diff options
author | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-10 17:01:42 -0400 |
---|---|---|
committer | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-10 17:01:42 -0400 |
commit | 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a (patch) | |
tree | 90a3200414c8ad6df8e7983a8e73fedfbe2b324e /nexgb/xgbgen/go_union.go | |
parent | e239bb3c68a4981a3916534203c2fbd6b96f593c (diff) | |
download | haven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.tar.gz haven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.tar.xz haven-0c50dc6241fa21712e041cfa2bfb9db4ccaef10a.zip |
a huge commit. splitting extensions into their own sub-packages.
Diffstat (limited to 'nexgb/xgbgen/go_union.go')
-rw-r--r-- | nexgb/xgbgen/go_union.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/nexgb/xgbgen/go_union.go b/nexgb/xgbgen/go_union.go index 73e85f7..91300a2 100644 --- a/nexgb/xgbgen/go_union.go +++ b/nexgb/xgbgen/go_union.go @@ -8,7 +8,7 @@ func (u *Union) Define(c *Context) { c.Putln("// Instead use one of the following constructors for '%s':", u.SrcName()) for _, field := range u.Fields { - c.Putln("// New%s%s(%s %s) %s", u.SrcName(), field.SrcName(), + c.Putln("// %s%sNew(%s %s) %s", u.SrcName(), field.SrcName(), field.SrcName(), field.SrcType(), u.SrcName()) } @@ -40,7 +40,7 @@ func (u *Union) New(c *Context) { for _, field := range u.Fields { c.Putln("// Union constructor for %s for field %s.", u.SrcName(), field.SrcName()) - c.Putln("func New%s%s(%s %s) %s {", + c.Putln("func %s%sNew(%s %s) %s {", u.SrcName(), field.SrcName(), field.SrcName(), field.SrcType(), u.SrcName()) c.Putln("var b int") @@ -66,7 +66,7 @@ func (u *Union) New(c *Context) { func (u *Union) Read(c *Context) { c.Putln("// Union read %s", u.SrcName()) - c.Putln("func Read%s(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) + c.Putln("func %sRead(buf []byte, v *%s) int {", u.SrcName(), u.SrcName()) c.Putln("var b int") c.Putln("") for _, field := range u.Fields { @@ -81,14 +81,14 @@ func (u *Union) Read(c *Context) { func (u *Union) ReadList(c *Context) { c.Putln("// Union list read %s", u.SrcName()) - c.Putln("func Read%sList(buf []byte, dest []%s) int {", + c.Putln("func %sReadList(buf []byte, dest []%s) int {", u.SrcName(), u.SrcName()) c.Putln("b := 0") c.Putln("for i := 0; i < len(dest); i++ {") c.Putln("dest[i] = %s{}", u.SrcName()) - c.Putln("b += Read%s(buf[b:], &dest[i])", u.SrcName()) + c.Putln("b += %sRead(buf[b:], &dest[i])", u.SrcName()) c.Putln("}") - c.Putln("return pad(b)") + c.Putln("return xgb.Pad(b)") c.Putln("}") c.Putln("") } @@ -121,7 +121,7 @@ func (u *Union) WriteList(c *Context) { c.Putln("for _, item := range list {") c.Putln("unionBytes = item.Bytes()") c.Putln("copy(buf[b:], unionBytes)") - c.Putln("b += pad(len(unionBytes))") + c.Putln("b += xgb.Pad(len(unionBytes))") c.Putln("}") c.Putln("return b") c.Putln("}") |