From: Vladimir Lavor Date: Tue, 15 Jun 2021 12:10:54 +0000 (+0200) Subject: Fix encode/decode for []bool X-Git-Tag: v0.4.0~14 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F32731%2F1;p=govpp.git Fix encode/decode for []bool Signed-off-by: Vladimir Lavor Change-Id: I6649d6825a208b9cd936bf8f3b80e69ff84f8b74 --- diff --git a/binapigen/gen_encoding.go b/binapigen/gen_encoding.go index d946771..ca1e848 100644 --- a/binapigen/gen_encoding.go +++ b/binapigen/gen_encoding.go @@ -21,10 +21,6 @@ import ( "github.com/sirupsen/logrus" ) -func init() { - //RegisterPlugin("encoding", GenerateEncoding) -} - func genMessageSize(g *GenFile, name string, fields []*Field) { g.P("func (m *", name, ") Size() (size int) {") g.P("if m == nil { return 0 }") @@ -230,7 +226,7 @@ func encodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom str g.P("buf.EncodeBytes(", name, "[:], ", length, ")") } return - case I8, I16, U16, I32, U32, I64, U64, F64: + case I8, I16, U16, I32, U32, I64, U64, F64, BOOL: gotype := BaseTypesGo[typ] if length != 0 { g.P("for i := 0; i < ", length, "; i++ {") @@ -268,7 +264,7 @@ func encodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom str } if isArray { switch typ { - case I8, U8, I16, U16, I32, U32, I64, U64, F64: + case I8, U8, I16, U16, I32, U32, I64, U64, F64, BOOL: g.P("}") } } @@ -369,7 +365,7 @@ func decodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom str g.P("copy(", name, "[:], buf.DecodeBytes(", size, "))") } return - case I8, I16, U16, I32, U32, I64, U64, F64: + case I8, I16, U16, I32, U32, I64, U64, F64, BOOL: if alloc { g.P(name, " = make([]", orig, ", ", size, ")") } @@ -401,7 +397,7 @@ func decodeBaseType(g *GenFile, typ, orig, name string, length int, sizefrom str } if isArray { switch typ { - case I8, U8, I16, U16, I32, U32, I64, U64, F64: + case I8, U8, I16, U16, I32, U32, I64, U64, F64, BOOL: g.P("}") } }