aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go_list.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-01 01:08:03 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-01 01:08:03 -0400
commit83a71d464887f4b6cf9124d2f8c565e6f17f2bd3 (patch)
treeca86805900a974f684dc5531311a53e4836ec784 /nexgb/xgbgen/go_list.go
parent73154769b3eba60fe48a7c08882e8e64b1545e3f (diff)
downloadhaven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.tar.gz
haven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.tar.xz
haven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.zip
unions, events and errors... oh my
Diffstat (limited to 'nexgb/xgbgen/go_list.go')
-rw-r--r--nexgb/xgbgen/go_list.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/nexgb/xgbgen/go_list.go b/nexgb/xgbgen/go_list.go
index 03da22e..a95ba71 100644
--- a/nexgb/xgbgen/go_list.go
+++ b/nexgb/xgbgen/go_list.go
@@ -12,8 +12,6 @@ func (f *ListField) Define(c *Context) {
}
func (f *ListField) Read(c *Context) {
- c.Putln("")
-
switch t := f.Type.(type) {
case *Resource:
length := f.LengthExpr.Reduce("v.", "")
@@ -34,6 +32,10 @@ func (f *ListField) Read(c *Context) {
c.Putln("}")
c.Putln("b = pad(b)")
}
+ case *Union:
+ c.Putln("v.%s = make([]%s, %s)",
+ f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", ""))
+ c.Putln("b += Read%sList(buf[b:], v.%s)", t.SrcName(), f.SrcName())
case *Struct:
c.Putln("v.%s = make([]%s, %s)",
f.SrcName(), t.SrcName(), f.LengthExpr.Reduce("v.", ""))
@@ -45,8 +47,6 @@ func (f *ListField) Read(c *Context) {
}
func (f *ListField) Write(c *Context) {
- c.Putln("")
-
switch t := f.Type.(type) {
case *Resource:
length := f.LengthExpr.Reduce("v.", "")
@@ -65,6 +65,8 @@ func (f *ListField) Write(c *Context) {
c.Putln("}")
c.Putln("b = pad(b)")
}
+ case *Union:
+ c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName())
case *Struct:
c.Putln("b += %sListBytes(buf[b:], v.%s)", t.SrcName(), f.SrcName())
default: