From 868b541e296dc47748ad03b8f0174c828d996529 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Thu, 13 Dec 2018 10:21:49 +0100 Subject: Add support for aliases and boolean type - aliases are now generated as new types or arrays (if length > 0) - bool is recognized as a boolean type and generated as Go bool - comment with original JSON is now prepended for each object type - interface Services is now generated at the top of the file to provide overview of what RPC services does the current module consists of - dump services now correctly return slice of the particular details type Change-Id: I788babc1c0f2de33e0febd87e5b200d54065b244 Signed-off-by: Ondrej Fabry --- cmd/binapi-generator/objects.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'cmd/binapi-generator/objects.go') diff --git a/cmd/binapi-generator/objects.go b/cmd/binapi-generator/objects.go index 2681085..97318cb 100644 --- a/cmd/binapi-generator/objects.go +++ b/cmd/binapi-generator/objects.go @@ -8,6 +8,7 @@ type Package struct { Enums []Enum Unions []Union Types []Type + Aliases []Alias Messages []Message Services []Service RefMap map[string]string @@ -37,6 +38,13 @@ type Type struct { Fields []Field } +// Alias represents VPP binary API alias +type Alias struct { + Name string + Type string + Length int +} + // Union represents VPP binary API union type Union struct { Name string @@ -105,16 +113,3 @@ func (s Service) IsRequestService() bool { // some binapi messages might have `null` reply (for example: memclnt) return s.ReplyType != "" && s.ReplyType != "null" // not null } - -func getSizeOfType(typ *Type) (size int) { - for _, field := range typ.Fields { - if n := getBinapiTypeSize(field.Type); n > 0 { - if field.Length > 0 { - size += n * field.Length - } else { - size += n - } - } - } - return size -} -- cgit 1.2.3-korg