diff options
author | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-01 01:08:03 -0400 |
---|---|---|
committer | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-01 01:08:03 -0400 |
commit | 83a71d464887f4b6cf9124d2f8c565e6f17f2bd3 (patch) | |
tree | ca86805900a974f684dc5531311a53e4836ec784 /nexgb/xgbgen/field.go | |
parent | 73154769b3eba60fe48a7c08882e8e64b1545e3f (diff) | |
download | haven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.tar.gz haven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.tar.xz haven-83a71d464887f4b6cf9124d2f8c565e6f17f2bd3.zip |
unions, events and errors... oh my
Diffstat (limited to 'nexgb/xgbgen/field.go')
-rw-r--r-- | nexgb/xgbgen/field.go | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/nexgb/xgbgen/field.go b/nexgb/xgbgen/field.go index 0f2323e..6d39af2 100644 --- a/nexgb/xgbgen/field.go +++ b/nexgb/xgbgen/field.go @@ -9,6 +9,7 @@ type Field interface { Initialize(p *Protocol) SrcName() string XmlName() string + SrcType() string Size() Size Define(c *Context) @@ -30,6 +31,10 @@ func (p *PadField) XmlName() string { panic("illegal to take XML name of a pad field") } +func (f *PadField) SrcType() string { + panic("it is illegal to call SrcType on a SwitchField field") +} + func (p *PadField) Size() Size { return newFixedSize(p.Bytes) } @@ -53,6 +58,10 @@ func (f *SingleField) XmlName() string { return f.xmlName } +func (f *SingleField) SrcType() string { + return f.Type.SrcName() +} + func (f *SingleField) Size() Size { return f.Type.Size() } @@ -72,9 +81,9 @@ func (f *ListField) XmlName() string { return f.xmlName } -// func (f *ListField) Size() Size { - // return newExpressionSize(f.LengthExpr).Multiply(f.Type.Size()) -// } +func (f *ListField) SrcType() string { + return fmt.Sprintf("[]%s", f.Type.SrcName()) +} func (f *ListField) Size() Size { simpleLen := &Function{ @@ -126,6 +135,10 @@ func (f *ExprField) XmlName() string { return f.xmlName } +func (f *ExprField) SrcType() string { + return f.Type.SrcName() +} + func (f *ExprField) Size() Size { return f.Type.Size() } @@ -150,6 +163,10 @@ func (f *ValueField) XmlName() string { panic("it is illegal to call XmlName on a ValueField field") } +func (f *ValueField) SrcType() string { + return f.MaskType.SrcName() +} + func (f *ValueField) Size() Size { return f.MaskType.Size() } @@ -174,6 +191,10 @@ func (f *SwitchField) XmlName() string { panic("it is illegal to call XmlName on a SwitchField field") } +func (f *SwitchField) SrcType() string { + panic("it is illegal to call SrcType on a SwitchField field") +} + // XXX: This is a bit tricky. The size has to be represented as a non-concrete // expression that finds *which* bitcase fields are included, and sums the // sizes of those fields. |