From 1c01d79ba14a802c603ca2e5bbd35156e3363b85 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 18 Jan 2017 09:53:26 +0100 Subject: Changed xgbgen to support xcb-proto 1.12 * Added minimal support for switch fields. * Changed the way Size is calculated to accomodate for lists inside structs (added to randr) * Removed heuristic to place alignment gaps, they are now explicitly described in xml --- nexgb/xgbgen/go.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'nexgb/xgbgen/go.go') diff --git a/nexgb/xgbgen/go.go b/nexgb/xgbgen/go.go index ace4e00..87b5028 100644 --- a/nexgb/xgbgen/go.go +++ b/nexgb/xgbgen/go.go @@ -186,11 +186,8 @@ func (f *ValueField) Read(c *Context, prefix string) { } func (f *ValueField) Write(c *Context, prefix string) { - // big time mofos - if rq, ok := f.Parent.(*Request); !ok || rq.SrcName() != "ConfigureWindow" { - WriteSimpleSingleField(c, - fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType) - } + WriteSimpleSingleField(c, + fmt.Sprintf("%s%s", prefix, f.MaskName), f.MaskType) c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) c.Putln("xgb.Put32(buf[b:], %s%s[i])", prefix, f.ListName) c.Putln("b += 4") @@ -200,16 +197,24 @@ func (f *ValueField) Write(c *Context, prefix string) { // Switch field func (f *SwitchField) Define(c *Context) { - c.Putln("// switch field: %s (%s)", f.Name, f.Expr) - panic("todo") + c.Putln("%s []uint32", f.Name) } func (f *SwitchField) Read(c *Context, prefix string) { - c.Putln("// reading switch field: %s (%s)", f.Name, f.Expr) - panic("todo") + c.Putln("") + c.Putln("%s%s = make([]uint32, %s)", + prefix, f.Name, f.ListLength().Reduce(prefix)) + c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) + c.Putln("%s%s[i] = xgb.Get32(buf[b:])", prefix, f.Name) + c.Putln("b += 4") + c.Putln("}") + c.Putln("b = xgb.Pad(b)") } func (f *SwitchField) Write(c *Context, prefix string) { - c.Putln("// writing switch field: %s (%s)", f.Name, f.Expr) - panic("todo") + c.Putln("for i := 0; i < %s; i++ {", f.ListLength().Reduce(prefix)) + c.Putln("xgb.Put32(buf[b:], %s%s[i])", prefix, f.Name) + c.Putln("b += 4") + c.Putln("}") + c.Putln("b = xgb.Pad(b)") } -- cgit v1.2.3