aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go_struct.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-10 23:57:34 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-10 23:57:34 -0400
commitc00652934e4ec68016a152b9bea10273b0be8726 (patch)
tree069dc287fa76dcec2d6240e1afdfe5652118a88a /nexgb/xgbgen/go_struct.go
parenta3363755cdfdafdf02d5a772bd47a462e99af057 (diff)
downloadhaven-c00652934e4ec68016a152b9bea10273b0be8726.tar.gz
haven-c00652934e4ec68016a152b9bea10273b0be8726.tar.xz
haven-c00652934e4ec68016a152b9bea10273b0be8726.zip
better docs
Diffstat (limited to 'nexgb/xgbgen/go_struct.go')
-rw-r--r--nexgb/xgbgen/go_struct.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/nexgb/xgbgen/go_struct.go b/nexgb/xgbgen/go_struct.go
index 7f33b21..a988893 100644
--- a/nexgb/xgbgen/go_struct.go
+++ b/nexgb/xgbgen/go_struct.go
@@ -1,8 +1,6 @@
package main
func (s *Struct) Define(c *Context) {
- c.Putln("// '%s' struct definition", s.SrcName())
- c.Putln("// Size: %s", s.Size())
c.Putln("type %s struct {", s.SrcName())
for _, field := range s.Fields {
field.Define(c)
@@ -34,7 +32,8 @@ func (s *Struct) Define(c *Context) {
// the number of bytes read off the buffer.
// 'ReadStructName' should only be used to read raw reply data from the wire.
func (s *Struct) Read(c *Context) {
- c.Putln("// Struct read %s", s.SrcName())
+ c.Putln("// %sRead reads a byte slice into a %s value.",
+ s.SrcName(), s.SrcName())
c.Putln("func %sRead(buf []byte, v *%s) int {", s.SrcName(), s.SrcName())
c.Putln("b := 0")
@@ -53,10 +52,10 @@ func (s *Struct) Read(c *Context) {
// a source (i.e., the buffer) byte slice, and a destination slice and returns
// the number of bytes read from the byte slice.
func (s *Struct) ReadList(c *Context) {
- c.Putln("// Struct list read %s", s.SrcName())
+ c.Putln("// %sReadList reads a byte slice into a list of %s values.",
+ s.SrcName(), s.SrcName())
c.Putln("func %sReadList(buf []byte, dest []%s) int {",
s.SrcName(), s.SrcName())
-
c.Putln("b := 0")
c.Putln("for i := 0; i < len(dest); i++ {")
c.Putln("dest[i] = %s{}", s.SrcName())
@@ -70,7 +69,7 @@ func (s *Struct) ReadList(c *Context) {
}
func (s *Struct) Write(c *Context) {
- c.Putln("// Struct write %s", s.SrcName())
+ c.Putln("// Bytes writes a %s value to a byte slice.", s.SrcName())
c.Putln("func (v %s) Bytes() []byte {", s.SrcName())
c.Putln("buf := make([]byte, %s)", s.Size().Reduce("v."))
c.Putln("b := 0")
@@ -85,7 +84,8 @@ func (s *Struct) Write(c *Context) {
}
func (s *Struct) WriteList(c *Context) {
- c.Putln("// Write struct list %s", s.SrcName())
+ c.Putln("// %sListBytes writes a list of %s values to a byte slice.",
+ s.SrcName())
c.Putln("func %sListBytes(buf []byte, list []%s) int {",
s.SrcName(), s.SrcName())
c.Putln("b := 0")
@@ -101,7 +101,8 @@ func (s *Struct) WriteList(c *Context) {
}
func (s *Struct) WriteListSize(c *Context) {
- c.Putln("// Struct list size %s", s.SrcName())
+ c.Putln("// %sListSize computes the size (bytes) of a list of %s values.",
+ s.SrcName(), s.SrcName())
c.Putln("func %sListSize(list []%s) int {", s.SrcName(), s.SrcName())
c.Putln("size := 0")
if s.Size().Expression.Concrete() {