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/damage/damage.go | 56 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'nexgb/damage/damage.go') diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go index a3ba928..f9aee61 100644 --- a/nexgb/damage/damage.go +++ b/nexgb/damage/damage.go @@ -2,7 +2,7 @@ package damage /* - This file was generated by damage.xml on May 11 2012 1:58:35am EDT. + This file was generated by damage.xml on May 11 2012 11:57:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -41,18 +41,6 @@ func init() { xgb.NewExtErrorFuncs["DAMAGE"] = make(map[int]xgb.NewErrorFun) } -// 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' - // Skipping definition for base type 'Card8' // Skipping definition for base type 'Int16' @@ -65,6 +53,18 @@ func init() { // 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' + const ( ReportLevelRawRectangles = 0 ReportLevelDeltaRectangles = 1 @@ -238,6 +238,9 @@ type QueryVersionCookie struct { // QueryVersion sends a checked request. // If an error occurs, it will be returned with the reply by calling QueryVersionCookie.Reply() func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} @@ -246,6 +249,9 @@ func QueryVersion(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uin // QueryVersionUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryVersionUnchecked(c *xgb.Conn, ClientMajorVersion uint32, ClientMinorVersion uint32) QueryVersionCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'QueryVersion' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(queryVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return QueryVersionCookie{cookie} @@ -330,6 +336,9 @@ type CreateCookie struct { // Create sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Create(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Create' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) return CreateCookie{cookie} @@ -338,6 +347,9 @@ func Create(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) Cr // CreateChecked sends a checked request. // If an error occurs, it can be retrieved using CreateCookie.Check() func CreateChecked(c *xgb.Conn, Damage Damage, Drawable xproto.Drawable, Level byte) CreateCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Create' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(createRequest(c, Damage, Drawable, Level), cookie) return CreateCookie{cookie} @@ -387,6 +399,9 @@ type DestroyCookie struct { // Destroy sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Destroy(c *xgb.Conn, Damage Damage) DestroyCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Destroy' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(destroyRequest(c, Damage), cookie) return DestroyCookie{cookie} @@ -395,6 +410,9 @@ func Destroy(c *xgb.Conn, Damage Damage) DestroyCookie { // DestroyChecked sends a checked request. // If an error occurs, it can be retrieved using DestroyCookie.Check() func DestroyChecked(c *xgb.Conn, Damage Damage) DestroyCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Destroy' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(destroyRequest(c, Damage), cookie) return DestroyCookie{cookie} @@ -436,6 +454,9 @@ type SubtractCookie struct { // Subtract sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) return SubtractCookie{cookie} @@ -444,6 +465,9 @@ func Subtract(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Reg // SubtractChecked sends a checked request. // If an error occurs, it can be retrieved using SubtractCookie.Check() func SubtractChecked(c *xgb.Conn, Damage Damage, Repair xfixes.Region, Parts xfixes.Region) SubtractCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Subtract' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(subtractRequest(c, Damage, Repair, Parts), cookie) return SubtractCookie{cookie} @@ -491,6 +515,9 @@ type AddCookie struct { // Add sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(addRequest(c, Drawable, Region), cookie) return AddCookie{cookie} @@ -499,6 +526,9 @@ func Add(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie // AddChecked sends a checked request. // If an error occurs, it can be retrieved using AddCookie.Check() func AddChecked(c *xgb.Conn, Drawable xproto.Drawable, Region xfixes.Region) AddCookie { + if _, ok := c.Extensions["DAMAGE"]; !ok { + panic("Cannot issue request 'Add' using the uninitialized extension 'DAMAGE'. damage.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(addRequest(c, Drawable, Region), cookie) return AddCookie{cookie} -- cgit v1.2.3