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/bigreq/bigreq.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'nexgb/bigreq/bigreq.go') diff --git a/nexgb/bigreq/bigreq.go b/nexgb/bigreq/bigreq.go index 32dacba..43a15a4 100644 --- a/nexgb/bigreq/bigreq.go +++ b/nexgb/bigreq/bigreq.go @@ -2,7 +2,7 @@ package bigreq /* - This file was generated by bigreq.xml on May 11 2012 1:58:35am EDT. + This file was generated by bigreq.xml on May 11 2012 11:57:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,10 @@ func init() { xgb.NewExtErrorFuncs["BIG-REQUESTS"] = make(map[int]xgb.NewErrorFun) } +// Skipping definition for base type 'Bool' + +// Skipping definition for base type 'Float' + // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' @@ -60,10 +64,6 @@ func init() { // Skipping definition for base type 'Double' -// Skipping definition for base type 'Bool' - -// Skipping definition for base type 'Float' - // EnableCookie is a cookie used only for Enable requests. type EnableCookie struct { *xgb.Cookie @@ -72,6 +72,9 @@ type EnableCookie struct { // Enable sends a checked request. // If an error occurs, it will be returned with the reply by calling EnableCookie.Reply() func Enable(c *xgb.Conn) EnableCookie { + if _, ok := c.Extensions["BIG-REQUESTS"]; !ok { + panic("Cannot issue request 'Enable' using the uninitialized extension 'BIG-REQUESTS'. bigreq.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} @@ -80,6 +83,9 @@ func Enable(c *xgb.Conn) EnableCookie { // EnableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func EnableUnchecked(c *xgb.Conn) EnableCookie { + if _, ok := c.Extensions["BIG-REQUESTS"]; !ok { + panic("Cannot issue request 'Enable' using the uninitialized extension 'BIG-REQUESTS'. bigreq.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} -- cgit v1.2.3