diff options
author | aarzilli <alessandro.arzilli@gmail.com> | 2014-05-02 15:09:23 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2018-09-08 16:49:22 +0200 |
commit | a548d9d0f7b889627c43b18811357fad88760b2d (patch) | |
tree | 0d4a0ad302d753638dfdb16159e03d1fb87b0872 /nexgb/xgbgen/go_list.go | |
parent | 1f8bd79abee5d96a41a934d1eb8c74e90ccbcc8f (diff) | |
download | haven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.gz haven-a548d9d0f7b889627c43b18811357fad88760b2d.tar.xz haven-a548d9d0f7b889627c43b18811357fad88760b2d.zip |
Fix Issue #21: automatic calculation of alignment padding after lists
Diffstat (limited to 'nexgb/xgbgen/go_list.go')
-rw-r--r-- | nexgb/xgbgen/go_list.go | 10 |
1 files changed, 2 insertions, 8 deletions
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()) |