From fa21c9d726ebb807895a8571af9a16dab5cd8d6e Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 8 Feb 2019 01:16:32 +0100 Subject: Generator improvements and cleanup - generator now supports include-comments flag (as opt-in) - minor code cleanup in binapi-generator - remove obsolete unit tests - flatten examples from examples/cmd folder - introduce constant for checking compatibility in future versions Change-Id: I3545f2ba4b869a3b51d6d0de7e742f3f1e1be392 Signed-off-by: Ondrej Fabry --- cmd/binapi-generator/objects.go | 52 +++++++---------------------------------- 1 file changed, 8 insertions(+), 44 deletions(-) (limited to 'cmd/binapi-generator/objects.go') diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go index 4b424f5..75c7581 100644 --- a/cmd/binapi-generator/objects.go +++ b/cmd/binapi-generator/objects.go @@ -1,9 +1,5 @@ package main -import ( - "strings" -) - // Package represents collection of objects parsed from VPP binary API JSON data type Package struct { APIVersion string @@ -52,6 +48,14 @@ type Type struct { Fields []Field } +// Field represents VPP binary API object field +type Field struct { + Name string + Type string + Length int + SizeFrom string +} + // Union represents VPP binary API union type Union struct { Name string @@ -75,43 +79,3 @@ const ( eventMessage // VPP event message otherMessage // other VPP message ) - -// Field represents VPP binary API object field -type Field struct { - Name string - Type string - Length int - SizeFrom string -} - -func (f *Field) IsArray() bool { - return f.Length > 0 || f.SizeFrom != "" -} - -func (s Service) MethodName() string { - reqTyp := camelCaseName(s.RequestType) - - // method name is same as parameter type name by default - method := reqTyp - if s.Stream { - // use Dump as prefix instead of suffix for stream services - if m := strings.TrimSuffix(method, "Dump"); method != m { - method = "Dump" + m - } - } - - return method -} - -func (s Service) IsDumpService() bool { - return s.Stream -} - -func (s Service) IsEventService() bool { - return len(s.Events) > 0 -} - -func (s Service) IsRequestService() bool { - // some binapi messages might have `null` reply (for example: memclnt) - return s.ReplyType != "" && s.ReplyType != "null" // not null -} -- cgit 1.2.3-korg