diff options
author | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-06 02:21:31 -0400 |
---|---|---|
committer | Andrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu> | 2012-05-06 02:21:31 -0400 |
commit | 18b2d420b092d71313f0c05210c3038ff32483e7 (patch) | |
tree | e934f6bddd11863e82d591fb2a168d60be382f9d /nexgb/xgbgen/protocol.go | |
parent | 99bc76de54729df5494faa944d4da96a8885d51e (diff) | |
download | haven-18b2d420b092d71313f0c05210c3038ff32483e7.tar.gz haven-18b2d420b092d71313f0c05210c3038ff32483e7.tar.xz haven-18b2d420b092d71313f0c05210c3038ff32483e7.zip |
added documentation and did some slight restructuring. it's party time.
Diffstat (limited to 'nexgb/xgbgen/protocol.go')
-rw-r--r-- | nexgb/xgbgen/protocol.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/nexgb/xgbgen/protocol.go b/nexgb/xgbgen/protocol.go new file mode 100644 index 0000000..505b400 --- /dev/null +++ b/nexgb/xgbgen/protocol.go @@ -0,0 +1,41 @@ +package main + +import ( + "strings" +) + +// Protocol is a type that encapsulates all information about one +// particular XML file. It also contains links to other protocol types +// if this protocol imports other other extensions. The import relationship +// is recursive. +type Protocol struct { + Name string + ExtXName string + ExtName string + MajorVersion string + MinorVersion string + + Imports []*Protocol + Types []Type + Requests []*Request +} + +// Initialize traverses all structures, looks for 'Translation' type, +// and looks up the real type in the namespace. It also sets the source +// name for all relevant fields/structures. +// This is necessary because we don't traverse the XML in order initially. +func (p *Protocol) Initialize() { + for _, typ := range p.Types { + typ.Initialize(p) + } + for _, req := range p.Requests { + req.Initialize(p) + } +} + +// isExt returns true if this protocol is an extension. +// i.e., it's name isn't "xproto". +func (p *Protocol) isExt() bool { + return strings.ToLower(p.Name) == "xproto" +} + |