diff options
author | 2018-08-21 22:32:11 +0200 | |
---|---|---|
committer | 2018-08-21 22:32:11 +0200 | |
commit | 08ddeac03fd3832d44a3dfb48ee85ecd95d2b388 (patch) | |
tree | 6b94f6acc86686dfb078cd21c7d67865cac4ae8f /cmd/binapi-generator/generate.go | |
parent | c4ccfc75f0698e148cfa37a3a1dda1a46bb29109 (diff) |
Make the warnings for validating services more obvious
- there is currently simple validation for services,
which checks type of services and its name for request/reply
- there is one known warning in dhcp package for dhcp_client_config,
since it is single case for normal requests subscribing to event
Change-Id: I504a52b9a1823ced841b2ead712318ef5e5477b1
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'cmd/binapi-generator/generate.go')
-rw-r--r-- | cmd/binapi-generator/generate.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/cmd/binapi-generator/generate.go b/cmd/binapi-generator/generate.go index 251d39d..e29c84d 100644 --- a/cmd/binapi-generator/generate.go +++ b/cmd/binapi-generator/generate.go @@ -504,13 +504,7 @@ func generateService(ctx *context, w io.Writer, svc *Service) { reqTyp := camelCaseName(svc.RequestType) // method name is same as parameter type name by default - method := reqTyp - if svc.Stream { - // use Dump as prefix instead of suffix for stream services - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - } + method := svc.MethodName() params := fmt.Sprintf("*%s", reqTyp) returns := "error" if replyTyp := camelCaseName(svc.ReplyType); replyTyp != "" { @@ -521,25 +515,28 @@ func generateService(ctx *context, w io.Writer, svc *Service) { } // generateMessageNameGetter generates getter for original VPP message name into the provider writer -func generateMessageNameGetter(w io.Writer, structName string, msgName string) { - fmt.Fprintln(w, "func (*"+structName+") GetMessageName() string {") - fmt.Fprintln(w, "\treturn \""+msgName+"\"") - fmt.Fprintln(w, "}") +func generateMessageNameGetter(w io.Writer, structName, msgName string) { + fmt.Fprintf(w, `func (*%s) GetMessageName() string { + return %q +} +`, structName, msgName) } // generateTypeNameGetter generates getter for original VPP type name into the provider writer -func generateTypeNameGetter(w io.Writer, structName string, msgName string) { - fmt.Fprintln(w, "func (*"+structName+") GetTypeName() string {") - fmt.Fprintln(w, "\treturn \""+msgName+"\"") - fmt.Fprintln(w, "}") +func generateTypeNameGetter(w io.Writer, structName, msgName string) { + fmt.Fprintf(w, `func (*%s) GetTypeName() string { + return %q +} +`, structName, msgName) } // generateCrcGetter generates getter for CRC checksum of the message definition into the provider writer -func generateCrcGetter(w io.Writer, structName string, crc string) { +func generateCrcGetter(w io.Writer, structName, crc string) { crc = strings.TrimPrefix(crc, "0x") - fmt.Fprintln(w, "func (*"+structName+") GetCrcString() string {") - fmt.Fprintln(w, "\treturn \""+crc+"\"") - fmt.Fprintln(w, "}") + fmt.Fprintf(w, `func (*%s) GetCrcString() string { + return %q +} +`, structName, crc) } // generateMessageTypeGetter generates message factory for the generated message into the provider writer |