panic when an extension request is issued before an extension has been initialized. but give a nice error message for the happy people.

This commit is contained in:
Andrew Gallant (Ocelot)
2012-05-11 23:58:52 -04:00
parent fb3128ed2a
commit 29942bf078
29 changed files with 2876 additions and 202 deletions

View File

@@ -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}