summaryrefslogtreecommitdiff
path: root/xgbgen/go_event.go
diff options
context:
space:
mode:
authorAndrew Gallant (Ocelot) <[email protected]>2012-04-30 16:18:17 -0400
committerAndrew Gallant (Ocelot) <[email protected]>2012-04-30 16:18:17 -0400
commit5d79dc324de0a23fd0543951f0fd1f0352018654 (patch)
treef924ee2fba3def91bec831e4a6577204470d412d /xgbgen/go_event.go
parentf7be3db65e559e77355537a11a88c8657ec4c059 (diff)
splitting up go specific code. too much for one file IMO. more progress. almost done with structs.
Diffstat (limited to 'xgbgen/go_event.go')
-rw-r--r--xgbgen/go_event.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/xgbgen/go_event.go b/xgbgen/go_event.go
new file mode 100644
index 0000000..d91fd7a
--- /dev/null
+++ b/xgbgen/go_event.go
@@ -0,0 +1,38 @@
+package main
+
+// Event types
+func (e *Event) Define(c *Context) {
+ c.Putln("// Event definition %s (%d)", e.SrcName(), e.Number)
+}
+
+func (e *Event) Read(c *Context, prefix string) {
+ c.Putln("// Event read %s", e.SrcName())
+}
+
+func (e *Event) Write(c *Context, prefix string) {
+ c.Putln("// Event write %s", e.SrcName())
+}
+
+// EventCopy types
+func (e *EventCopy) Define(c *Context) {
+ c.Putln("// EventCopy definition %s (%d)", e.SrcName(), e.Number)
+ c.Putln("")
+ c.Putln("const %s = %d", e.SrcName(), e.Number)
+ c.Putln("")
+ c.Putln("type %s %s", e.EvType(), e.Old.(*Event).EvType())
+ c.Putln("")
+ c.Putln("func New%s(buf []byte) %s {", e.SrcName(), e.EvType())
+ c.Putln("return (%s)(New%s(buf))", e.EvType(), e.Old.SrcName())
+ c.Putln("}")
+ c.Putln("")
+ c.Putln("func (ev %s) ImplementsEvent() { }", e.EvType())
+ c.Putln("")
+ c.Putln("func (ev %s) Bytes() []byte {", e.EvType())
+ c.Putln("return (%s)(ev).Bytes()", e.Old.(*Event).EvType())
+ c.Putln("}")
+ c.Putln("")
+ c.Putln("func init() {")
+ c.Putln("newEventFuncs[%d] = New%s", e.Number, e.SrcName())
+ c.Putln("}")
+ c.Putln("")
+}