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/xtest/xtest.go | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'nexgb/xtest/xtest.go') diff --git a/nexgb/xtest/xtest.go b/nexgb/xtest/xtest.go index 8f964e4..3fab056 100644 --- a/nexgb/xtest/xtest.go +++ b/nexgb/xtest/xtest.go @@ -2,7 +2,7 @@ package xtest /* - This file was generated by xtest.xml on May 11 2012 1:58:37am EDT. + This file was generated by xtest.xml on May 11 2012 11:57:20pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["XTEST"] = 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' @@ -64,6 +60,10 @@ func init() { // Skipping definition for base type 'Float' +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + const ( CursorNone = 0 CursorCurrent = 1 @@ -77,6 +77,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, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) return GetVersionCookie{cookie} @@ -85,6 +88,9 @@ func GetVersion(c *xgb.Conn, MajorVersion byte, MinorVersion uint16) GetVersionC // 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, MajorVersion byte, MinorVersion uint16) GetVersionCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, MajorVersion, MinorVersion), cookie) return GetVersionCookie{cookie} @@ -165,6 +171,9 @@ type CompareCursorCookie struct { // CompareCursor sends a checked request. // If an error occurs, it will be returned with the reply by calling CompareCursorCookie.Reply() func CompareCursor(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'CompareCursor' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) return CompareCursorCookie{cookie} @@ -173,6 +182,9 @@ func CompareCursor(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) Comp // CompareCursorUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CompareCursorUnchecked(c *xgb.Conn, Window xproto.Window, Cursor xproto.Cursor) CompareCursorCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'CompareCursor' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(compareCursorRequest(c, Window, Cursor), cookie) return CompareCursorCookie{cookie} @@ -251,6 +263,9 @@ type FakeInputCookie struct { // FakeInput sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func FakeInput(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'FakeInput' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) return FakeInputCookie{cookie} @@ -259,6 +274,9 @@ func FakeInput(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Win // FakeInputChecked sends a checked request. // If an error occurs, it can be retrieved using FakeInputCookie.Check() func FakeInputChecked(c *xgb.Conn, Type byte, Detail byte, Time uint32, Root xproto.Window, RootX int16, RootY int16, Deviceid byte) FakeInputCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'FakeInput' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(fakeInputRequest(c, Type, Detail, Time, Root, RootX, RootY, Deviceid), cookie) return FakeInputCookie{cookie} @@ -324,6 +342,9 @@ type GrabControlCookie struct { // GrabControl sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GrabControl(c *xgb.Conn, Impervious bool) GrabControlCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GrabControl' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(grabControlRequest(c, Impervious), cookie) return GrabControlCookie{cookie} @@ -332,6 +353,9 @@ func GrabControl(c *xgb.Conn, Impervious bool) GrabControlCookie { // GrabControlChecked sends a checked request. // If an error occurs, it can be retrieved using GrabControlCookie.Check() func GrabControlChecked(c *xgb.Conn, Impervious bool) GrabControlCookie { + if _, ok := c.Extensions["XTEST"]; !ok { + panic("Cannot issue request 'GrabControl' using the uninitialized extension 'XTEST'. xtest.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(grabControlRequest(c, Impervious), cookie) return GrabControlCookie{cookie} -- cgit v1.2.3-70-g09d2