From b32eeae088bd3e2bb8d345aab4274a1e79fdb10d Mon Sep 17 00:00:00 2001 From: Daniel Grau Date: Mon, 6 Jan 2025 17:36:36 +0000 Subject: [PATCH] Generate server bool --- dataplane/apigen/ccgen/ccgen.go | 2 +- dataplane/apigen/ccgen/servergen.go | 2 +- dataplane/apigen/protogen/protogen.go | 2 +- dataplane/apigen/typeinfo/typeinfo.go | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dataplane/apigen/ccgen/ccgen.go b/dataplane/apigen/ccgen/ccgen.go index ae79cd69..2cd6642a 100644 --- a/dataplane/apigen/ccgen/ccgen.go +++ b/dataplane/apigen/ccgen/ccgen.go @@ -36,7 +36,7 @@ func GenClient(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoOutDir, ccOutDir ProtoOutDir: protoOutDir, CCOutDir: ccOutDir, } - d, err := typeinfo.Data(doc, sai, "", "", ccOutDir, protoOutDir) + d, err := typeinfo.Data(doc, sai, "", "", ccOutDir, protoOutDir, false) if err != nil { return nil, err } diff --git a/dataplane/apigen/ccgen/servergen.go b/dataplane/apigen/ccgen/servergen.go index bc15ef48..61c1434a 100644 --- a/dataplane/apigen/ccgen/servergen.go +++ b/dataplane/apigen/ccgen/servergen.go @@ -30,7 +30,7 @@ func GenServer(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoOutDir, ccOutDir ProtoOutDir: protoOutDir, CCOutDir: ccOutDir, } - d, err := typeinfo.Data(doc, sai, "", "", ccOutDir, protoOutDir) + d, err := typeinfo.Data(doc, sai, "", "", ccOutDir, protoOutDir, false) if err != nil { return nil, err } diff --git a/dataplane/apigen/protogen/protogen.go b/dataplane/apigen/protogen/protogen.go index 28dd9558..be1ac807 100644 --- a/dataplane/apigen/protogen/protogen.go +++ b/dataplane/apigen/protogen/protogen.go @@ -34,7 +34,7 @@ func Generate(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoP return nil, err } files["common.proto"] = common - d, err := typeinfo.Data(doc, sai, protoPackage, protoGoPackage, "", protoOutDir) + d, err := typeinfo.Data(doc, sai, protoPackage, protoGoPackage, "", protoOutDir, false) if err != nil { return nil, err } diff --git a/dataplane/apigen/typeinfo/typeinfo.go b/dataplane/apigen/typeinfo/typeinfo.go index 025e7482..d4aacf38 100644 --- a/dataplane/apigen/typeinfo/typeinfo.go +++ b/dataplane/apigen/typeinfo/typeinfo.go @@ -82,7 +82,7 @@ type APITemplate struct { CCOutDir string } -func Data(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoPackage, ccOutDir, protoOutDir string) (*TemplateData, error) { +func Data(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoPackage, ccOutDir, protoOutDir string, server bool) (*TemplateData, error) { data := &TemplateData{ APIs: map[string]*APITemplate{}, } @@ -123,7 +123,7 @@ func Data(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoPacka data.APIs[apiName].Types = append(data.APIs[apiName].Types, protoReqType, protoRespType) } - populateCCInfo(meta, apiName, sai, doc, fn, gFunc) + populateCCInfo(meta, apiName, sai, doc, fn, gFunc, server) if gFunc.Operation == getAttrOp { enum := genProtoEnum(doc, apiName, meta) @@ -135,7 +135,7 @@ func Data(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoPacka data.APIs[apiName].Types = append(data.APIs[apiName].Types, msgs...) } if gFunc.Operation == createOp { - convertFn := genConvertFunc(gFunc, meta, doc, sai, fn) + convertFn := genConvertFunc(gFunc, meta, doc, sai, fn, server) data.APIs[apiName].ConvertFuncs = append(data.APIs[apiName].ConvertFuncs, convertFn) } data.APIs[apiName].Funcs = append(data.APIs[apiName].Funcs, gFunc) @@ -144,7 +144,7 @@ func Data(doc *docparser.SAIInfo, sai *saiast.SAIAPI, protoPackage, protoGoPacka return data, nil } -func genConvertFunc(genFunc *GenFunc, meta *saiast.FuncMetadata, info *docparser.SAIInfo, sai *saiast.SAIAPI, fn *saiast.TypeDecl) *GenFunc { +func genConvertFunc(genFunc *GenFunc, meta *saiast.FuncMetadata, info *docparser.SAIInfo, sai *saiast.SAIAPI, fn *saiast.TypeDecl, server bool) *GenFunc { convertFn := &GenFunc{ Name: "convert_" + meta.Name, Operation: genFunc.Operation, @@ -209,7 +209,7 @@ func getParamDefs(params []saiast.TypeDecl) ([]string, []string) { // populateCCInfo returns a two structs with the template data for the given function. // The first is the implementation of the API: CreateFoo. // The second is the a conversion func from attribute list to the proto message. covert_create_foo. -func populateCCInfo(meta *saiast.FuncMetadata, apiName string, sai *saiast.SAIAPI, info *docparser.SAIInfo, fn *saiast.TypeDecl, genFunc *GenFunc) { +func populateCCInfo(meta *saiast.FuncMetadata, apiName string, sai *saiast.SAIAPI, info *docparser.SAIInfo, fn *saiast.TypeDecl, genFunc *GenFunc, server bool) { if info.Attrs[meta.TypeName] == nil { fmt.Printf("no doc info for type: %v\n", meta.TypeName) return