From a548d9d0f7b889627c43b18811357fad88760b2d Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 2 May 2014 15:09:23 +0200 Subject: Fix Issue #21: automatic calculation of alignment padding after lists --- nexgb/xgbgen/go_list.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'nexgb/xgbgen/go_list.go') diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go index fa8df69..1e85d9f 100644 --- a/nexgb/xgbgen/go_list.go +++ b/nexgb/xgbgen/go_list.go @@ -21,7 +21,6 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("for i := 0; i < int(%s); i++ {", length) ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") case *Base: length := f.LengthExpr.Reduce(prefix) if strings.ToLower(t.XmlName()) == "char" { @@ -38,7 +37,7 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), length) c.Putln("copy(%s%s[:%s], buf[b:])", prefix, f.SrcName(), length) - c.Putln("b += xgb.Pad(int(%s))", length) + c.Putln("b += int(%s)", length) } else { c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), length) @@ -46,7 +45,6 @@ func (f *ListField) Read(c *Context, prefix string) { ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") } case *TypeDef: length := f.LengthExpr.Reduce(prefix) @@ -55,7 +53,6 @@ func (f *ListField) Read(c *Context, prefix string) { c.Putln("for i := 0; i < int(%s); i++ {", length) ReadSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") case *Union: c.Putln("%s%s = make([]%s, %s)", prefix, f.SrcName(), t.SrcName(), f.LengthExpr.Reduce(prefix)) @@ -80,18 +77,16 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") case *Base: length := f.Length().Reduce(prefix) if t.SrcName() == "byte" { c.Putln("copy(buf[b:], %s%s[:%s])", prefix, f.SrcName(), length) - c.Putln("b += xgb.Pad(int(%s))", length) + c.Putln("b += int(%s)", length) } else { c.Putln("for i := 0; i < int(%s); i++ {", length) WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") } case *TypeDef: length := f.Length().Reduce(prefix) @@ -99,7 +94,6 @@ func (f *ListField) Write(c *Context, prefix string) { WriteSimpleSingleField(c, fmt.Sprintf("%s%s[i]", prefix, f.SrcName()), t) c.Putln("}") - c.Putln("b = xgb.Pad(b)") case *Union: c.Putln("b += %sListBytes(buf[b:], %s%s)", t.SrcName(), prefix, f.SrcName()) -- cgit v1.2.3-70-g09d2