Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate server bool #516

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dataplane/apigen/ccgen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion dataplane/apigen/ccgen/servergen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion dataplane/apigen/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 5 additions & 5 deletions dataplane/apigen/typeinfo/typeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Loading