aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/context.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-03 01:00:01 -0400
committerAndrew Gallant (Ocelot) <Andrew.Gallant@tufts.edu>2012-05-03 01:00:01 -0400
commit5cdae5950c357564300c0ee3fb4dc9e7bbf4946b (patch)
tree1ca6c09455b060b9f607c3e275ac14b5c57bbdc1 /nexgb/xgbgen/context.go
parent39507f86ab0468292c24081a80f41c1799d6b477 (diff)
downloadhaven-5cdae5950c357564300c0ee3fb4dc9e7bbf4946b.tar.gz
haven-5cdae5950c357564300c0ee3fb4dc9e7bbf4946b.tar.xz
haven-5cdae5950c357564300c0ee3fb4dc9e7bbf4946b.zip
holy toldeo... things might actually be working
Diffstat (limited to 'nexgb/xgbgen/context.go')
-rw-r--r--nexgb/xgbgen/context.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/nexgb/xgbgen/context.go b/nexgb/xgbgen/context.go
index 33641b3..3e484f3 100644
--- a/nexgb/xgbgen/context.go
+++ b/nexgb/xgbgen/context.go
@@ -5,6 +5,7 @@ import (
"encoding/xml"
"fmt"
"log"
+ "time"
)
type Context struct {
@@ -47,6 +48,26 @@ func (c *Context) Morph(xmlBytes []byte) {
// Translate XML types to nice types
c.protocol = parsedXml.Translate()
+ // Start with Go header.
+ c.Putln("package xgb")
+ c.Putln("")
+ c.Putln("/*")
+ c.Putln("\tThis file was generated by %s.xml on %s.",
+ c.protocol.Name, time.Now().Format("Jan 2 2006 3:04:05pm MST"))
+ c.Putln("\tThis file is automatically generated. Edit at your peril!")
+ c.Putln("*/")
+ c.Putln("")
+
+ // Write imports in comments
+ if len(c.protocol.Imports) > 0 {
+ c.Putln("// Imports are not necessary for XGB because everything is ")
+ c.Putln("// in one package. They are still listed here for reference.")
+ for _, imp := range c.protocol.Imports {
+ c.Putln("// import \"%s\"", imp.Name)
+ }
+ c.Putln("")
+ }
+
// Now write Go source code
for _, typ := range c.protocol.Types {
typ.Define(c)