diff options
| author | Andrew Gallant (Ocelot) <[email protected]> | 2012-05-03 01:00:01 -0400 |
|---|---|---|
| committer | Andrew Gallant (Ocelot) <[email protected]> | 2012-05-03 01:00:01 -0400 |
| commit | 9028aaf89872d8d90c65254c17658bfaf8a4918d (patch) | |
| tree | ba8cc21965e466d9fcc1e1c7d38d7f6bbf462fbb /xgbgen/context.go | |
| parent | 552804d994db62e1002f13a8cfbbbc2359d99eef (diff) | |
holy toldeo... things might actually be working
Diffstat (limited to 'xgbgen/context.go')
| -rw-r--r-- | xgbgen/context.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/xgbgen/context.go b/xgbgen/context.go index 33641b3..3e484f3 100644 --- a/xgbgen/context.go +++ b/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) |
