When writing, don't pad the length of bytes produced from inner
structs/unions. Each type should take care of its own padding. Close #14.
This commit is contained in:
@@ -152,13 +152,13 @@ func (f *SingleField) Write(c *Context, prefix string) {
|
||||
c.Putln("{")
|
||||
c.Putln("unionBytes := %s%s.Bytes()", prefix, f.SrcName())
|
||||
c.Putln("copy(buf[b:], unionBytes)")
|
||||
c.Putln("b += xgb.Pad(len(unionBytes))")
|
||||
c.Putln("b += len(unionBytes)")
|
||||
c.Putln("}")
|
||||
case *Struct:
|
||||
c.Putln("{")
|
||||
c.Putln("structBytes := %s%s.Bytes()", prefix, f.SrcName())
|
||||
c.Putln("copy(buf[b:], structBytes)")
|
||||
c.Putln("b += xgb.Pad(len(structBytes))")
|
||||
c.Putln("b += len(structBytes)")
|
||||
c.Putln("}")
|
||||
default:
|
||||
log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type)
|
||||
|
||||
Reference in New Issue
Block a user