From 0c50dc6241fa21712e041cfa2bfb9db4ccaef10a Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 17:01:42 -0400 Subject: a huge commit. splitting extensions into their own sub-packages. --- nexgb/xcmisc/xcmisc.go | 320 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 nexgb/xcmisc/xcmisc.go (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go new file mode 100644 index 0000000..324d455 --- /dev/null +++ b/nexgb/xcmisc/xcmisc.go @@ -0,0 +1,320 @@ +package xcmisc + +/* + This file was generated by xc_misc.xml on May 10 2012 4:20:28pm EDT. + This file is automatically generated. Edit at your peril! +*/ + +import ( + "github.com/BurntSushi/xgb" + + "github.com/BurntSushi/xgb/xproto" +) + +// Init must be called before using the XC-MISC extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 7, "XC-MISC").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named XC-MISC could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["XC-MISC"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["XC-MISC"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["XC-MISC"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["XC-MISC"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) +} + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Int8' + +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Char' + +// Skipping definition for base type 'Card32' + +// Skipping definition for base type 'Double' + +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + +// Request GetVersion +// size: 8 +type GetVersionCookie struct { + *xgb.Cookie +} + +func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} +} + +// Request reply for GetVersion +// size: 12 +type GetVersionReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + ServerMajorVersion uint16 + ServerMinorVersion uint16 +} + +// Waits and reads reply data from request GetVersion +func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// Read reply into structure from buffer for GetVersion +func getVersionReply(buf []byte) *GetVersionReply { + v := new(GetVersionReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.ServerMajorVersion = xgb.Get16(buf[b:]) + b += 2 + + v.ServerMinorVersion = xgb.Get16(buf[b:]) + b += 2 + + return v +} + +// Write request to wire for GetVersion +func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 0 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) + b += 2 + + return buf +} + +// Request GetXIDRange +// size: 4 +type GetXIDRangeCookie struct { + *xgb.Cookie +} + +func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} +} + +// Request reply for GetXIDRange +// size: 16 +type GetXIDRangeReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StartId uint32 + Count uint32 +} + +// Waits and reads reply data from request GetXIDRange +func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getXIDRangeReply(buf), nil +} + +// Read reply into structure from buffer for GetXIDRange +func getXIDRangeReply(buf []byte) *GetXIDRangeReply { + v := new(GetXIDRangeReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.StartId = xgb.Get32(buf[b:]) + b += 4 + + v.Count = xgb.Get32(buf[b:]) + b += 4 + + return v +} + +// Write request to wire for GetXIDRange +func getXIDRangeRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 1 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request GetXIDList +// size: 8 +type GetXIDListCookie struct { + *xgb.Cookie +} + +func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} +} + +func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} +} + +// Request reply for GetXIDList +// size: (32 + xgb.Pad((int(IdsLen) * 4))) +type GetXIDListReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + IdsLen uint32 + // padding: 20 bytes + Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) +} + +// Waits and reads reply data from request GetXIDList +func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getXIDListReply(buf), nil +} + +// Read reply into structure from buffer for GetXIDList +func getXIDListReply(buf []byte) *GetXIDListReply { + v := new(GetXIDListReply) + b := 1 // skip reply determinant + + b += 1 // padding + + v.Sequence = xgb.Get16(buf[b:]) + b += 2 + + v.Length = xgb.Get32(buf[b:]) // 4-byte units + b += 4 + + v.IdsLen = xgb.Get32(buf[b:]) + b += 4 + + b += 20 // padding + + v.Ids = make([]uint32, v.IdsLen) + for i := 0; i < int(v.IdsLen); i++ { + v.Ids[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) + + return v +} + +// Write request to wire for GetXIDList +func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["XC-MISC"] + b += 1 + + buf[b] = 2 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put32(buf[b:], Count) + b += 4 + + return buf +} -- cgit v1.2.3 From a3363755cdfdafdf02d5a772bd47a462e99af057 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 20:06:22 -0400 Subject: adding package header comments --- nexgb/xcmisc/xcmisc.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 324d455..d4f7b0d 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -1,7 +1,8 @@ +// Package xcmisc is the X client API for the XC-MISC extension. package xcmisc /* - This file was generated by xc_misc.xml on May 10 2012 4:20:28pm EDT. + This file was generated by xc_misc.xml on May 10 2012 8:04:32pm EDT. This file is automatically generated. Edit at your peril! */ @@ -39,6 +40,8 @@ func init() { xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Float' + // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' @@ -61,8 +64,6 @@ func init() { // Skipping definition for base type 'Bool' -// Skipping definition for base type 'Float' - // Request GetVersion // size: 8 type GetVersionCookie struct { -- cgit v1.2.3 From c00652934e4ec68016a152b9bea10273b0be8726 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Thu, 10 May 2012 23:57:34 -0400 Subject: better docs --- nexgb/xcmisc/xcmisc.go | 59 +++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index d4f7b0d..5157119 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 10 2012 8:04:32pm EDT. + This file was generated by xc_misc.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -64,35 +64,37 @@ func init() { // Skipping definition for base type 'Bool' -// Request GetVersion -// size: 8 +// GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { *xgb.Cookie } +// GetVersion sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } +// GetVersionUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} } -// Request reply for GetVersion -// size: 12 +// GetVersionReply represents the data returned from a GetVersion request. type GetVersionReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes ServerMajorVersion uint16 ServerMinorVersion uint16 } -// Waits and reads reply data from request GetVersion +// Reply blocks and returns the reply data for a GetVersion request. func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -104,7 +106,7 @@ func (cook GetVersionCookie) Reply() (*GetVersionReply, error) { return getVersionReply(buf), nil } -// Read reply into structure from buffer for GetVersion +// getVersionReply reads a byte slice into a GetVersionReply value. func getVersionReply(buf []byte) *GetVersionReply { v := new(GetVersionReply) b := 1 // skip reply determinant @@ -127,6 +129,7 @@ func getVersionReply(buf []byte) *GetVersionReply { } // Write request to wire for GetVersion +// getVersionRequest writes a GetVersion request to a byte slice. func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 @@ -150,35 +153,37 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// Request GetXIDRange -// size: 4 +// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. type GetXIDRangeCookie struct { *xgb.Cookie } +// GetXIDRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { cookie := c.NewCookie(true, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} } +// GetXIDRangeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { cookie := c.NewCookie(false, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} } -// Request reply for GetXIDRange -// size: 16 +// GetXIDRangeReply represents the data returned from a GetXIDRange request. type GetXIDRangeReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes StartId uint32 Count uint32 } -// Waits and reads reply data from request GetXIDRange +// Reply blocks and returns the reply data for a GetXIDRange request. func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -190,7 +195,7 @@ func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { return getXIDRangeReply(buf), nil } -// Read reply into structure from buffer for GetXIDRange +// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. func getXIDRangeReply(buf []byte) *GetXIDRangeReply { v := new(GetXIDRangeReply) b := 1 // skip reply determinant @@ -213,6 +218,7 @@ func getXIDRangeReply(buf []byte) *GetXIDRangeReply { } // Write request to wire for GetXIDRange +// getXIDRangeRequest writes a GetXIDRange request to a byte slice. func getXIDRangeRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -230,36 +236,38 @@ func getXIDRangeRequest(c *xgb.Conn) []byte { return buf } -// Request GetXIDList -// size: 8 +// GetXIDListCookie is a cookie used only for GetXIDList requests. type GetXIDListCookie struct { *xgb.Cookie } +// GetXIDList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { cookie := c.NewCookie(true, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} } +// GetXIDListUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { cookie := c.NewCookie(false, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} } -// Request reply for GetXIDList -// size: (32 + xgb.Pad((int(IdsLen) * 4))) +// GetXIDListReply represents the data returned from a GetXIDList request. type GetXIDListReply struct { - Sequence uint16 - Length uint32 + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply // padding: 1 bytes IdsLen uint32 // padding: 20 bytes Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) } -// Waits and reads reply data from request GetXIDList +// Reply blocks and returns the reply data for a GetXIDList request. func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -271,7 +279,7 @@ func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { return getXIDListReply(buf), nil } -// Read reply into structure from buffer for GetXIDList +// getXIDListReply reads a byte slice into a GetXIDListReply value. func getXIDListReply(buf []byte) *GetXIDListReply { v := new(GetXIDListReply) b := 1 // skip reply determinant @@ -300,6 +308,7 @@ func getXIDListReply(buf []byte) *GetXIDListReply { } // Write request to wire for GetXIDList +// getXIDListRequest writes a GetXIDList request to a byte slice. func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { size := 8 b := 0 -- cgit v1.2.3 From 3e6b3544934cb71e3a3b0edf9bc184241ac1ad7f Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 01:58:52 -0400 Subject: add a little more docs for errors --- nexgb/xcmisc/xcmisc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 5157119..7171969 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 10 2012 11:56:19pm EDT. + This file was generated by xc_misc.xml on May 11 2012 1:58:36am EDT. This file is automatically generated. Edit at your peril! */ -- cgit v1.2.3 From 29942bf078c92fea681e42ca5029592526f00718 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Fri, 11 May 2012 23:58:52 -0400 Subject: panic when an extension request is issued before an extension has been initialized. but give a nice error message for the happy people. --- nexgb/xcmisc/xcmisc.go | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 7171969..0a4b4ce 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 11 2012 1:58:36am EDT. + This file was generated by xc_misc.xml on May 11 2012 11:57:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,18 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Float' - -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - -// Skipping definition for base type 'Byte' - // Skipping definition for base type 'Int8' // Skipping definition for base type 'Card16' @@ -64,6 +52,18 @@ func init() { // Skipping definition for base type 'Bool' +// Skipping definition for base type 'Float' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + // GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { *xgb.Cookie @@ -72,6 +72,9 @@ type GetVersionCookie struct { // GetVersion sends a checked request. // If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} @@ -80,6 +83,9 @@ func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint1 // GetVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} @@ -161,6 +167,9 @@ type GetXIDRangeCookie struct { // GetXIDRange sends a checked request. // If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} @@ -169,6 +178,9 @@ func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { // GetXIDRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getXIDRangeRequest(c), cookie) return GetXIDRangeCookie{cookie} @@ -244,6 +256,9 @@ type GetXIDListCookie struct { // GetXIDList sends a checked request. // If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} @@ -252,6 +267,9 @@ func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { // GetXIDListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { + if _, ok := c.Extensions["XC-MISC"]; !ok { + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getXIDListRequest(c, Count), cookie) return GetXIDListCookie{cookie} -- cgit v1.2.3 From 4ea94ca0fef7786ce21722cbb02a9cf069bdedd9 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Sat, 26 May 2012 18:24:52 -0400 Subject: Bug fix in the generator that was outputting %(MISSING) crud. --- nexgb/xcmisc/xcmisc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 0a4b4ce..0ca4094 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 11 2012 11:57:19pm EDT. + This file was generated by xc_misc.xml on May 26 2012 6:23:13pm EDT. This file is automatically generated. Edit at your peril! */ -- cgit v1.2.3 From a9eae45cb3977bce5983e817d00d4584d176b044 Mon Sep 17 00:00:00 2001 From: "Andrew Gallant (Ocelot)" Date: Tue, 5 Jun 2012 00:14:34 -0400 Subject: Refresh build. Eh. --- nexgb/xcmisc/xcmisc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 0ca4094..dce0e9d 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on May 26 2012 6:23:13pm EDT. + This file was generated by xc_misc.xml on Jun 5 2012 12:11:59am EDT. This file is automatically generated. Edit at your peril! */ -- cgit v1.2.3 From 0685fb57e14104ee4ad9f70ec94f787a9a22c028 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:43:26 -0400 Subject: Update to latest xproto XML. --- nexgb/xcmisc/xcmisc.go | 164 ++++++++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 82 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index dce0e9d..e32ae42 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -2,7 +2,7 @@ package xcmisc /* - This file was generated by xc_misc.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by xc_misc.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,29 +40,29 @@ func init() { xgb.NewExtErrorFuncs["XC-MISC"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int8' +// Skipping definition for base type 'Bool' -// Skipping definition for base type 'Card16' +// Skipping definition for base type 'Byte' + +// Skipping definition for base type 'Card8' // Skipping definition for base type 'Char' -// Skipping definition for base type 'Card32' +// Skipping definition for base type 'Void' // Skipping definition for base type 'Double' -// Skipping definition for base type 'Bool' - // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - // Skipping definition for base type 'Int16' // Skipping definition for base type 'Int32' -// Skipping definition for base type 'Void' +// Skipping definition for base type 'Int8' -// Skipping definition for base type 'Byte' +// Skipping definition for base type 'Card16' + +// Skipping definition for base type 'Card32' // GetVersionCookie is a cookie used only for GetVersion requests. type GetVersionCookie struct { @@ -159,44 +159,45 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. -type GetXIDRangeCookie struct { +// GetXIDListCookie is a cookie used only for GetXIDList requests. +type GetXIDListCookie struct { *xgb.Cookie } -// GetXIDRange sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() -func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { +// GetXIDList sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() +func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} } -// GetXIDRangeUnchecked sends an unchecked request. +// GetXIDListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { +func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getXIDRangeRequest(c), cookie) - return GetXIDRangeCookie{cookie} + c.NewRequest(getXIDListRequest(c, Count), cookie) + return GetXIDListCookie{cookie} } -// GetXIDRangeReply represents the data returned from a GetXIDRange request. -type GetXIDRangeReply struct { +// GetXIDListReply represents the data returned from a GetXIDList request. +type GetXIDListReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - StartId uint32 - Count uint32 + IdsLen uint32 + // padding: 20 bytes + Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) } -// Reply blocks and returns the reply data for a GetXIDRange request. -func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { +// Reply blocks and returns the reply data for a GetXIDList request. +func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -204,12 +205,12 @@ func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { if buf == nil { return nil, nil } - return getXIDRangeReply(buf), nil + return getXIDListReply(buf), nil } -// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. -func getXIDRangeReply(buf []byte) *GetXIDRangeReply { - v := new(GetXIDRangeReply) +// getXIDListReply reads a byte slice into a GetXIDListReply value. +func getXIDListReply(buf []byte) *GetXIDListReply { + v := new(GetXIDListReply) b := 1 // skip reply determinant b += 1 // padding @@ -220,73 +221,81 @@ func getXIDRangeReply(buf []byte) *GetXIDRangeReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.StartId = xgb.Get32(buf[b:]) + v.IdsLen = xgb.Get32(buf[b:]) b += 4 - v.Count = xgb.Get32(buf[b:]) - b += 4 + b += 20 // padding + + v.Ids = make([]uint32, v.IdsLen) + for i := 0; i < int(v.IdsLen); i++ { + v.Ids[i] = xgb.Get32(buf[b:]) + b += 4 + } + b = xgb.Pad(b) return v } -// Write request to wire for GetXIDRange -// getXIDRangeRequest writes a GetXIDRange request to a byte slice. -func getXIDRangeRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for GetXIDList +// getXIDListRequest writes a GetXIDList request to a byte slice. +func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XC-MISC"] b += 1 - buf[b] = 1 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put32(buf[b:], Count) + b += 4 + return buf } -// GetXIDListCookie is a cookie used only for GetXIDList requests. -type GetXIDListCookie struct { +// GetXIDRangeCookie is a cookie used only for GetXIDRange requests. +type GetXIDRangeCookie struct { *xgb.Cookie } -// GetXIDList sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() -func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { +// GetXIDRange sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() +func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(true, true) - c.NewRequest(getXIDListRequest(c, Count), cookie) - return GetXIDListCookie{cookie} + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} } -// GetXIDListUnchecked sends an unchecked request. +// GetXIDRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { +func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { if _, ok := c.Extensions["XC-MISC"]; !ok { - panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") + panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } cookie := c.NewCookie(false, true) - c.NewRequest(getXIDListRequest(c, Count), cookie) - return GetXIDListCookie{cookie} + c.NewRequest(getXIDRangeRequest(c), cookie) + return GetXIDRangeCookie{cookie} } -// GetXIDListReply represents the data returned from a GetXIDList request. -type GetXIDListReply struct { +// GetXIDRangeReply represents the data returned from a GetXIDRange request. +type GetXIDRangeReply struct { Sequence uint16 // sequence number of the request for this reply Length uint32 // number of bytes in this reply // padding: 1 bytes - IdsLen uint32 - // padding: 20 bytes - Ids []uint32 // size: xgb.Pad((int(IdsLen) * 4)) + StartId uint32 + Count uint32 } -// Reply blocks and returns the reply data for a GetXIDList request. -func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { +// Reply blocks and returns the reply data for a GetXIDRange request. +func (cook GetXIDRangeCookie) Reply() (*GetXIDRangeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { return nil, err @@ -294,12 +303,12 @@ func (cook GetXIDListCookie) Reply() (*GetXIDListReply, error) { if buf == nil { return nil, nil } - return getXIDListReply(buf), nil + return getXIDRangeReply(buf), nil } -// getXIDListReply reads a byte slice into a GetXIDListReply value. -func getXIDListReply(buf []byte) *GetXIDListReply { - v := new(GetXIDListReply) +// getXIDRangeReply reads a byte slice into a GetXIDRangeReply value. +func getXIDRangeReply(buf []byte) *GetXIDRangeReply { + v := new(GetXIDRangeReply) b := 1 // skip reply determinant b += 1 // padding @@ -310,39 +319,30 @@ func getXIDListReply(buf []byte) *GetXIDListReply { v.Length = xgb.Get32(buf[b:]) // 4-byte units b += 4 - v.IdsLen = xgb.Get32(buf[b:]) + v.StartId = xgb.Get32(buf[b:]) b += 4 - b += 20 // padding - - v.Ids = make([]uint32, v.IdsLen) - for i := 0; i < int(v.IdsLen); i++ { - v.Ids[i] = xgb.Get32(buf[b:]) - b += 4 - } - b = xgb.Pad(b) + v.Count = xgb.Get32(buf[b:]) + b += 4 return v } -// Write request to wire for GetXIDList -// getXIDListRequest writes a GetXIDList request to a byte slice. -func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { - size := 8 +// Write request to wire for GetXIDRange +// getXIDRangeRequest writes a GetXIDRange request to a byte slice. +func getXIDRangeRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["XC-MISC"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 1 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put32(buf[b:], Count) - b += 4 - return buf } -- cgit v1.2.3 From b06a8ca97625c1134449c3af65d9ac3fb251a613 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 11 Aug 2013 20:45:36 -0400 Subject: Don't needlessly change source files every time. --- nexgb/xcmisc/xcmisc.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index e32ae42..5cff5f1 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -1,10 +1,7 @@ // Package xcmisc is the X client API for the XC-MISC extension. package xcmisc -/* - This file was generated by xc_misc.xml on Aug 11 2013 8:39:43pm EDT. - This file is automatically generated. Edit at your peril! -*/ +// This file is automatically generated from xc_misc.xml. Edit at your peril! import ( "github.com/BurntSushi/xgb" -- cgit v1.2.3 From a548d9d0f7b889627c43b18811357fad88760b2d Mon Sep 17 00:00:00 2001 From: aarzilli Date: Fri, 2 May 2014 15:09:23 +0200 Subject: Fix Issue #21: automatic calculation of alignment padding after lists --- nexgb/xcmisc/xcmisc.go | 1 - 1 file changed, 1 deletion(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 5cff5f1..2240ee1 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -228,7 +228,6 @@ func getXIDListReply(buf []byte) *GetXIDListReply { v.Ids[i] = xgb.Get32(buf[b:]) b += 4 } - b = xgb.Pad(b) return v } -- cgit v1.2.3 From becaf43dcb3e9832c3eb951ff9908ed697868152 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Tue, 1 Mar 2016 15:41:38 +0100 Subject: Read/Write mutex for Extensions map --- nexgb/xcmisc/xcmisc.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'nexgb/xcmisc') diff --git a/nexgb/xcmisc/xcmisc.go b/nexgb/xcmisc/xcmisc.go index 2240ee1..1778057 100644 --- a/nexgb/xcmisc/xcmisc.go +++ b/nexgb/xcmisc/xcmisc.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named XC-MISC could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["XC-MISC"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["XC-MISC"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["XC-MISC"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -69,6 +68,8 @@ type GetVersionCookie struct { // GetVersion sends a checked request. // If an error occurs, it will be returned with the reply by calling GetVersionCookie.Reply() func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -80,6 +81,8 @@ func GetVersion(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint1 // GetVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) GetVersionCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -138,7 +141,9 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XC-MISC"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode @@ -164,6 +169,8 @@ type GetXIDListCookie struct { // GetXIDList sends a checked request. // If an error occurs, it will be returned with the reply by calling GetXIDListCookie.Reply() func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -175,6 +182,8 @@ func GetXIDList(c *xgb.Conn, Count uint32) GetXIDListCookie { // GetXIDListUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDListUnchecked(c *xgb.Conn, Count uint32) GetXIDListCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetXIDList' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -239,7 +248,9 @@ func getXIDListRequest(c *xgb.Conn, Count uint32) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XC-MISC"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -262,6 +273,8 @@ type GetXIDRangeCookie struct { // GetXIDRange sends a checked request. // If an error occurs, it will be returned with the reply by calling GetXIDRangeCookie.Reply() func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -273,6 +286,8 @@ func GetXIDRange(c *xgb.Conn) GetXIDRangeCookie { // GetXIDRangeUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetXIDRangeUnchecked(c *xgb.Conn) GetXIDRangeCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["XC-MISC"]; !ok { panic("Cannot issue request 'GetXIDRange' using the uninitialized extension 'XC-MISC'. xcmisc.Init(connObj) must be called first.") } @@ -331,7 +346,9 @@ func getXIDRangeRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["XC-MISC"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode -- cgit v1.2.3