Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
DanG100 committed Jul 31, 2023
1 parent 9035ac5 commit 98e40ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions dataplane/standalone/apigen/ccgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"fmt"
"strings"
"text/template"

strcase "github.com/stoewer/go-strcase"
)

func createCCData(sai *saiAPI, fn typeDecl) (*templateFunc, bool, string) {
Expand All @@ -41,7 +39,7 @@ func createCCData(sai *saiAPI, fn typeDecl) (*templateFunc, bool, string) {
if strings.Contains(param.typ, "entry") {
tf.Entry = fmt.Sprintf("common_entry_t entry = {.%s = %s};", name, name)
name = "entry"
entryType = strcase.UpperCamelCase(strings.TrimSuffix(strings.TrimPrefix(param.typ, "const sai_"), "_t"))
entryType = trimSAIName(strings.TrimPrefix(param.typ, "const"), true, false)
}
if i == 1 && param.name == "switch_id" {
isSwitchScoped = true
Expand Down
4 changes: 2 additions & 2 deletions dataplane/standalone/apigen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func populateTmplDataFromFunc(protoTmplData *protoTmplData, funcName, entryType,
RequestName: strcase.UpperCamelCase(funcName + "_request"),
ResponseName: strcase.UpperCamelCase(funcName + "_response"),
}
nameTrimmed := strings.TrimSuffix(strings.TrimPrefix(apiName, "sai_"), "_api_t")
apiNameTrimmed := strings.TrimSuffix(trimSAIName(apiName, false, false), "_api")
idField := protoTmplField{
Index: 1,
ProtoType: "uint64",
Expand Down Expand Up @@ -103,7 +103,7 @@ func populateTmplDataFromFunc(protoTmplData *protoTmplData, funcName, entryType,

// For types that begin sai_api_name, generate them in the package.
// TODO: Otherwise mark them for generation in a common package.
if strings.HasPrefix(attr.SaiType, "sai_"+nameTrimmed) {
if strings.HasPrefix(attr.SaiType, "sai_"+apiNameTrimmed) {
protoName := trimSAIName(attr.SaiType, true, false)
// TODO: Generated code for non-enum types.
if vals, ok := xmlInfo.enums[attr.SaiType]; ok {
Expand Down

0 comments on commit 98e40ef

Please sign in to comment.