aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/go.go
diff options
context:
space:
mode:
authoraarzilli <alessandro.arzilli@gmail.com>2017-01-18 09:53:26 +0100
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:26 +0200
commit1c01d79ba14a802c603ca2e5bbd35156e3363b85 (patch)
tree5ba818deb4c33dd44df9b5c66dc9d45f3b1672e5 /nexgb/xgbgen/go.go
parenta102c4056f6b01035772cf79060012ff800c9669 (diff)
downloadhaven-1c01d79ba14a802c603ca2e5bbd35156e3363b85.tar.gz
haven-1c01d79ba14a802c603ca2e5bbd35156e3363b85.tar.xz
haven-1c01d79ba14a802c603ca2e5bbd35156e3363b85.zip
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
Diffstat (limited to 'nexgb/xgbgen/go.go')
-rw-r--r--nexgb/xgbgen/go.go27
1 files changed, 16 insertions, 11 deletions
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)")
}