aboutsummaryrefslogtreecommitdiffstats
path: root/binapigen
diff options
context:
space:
mode:
authorVladimir Lavor <vlavor@cisco.com>2021-06-15 14:10:54 +0200
committerVladimir Lavor <vlavor@cisco.com>2021-06-15 14:10:54 +0200
commit5de7f6b85458615fa592a335d45c546397f32c9a (patch)
tree606884221757d050a3efa487639e83b1be5b9ee0 /binapigen
parentda95997338b77811bc2ea850db393c652b3bd18e (diff)
Fix encode/decode for []bool
Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: I6649d6825a208b9cd936bf8f3b80e69ff84f8b74
Diffstat (limited to 'binapigen')
-rw-r--r--binapigen/gen_encoding.go12
1 files changed, 4 insertions, 8 deletions
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("}")
}
}