diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-09-09 09:56:59 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-09-09 09:56:59 +0200 |
commit | ccb7b913d54fafdf08b36ac7eb36e462b1ecc9eb (patch) | |
tree | 1cf8f9fa125e577a0887519f0c0c436891e0983a /cmd/binapi-generator/parse.go | |
parent | d06548e4f4492c181f04a5fc9bf994764278e68b (diff) |
Fix compatibility with latest master (20.01-rc0)
- fixed generator for new string types
- update simple client example
- regenerate examples binapi for VPP 19.08
Change-Id: If4fe78c130d95641f35f75cd0262b35b032acaf8
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'cmd/binapi-generator/parse.go')
-rw-r--r-- | cmd/binapi-generator/parse.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/cmd/binapi-generator/parse.go b/cmd/binapi-generator/parse.go index 8852ae2..3867dd4 100644 --- a/cmd/binapi-generator/parse.go +++ b/cmd/binapi-generator/parse.go @@ -63,7 +63,8 @@ const ( // field meta info const ( - fieldMetaLimit = "limit" + fieldMetaLimit = "limit" + fieldMetaDefault = "default" ) // module options @@ -448,13 +449,16 @@ func parseField(ctx *context, field *jsongo.JSONNode) (*Field, error) { } if field.Len() >= 3 { - if field.At(2).GetType() == jsongo.TypeValue { + switch field.At(2).GetType() { + case jsongo.TypeValue: fieldLength, ok := field.At(2).Get().(float64) if !ok { return nil, fmt.Errorf("field length is %T, not float64", field.At(2).Get()) } f.Length = int(fieldLength) - } else if field.At(2).GetType() == jsongo.TypeMap { + f.SpecifiedLen = true + + case jsongo.TypeMap: fieldMeta := field.At(2) for _, key := range fieldMeta.GetKeys() { @@ -463,11 +467,13 @@ func parseField(ctx *context, field *jsongo.JSONNode) (*Field, error) { switch metaName := key.(string); metaName { case fieldMetaLimit: f.Meta.Limit = int(metaNode.Get().(float64)) + case fieldMetaDefault: + f.Meta.Default = metaNode.Get().(float64) default: logrus.Warnf("unknown meta info (%s) for field (%s)", metaName, fieldName) } } - } else { + default: return nil, errors.New("invalid JSON for field specified") } } |