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/dpms/dpms.go | 590 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 590 insertions(+) create mode 100644 nexgb/dpms/dpms.go (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go new file mode 100644 index 0000000..01314ac --- /dev/null +++ b/nexgb/dpms/dpms.go @@ -0,0 +1,590 @@ +package dpms + +/* + This file was generated by dpms.xml on May 10 2012 4:20:27pm 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 DPMS extension. +func Init(c *xgb.Conn) error { + reply, err := xproto.QueryExtension(c, 4, "DPMS").Reply() + switch { + case err != nil: + return err + case !reply.Present: + return xgb.Errorf("No extension named DPMS could be found on on the server.") + } + + xgb.ExtLock.Lock() + c.Extensions["DPMS"] = reply.MajorOpcode + for evNum, fun := range xgb.NewExtEventFuncs["DPMS"] { + xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun + } + for errNum, fun := range xgb.NewExtErrorFuncs["DPMS"] { + xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun + } + xgb.ExtLock.Unlock() + + return nil +} + +func init() { + xgb.NewExtEventFuncs["DPMS"] = make(map[int]xgb.NewEventFun) + xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) +} + +// 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' + +// Skipping definition for base type 'Card8' + +// Skipping definition for base type 'Int16' + +const ( + DPMSModeOn = 0 + DPMSModeStandby = 1 + DPMSModeSuspend = 2 + DPMSModeOff = 3 +) + +// 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["DPMS"] + 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 Capable +// size: 4 +type CapableCookie struct { + *xgb.Cookie +} + +func Capable(c *xgb.Conn) CapableCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(capableRequest(c), cookie) + return CapableCookie{cookie} +} + +func CapableUnchecked(c *xgb.Conn) CapableCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(capableRequest(c), cookie) + return CapableCookie{cookie} +} + +// Request reply for Capable +// size: 32 +type CapableReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + Capable bool + // padding: 23 bytes +} + +// Waits and reads reply data from request Capable +func (cook CapableCookie) Reply() (*CapableReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return capableReply(buf), nil +} + +// Read reply into structure from buffer for Capable +func capableReply(buf []byte) *CapableReply { + v := new(CapableReply) + 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 + + if buf[b] == 1 { + v.Capable = true + } else { + v.Capable = false + } + b += 1 + + b += 23 // padding + + return v +} + +// Write request to wire for Capable +func capableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + 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 GetTimeouts +// size: 4 +type GetTimeoutsCookie struct { + *xgb.Cookie +} + +func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} +} + +func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} +} + +// Request reply for GetTimeouts +// size: 32 +type GetTimeoutsReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + StandbyTimeout uint16 + SuspendTimeout uint16 + OffTimeout uint16 + // padding: 18 bytes +} + +// Waits and reads reply data from request GetTimeouts +func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTimeoutsReply(buf), nil +} + +// Read reply into structure from buffer for GetTimeouts +func getTimeoutsReply(buf []byte) *GetTimeoutsReply { + v := new(GetTimeoutsReply) + 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.StandbyTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.SuspendTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.OffTimeout = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetTimeouts +func getTimeoutsRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + 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 + + return buf +} + +// Request SetTimeouts +// size: 12 +type SetTimeoutsCookie struct { + *xgb.Cookie +} + +// Write request to wire for SetTimeouts +func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +func (cook SetTimeoutsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetTimeouts +func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], StandbyTimeout) + b += 2 + + xgb.Put16(buf[b:], SuspendTimeout) + b += 2 + + xgb.Put16(buf[b:], OffTimeout) + b += 2 + + return buf +} + +// Request Enable +// size: 4 +type EnableCookie struct { + *xgb.Cookie +} + +// Write request to wire for Enable +func Enable(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +func EnableChecked(c *xgb.Conn) EnableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} +} + +func (cook EnableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Enable +func enableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 4 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request Disable +// size: 4 +type DisableCookie struct { + *xgb.Cookie +} + +// Write request to wire for Disable +func Disable(c *xgb.Conn) DisableCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} +} + +func DisableChecked(c *xgb.Conn) DisableCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} +} + +func (cook DisableCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for Disable +func disableRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 5 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + return buf +} + +// Request ForceLevel +// size: 8 +type ForceLevelCookie struct { + *xgb.Cookie +} + +// Write request to wire for ForceLevel +func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + cookie := c.NewCookie(false, false) + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} +} + +func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + cookie := c.NewCookie(true, false) + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} +} + +func (cook ForceLevelCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for ForceLevel +func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { + size := 8 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 6 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], PowerLevel) + b += 2 + + return buf +} + +// Request Info +// size: 4 +type InfoCookie struct { + *xgb.Cookie +} + +func Info(c *xgb.Conn) InfoCookie { + cookie := c.NewCookie(true, true) + c.NewRequest(infoRequest(c), cookie) + return InfoCookie{cookie} +} + +func InfoUnchecked(c *xgb.Conn) InfoCookie { + cookie := c.NewCookie(false, true) + c.NewRequest(infoRequest(c), cookie) + return InfoCookie{cookie} +} + +// Request reply for Info +// size: 32 +type InfoReply struct { + Sequence uint16 + Length uint32 + // padding: 1 bytes + PowerLevel uint16 + State bool + // padding: 21 bytes +} + +// Waits and reads reply data from request Info +func (cook InfoCookie) Reply() (*InfoReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return infoReply(buf), nil +} + +// Read reply into structure from buffer for Info +func infoReply(buf []byte) *InfoReply { + v := new(InfoReply) + 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.PowerLevel = xgb.Get16(buf[b:]) + b += 2 + + if buf[b] == 1 { + v.State = true + } else { + v.State = false + } + b += 1 + + b += 21 // padding + + return v +} + +// Write request to wire for Info +func infoRequest(c *xgb.Conn) []byte { + size := 4 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 7 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + 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/dpms/dpms.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index 01314ac..de748e4 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -1,7 +1,8 @@ +// Package dpms is the X client API for the DPMS extension. package dpms /* - This file was generated by dpms.xml on May 10 2012 4:20:27pm EDT. + This file was generated by dpms.xml on May 10 2012 8:04:31pm EDT. This file is automatically generated. Edit at your peril! */ @@ -39,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } -// Skipping definition for base type 'Int32' - -// Skipping definition for base type 'Void' - // Skipping definition for base type 'Byte' // Skipping definition for base type 'Int8' @@ -63,6 +60,10 @@ func init() { // Skipping definition for base type 'Int16' +// Skipping definition for base type 'Int32' + +// Skipping definition for base type 'Void' + const ( DPMSModeOn = 0 DPMSModeStandby = 1 -- 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/dpms/dpms.go | 138 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 53 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index de748e4..e3e095a 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 10 2012 8:04:31pm EDT. + This file was generated by dpms.xml on May 10 2012 11:56:18pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,14 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = 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' @@ -56,14 +64,6 @@ func init() { // 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' - const ( DPMSModeOn = 0 DPMSModeStandby = 1 @@ -71,35 +71,37 @@ const ( DPMSModeOff = 3 ) -// 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 { @@ -111,7 +113,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 @@ -134,6 +136,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 @@ -157,35 +160,37 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio return buf } -// Request Capable -// size: 4 +// CapableCookie is a cookie used only for Capable requests. type CapableCookie struct { *xgb.Cookie } +// Capable sends a checked request. +// If an error occurs, it will be returned with the reply by calling CapableCookie.Reply() func Capable(c *xgb.Conn) CapableCookie { cookie := c.NewCookie(true, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} } +// CapableUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CapableUnchecked(c *xgb.Conn) CapableCookie { cookie := c.NewCookie(false, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} } -// Request reply for Capable -// size: 32 +// CapableReply represents the data returned from a Capable request. type CapableReply 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 Capable bool // padding: 23 bytes } -// Waits and reads reply data from request Capable +// Reply blocks and returns the reply data for a Capable request. func (cook CapableCookie) Reply() (*CapableReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -197,7 +202,7 @@ func (cook CapableCookie) Reply() (*CapableReply, error) { return capableReply(buf), nil } -// Read reply into structure from buffer for Capable +// capableReply reads a byte slice into a CapableReply value. func capableReply(buf []byte) *CapableReply { v := new(CapableReply) b := 1 // skip reply determinant @@ -223,6 +228,7 @@ func capableReply(buf []byte) *CapableReply { } // Write request to wire for Capable +// capableRequest writes a Capable request to a byte slice. func capableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -240,29 +246,31 @@ func capableRequest(c *xgb.Conn) []byte { return buf } -// Request GetTimeouts -// size: 4 +// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. type GetTimeoutsCookie struct { *xgb.Cookie } +// GetTimeouts sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { cookie := c.NewCookie(true, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} } +// GetTimeoutsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { cookie := c.NewCookie(false, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} } -// Request reply for GetTimeouts -// size: 32 +// GetTimeoutsReply represents the data returned from a GetTimeouts request. type GetTimeoutsReply 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 StandbyTimeout uint16 SuspendTimeout uint16 @@ -270,7 +278,7 @@ type GetTimeoutsReply struct { // padding: 18 bytes } -// Waits and reads reply data from request GetTimeouts +// Reply blocks and returns the reply data for a GetTimeouts request. func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -282,7 +290,7 @@ func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { return getTimeoutsReply(buf), nil } -// Read reply into structure from buffer for GetTimeouts +// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. func getTimeoutsReply(buf []byte) *GetTimeoutsReply { v := new(GetTimeoutsReply) b := 1 // skip reply determinant @@ -310,6 +318,7 @@ func getTimeoutsReply(buf []byte) *GetTimeoutsReply { } // Write request to wire for GetTimeouts +// getTimeoutsRequest writes a GetTimeouts request to a byte slice. func getTimeoutsRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -327,30 +336,35 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { return buf } -// Request SetTimeouts -// size: 12 +// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. type SetTimeoutsCookie struct { *xgb.Cookie } -// Write request to wire for SetTimeouts +// SetTimeouts sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { cookie := c.NewCookie(false, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} } +// SetTimeoutsChecked sends a checked request. +// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { cookie := c.NewCookie(true, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook SetTimeoutsCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetTimeouts +// setTimeoutsRequest writes a SetTimeouts request to a byte slice. func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { size := 12 b := 0 @@ -377,30 +391,35 @@ func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint1 return buf } -// Request Enable -// size: 4 +// EnableCookie is a cookie used only for Enable requests. type EnableCookie struct { *xgb.Cookie } -// Write request to wire for Enable +// Enable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Enable(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(false, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } +// EnableChecked sends a checked request. +// If an error occurs, it can be retrieved using EnableCookie.Check() func EnableChecked(c *xgb.Conn) EnableCookie { cookie := c.NewCookie(true, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook EnableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Enable +// enableRequest writes a Enable request to a byte slice. func enableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -418,30 +437,35 @@ func enableRequest(c *xgb.Conn) []byte { return buf } -// Request Disable -// size: 4 +// DisableCookie is a cookie used only for Disable requests. type DisableCookie struct { *xgb.Cookie } -// Write request to wire for Disable +// Disable sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Disable(c *xgb.Conn) DisableCookie { cookie := c.NewCookie(false, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} } +// DisableChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableCookie.Check() func DisableChecked(c *xgb.Conn) DisableCookie { cookie := c.NewCookie(true, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook DisableCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Disable +// disableRequest writes a Disable request to a byte slice. func disableRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -459,30 +483,35 @@ func disableRequest(c *xgb.Conn) []byte { return buf } -// Request ForceLevel -// size: 8 +// ForceLevelCookie is a cookie used only for ForceLevel requests. type ForceLevelCookie struct { *xgb.Cookie } -// Write request to wire for ForceLevel +// ForceLevel sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { cookie := c.NewCookie(false, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} } +// ForceLevelChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceLevelCookie.Check() func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { cookie := c.NewCookie(true, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} } +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. func (cook ForceLevelCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ForceLevel +// forceLevelRequest writes a ForceLevel request to a byte slice. func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { size := 8 b := 0 @@ -503,36 +532,38 @@ func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { return buf } -// Request Info -// size: 4 +// InfoCookie is a cookie used only for Info requests. type InfoCookie struct { *xgb.Cookie } +// Info sends a checked request. +// If an error occurs, it will be returned with the reply by calling InfoCookie.Reply() func Info(c *xgb.Conn) InfoCookie { cookie := c.NewCookie(true, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{cookie} } +// InfoUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InfoUnchecked(c *xgb.Conn) InfoCookie { cookie := c.NewCookie(false, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{cookie} } -// Request reply for Info -// size: 32 +// InfoReply represents the data returned from a Info request. type InfoReply 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 PowerLevel uint16 State bool // padding: 21 bytes } -// Waits and reads reply data from request Info +// Reply blocks and returns the reply data for a Info request. func (cook InfoCookie) Reply() (*InfoReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -544,7 +575,7 @@ func (cook InfoCookie) Reply() (*InfoReply, error) { return infoReply(buf), nil } -// Read reply into structure from buffer for Info +// infoReply reads a byte slice into a InfoReply value. func infoReply(buf []byte) *InfoReply { v := new(InfoReply) b := 1 // skip reply determinant @@ -573,6 +604,7 @@ func infoReply(buf []byte) *InfoReply { } // Write request to wire for Info +// infoRequest writes a Info request to a byte slice. func infoRequest(c *xgb.Conn) []byte { size := 4 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/dpms/dpms.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index e3e095a..8ffb2ee 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 10 2012 11:56:18pm EDT. + This file was generated by dpms.xml on May 11 2012 1:58:35am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,16 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = 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' @@ -64,6 +54,16 @@ func init() { // 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' + const ( DPMSModeOn = 0 DPMSModeStandby = 1 -- 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/dpms/dpms.go | 66 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 9 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index 8ffb2ee..d1142ce 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 11 2012 1:58:35am EDT. + This file was generated by dpms.xml on May 11 2012 11:57:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,14 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } -// 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' @@ -64,6 +56,14 @@ func init() { // 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' + const ( DPMSModeOn = 0 DPMSModeStandby = 1 @@ -79,6 +79,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["DPMS"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} @@ -87,6 +90,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["DPMS"]; !ok { + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) return GetVersionCookie{cookie} @@ -168,6 +174,9 @@ type CapableCookie struct { // Capable sends a checked request. // If an error occurs, it will be returned with the reply by calling CapableCookie.Reply() func Capable(c *xgb.Conn) CapableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Capable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} @@ -176,6 +185,9 @@ func Capable(c *xgb.Conn) CapableCookie { // CapableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CapableUnchecked(c *xgb.Conn) CapableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Capable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(capableRequest(c), cookie) return CapableCookie{cookie} @@ -254,6 +266,9 @@ type GetTimeoutsCookie struct { // GetTimeouts sends a checked request. // If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} @@ -262,6 +277,9 @@ func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { // GetTimeoutsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(getTimeoutsRequest(c), cookie) return GetTimeoutsCookie{cookie} @@ -344,6 +362,9 @@ type SetTimeoutsCookie struct { // SetTimeouts sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} @@ -352,6 +373,9 @@ func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffT // SetTimeoutsChecked sends a checked request. // If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) return SetTimeoutsCookie{cookie} @@ -399,6 +423,9 @@ type EnableCookie struct { // Enable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Enable(c *xgb.Conn) EnableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} @@ -407,6 +434,9 @@ func Enable(c *xgb.Conn) EnableCookie { // EnableChecked sends a checked request. // If an error occurs, it can be retrieved using EnableCookie.Check() func EnableChecked(c *xgb.Conn) EnableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(enableRequest(c), cookie) return EnableCookie{cookie} @@ -445,6 +475,9 @@ type DisableCookie struct { // Disable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Disable(c *xgb.Conn) DisableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} @@ -453,6 +486,9 @@ func Disable(c *xgb.Conn) DisableCookie { // DisableChecked sends a checked request. // If an error occurs, it can be retrieved using DisableCookie.Check() func DisableChecked(c *xgb.Conn) DisableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(disableRequest(c), cookie) return DisableCookie{cookie} @@ -491,6 +527,9 @@ type ForceLevelCookie struct { // ForceLevel sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} @@ -499,6 +538,9 @@ func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { // ForceLevelChecked sends a checked request. // If an error occurs, it can be retrieved using ForceLevelCookie.Check() func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, false) c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) return ForceLevelCookie{cookie} @@ -540,6 +582,9 @@ type InfoCookie struct { // Info sends a checked request. // If an error occurs, it will be returned with the reply by calling InfoCookie.Reply() func Info(c *xgb.Conn) InfoCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Info' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(true, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{cookie} @@ -548,6 +593,9 @@ func Info(c *xgb.Conn) InfoCookie { // InfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InfoUnchecked(c *xgb.Conn) InfoCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Info' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } cookie := c.NewCookie(false, true) c.NewRequest(infoRequest(c), cookie) return InfoCookie{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/dpms/dpms.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index d1142ce..0ef913c 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 11 2012 11:57:19pm EDT. + This file was generated by dpms.xml on May 26 2012 6:23:12pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,18 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } -// 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 'Byte' @@ -64,6 +52,18 @@ func init() { // 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' + +// Skipping definition for base type 'Int32' + const ( DPMSModeOn = 0 DPMSModeStandby = 1 -- 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/dpms/dpms.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index 0ef913c..f7d6ffe 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on May 26 2012 6:23:12pm EDT. + This file was generated by dpms.xml on Jun 5 2012 12:11:59am EDT. This file is automatically generated. Edit at your peril! */ @@ -40,10 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } -// 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 +60,10 @@ func init() { // Skipping definition for base type 'Int32' +// Skipping definition for base type 'Void' + +// Skipping definition for base type 'Byte' + const ( DPMSModeOn = 0 DPMSModeStandby = 1 -- 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/dpms/dpms.go | 548 ++++++++++++++++++++++++++--------------------------- 1 file changed, 274 insertions(+), 274 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index f7d6ffe..96d82f0 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -2,7 +2,7 @@ package dpms /* - This file was generated by dpms.xml on Jun 5 2012 12:11:59am EDT. + This file was generated by dpms.xml on Aug 11 2013 8:39:43pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,30 +40,6 @@ func init() { xgb.NewExtErrorFuncs["DPMS"] = make(map[int]xgb.NewErrorFun) } -// 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' - -// 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' - const ( DPMSModeOn = 0 DPMSModeStandby = 1 @@ -71,100 +47,29 @@ const ( DPMSModeOff = 3 ) -// 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 { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - 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 { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - cookie := c.NewCookie(false, true) - c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) - return GetVersionCookie{cookie} -} - -// GetVersionReply represents the data returned from a GetVersion request. -type GetVersionReply struct { - 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 -} - -// 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 { - return nil, err - } - if buf == nil { - return nil, nil - } - return getVersionReply(buf), nil -} - -// getVersionReply reads a byte slice into a GetVersionReply value. -func getVersionReply(buf []byte) *GetVersionReply { - v := new(GetVersionReply) - b := 1 // skip reply determinant - - b += 1 // padding - - v.Sequence = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Bool' - v.Length = xgb.Get32(buf[b:]) // 4-byte units - b += 4 +// Skipping definition for base type 'Byte' - v.ServerMajorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Card8' - v.ServerMinorVersion = xgb.Get16(buf[b:]) - b += 2 +// Skipping definition for base type 'Char' - return v -} +// Skipping definition for base type 'Void' -// 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 - buf := make([]byte, size) +// Skipping definition for base type 'Double' - buf[b] = c.Extensions["DPMS"] - b += 1 +// Skipping definition for base type 'Float' - buf[b] = 0 // request opcode - b += 1 +// Skipping definition for base type 'Int16' - xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units - b += 2 +// Skipping definition for base type 'Int32' - xgb.Put16(buf[b:], ClientMajorVersion) - b += 2 +// Skipping definition for base type 'Int8' - xgb.Put16(buf[b:], ClientMinorVersion) - b += 2 +// Skipping definition for base type 'Card16' - return buf -} +// Skipping definition for base type 'Card32' // CapableCookie is a cookie used only for Capable requests. type CapableCookie struct { @@ -258,86 +163,42 @@ func capableRequest(c *xgb.Conn) []byte { return buf } -// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. -type GetTimeoutsCookie struct { +// DisableCookie is a cookie used only for Disable requests. +type DisableCookie struct { *xgb.Cookie } -// GetTimeouts sends a checked request. -// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() -func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { - if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") - } - cookie := c.NewCookie(true, true) - c.NewRequest(getTimeoutsRequest(c), cookie) - return GetTimeoutsCookie{cookie} -} - -// GetTimeoutsUnchecked sends an unchecked request. +// Disable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { +func Disable(c *xgb.Conn) DisableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, true) - c.NewRequest(getTimeoutsRequest(c), cookie) - return GetTimeoutsCookie{cookie} -} - -// GetTimeoutsReply represents the data returned from a GetTimeouts request. -type GetTimeoutsReply struct { - Sequence uint16 // sequence number of the request for this reply - Length uint32 // number of bytes in this reply - // padding: 1 bytes - StandbyTimeout uint16 - SuspendTimeout uint16 - OffTimeout uint16 - // padding: 18 bytes + cookie := c.NewCookie(false, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} } -// Reply blocks and returns the reply data for a GetTimeouts request. -func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { - buf, err := cook.Cookie.Reply() - if err != nil { - return nil, err - } - if buf == nil { - return nil, nil +// DisableChecked sends a checked request. +// If an error occurs, it can be retrieved using DisableCookie.Check() +func DisableChecked(c *xgb.Conn) DisableCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - return getTimeoutsReply(buf), nil + cookie := c.NewCookie(true, false) + c.NewRequest(disableRequest(c), cookie) + return DisableCookie{cookie} } -// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. -func getTimeoutsReply(buf []byte) *GetTimeoutsReply { - v := new(GetTimeoutsReply) - 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.StandbyTimeout = xgb.Get16(buf[b:]) - b += 2 - - v.SuspendTimeout = xgb.Get16(buf[b:]) - b += 2 - - v.OffTimeout = xgb.Get16(buf[b:]) - b += 2 - - b += 18 // padding - - return v +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook DisableCookie) Check() error { + return cook.Cookie.Check() } -// Write request to wire for GetTimeouts -// getTimeoutsRequest writes a GetTimeouts request to a byte slice. -func getTimeoutsRequest(c *xgb.Conn) []byte { +// Write request to wire for Disable +// disableRequest writes a Disable request to a byte slice. +func disableRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -345,7 +206,7 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 2 // request opcode + buf[b] = 5 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -354,155 +215,193 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { return buf } -// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. -type SetTimeoutsCookie struct { +// EnableCookie is a cookie used only for Enable requests. +type EnableCookie struct { *xgb.Cookie } -// SetTimeouts sends an unchecked request. +// Enable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { +func Enable(c *xgb.Conn) EnableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return SetTimeoutsCookie{cookie} + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} } -// SetTimeoutsChecked sends a checked request. -// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() -func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { +// EnableChecked sends a checked request. +// If an error occurs, it can be retrieved using EnableCookie.Check() +func EnableChecked(c *xgb.Conn) EnableCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) - return SetTimeoutsCookie{cookie} + c.NewRequest(enableRequest(c), cookie) + return EnableCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook SetTimeoutsCookie) Check() error { +func (cook EnableCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for SetTimeouts -// setTimeoutsRequest writes a SetTimeouts request to a byte slice. -func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { - size := 12 +// Write request to wire for Enable +// enableRequest writes a Enable request to a byte slice. +func enableRequest(c *xgb.Conn) []byte { + size := 4 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 3 // request opcode + buf[b] = 4 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 - xgb.Put16(buf[b:], StandbyTimeout) - b += 2 - - xgb.Put16(buf[b:], SuspendTimeout) - b += 2 + return buf +} - xgb.Put16(buf[b:], OffTimeout) - b += 2 - - return buf -} - -// EnableCookie is a cookie used only for Enable requests. -type EnableCookie struct { +// ForceLevelCookie is a cookie used only for ForceLevel requests. +type ForceLevelCookie struct { *xgb.Cookie } -// Enable sends an unchecked request. +// ForceLevel sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Enable(c *xgb.Conn) EnableCookie { +func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(false, false) - c.NewRequest(enableRequest(c), cookie) - return EnableCookie{cookie} + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} } -// EnableChecked sends a checked request. -// If an error occurs, it can be retrieved using EnableCookie.Check() -func EnableChecked(c *xgb.Conn) EnableCookie { +// ForceLevelChecked sends a checked request. +// If an error occurs, it can be retrieved using ForceLevelCookie.Check() +func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } cookie := c.NewCookie(true, false) - c.NewRequest(enableRequest(c), cookie) - return EnableCookie{cookie} + c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) + return ForceLevelCookie{cookie} } // Check returns an error if one occurred for checked requests that are not expecting a reply. // This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook EnableCookie) Check() error { +func (cook ForceLevelCookie) Check() error { return cook.Cookie.Check() } -// Write request to wire for Enable -// enableRequest writes a Enable request to a byte slice. -func enableRequest(c *xgb.Conn) []byte { - size := 4 +// Write request to wire for ForceLevel +// forceLevelRequest writes a ForceLevel request to a byte slice. +func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { + size := 8 b := 0 buf := make([]byte, size) buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 4 // request opcode + buf[b] = 6 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 + xgb.Put16(buf[b:], PowerLevel) + b += 2 + return buf } -// DisableCookie is a cookie used only for Disable requests. -type DisableCookie struct { +// GetTimeoutsCookie is a cookie used only for GetTimeouts requests. +type GetTimeoutsCookie struct { *xgb.Cookie } -// Disable sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func Disable(c *xgb.Conn) DisableCookie { +// GetTimeouts sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() +func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(disableRequest(c), cookie) - return DisableCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} } -// DisableChecked sends a checked request. -// If an error occurs, it can be retrieved using DisableCookie.Check() -func DisableChecked(c *xgb.Conn) DisableCookie { +// GetTimeoutsUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { if _, ok := c.Extensions["DPMS"]; !ok { - panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(disableRequest(c), cookie) - return DisableCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getTimeoutsRequest(c), cookie) + return GetTimeoutsCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook DisableCookie) Check() error { - return cook.Cookie.Check() +// GetTimeoutsReply represents the data returned from a GetTimeouts request. +type GetTimeoutsReply struct { + Sequence uint16 // sequence number of the request for this reply + Length uint32 // number of bytes in this reply + // padding: 1 bytes + StandbyTimeout uint16 + SuspendTimeout uint16 + OffTimeout uint16 + // padding: 18 bytes } -// Write request to wire for Disable -// disableRequest writes a Disable request to a byte slice. -func disableRequest(c *xgb.Conn) []byte { +// Reply blocks and returns the reply data for a GetTimeouts request. +func (cook GetTimeoutsCookie) Reply() (*GetTimeoutsReply, error) { + buf, err := cook.Cookie.Reply() + if err != nil { + return nil, err + } + if buf == nil { + return nil, nil + } + return getTimeoutsReply(buf), nil +} + +// getTimeoutsReply reads a byte slice into a GetTimeoutsReply value. +func getTimeoutsReply(buf []byte) *GetTimeoutsReply { + v := new(GetTimeoutsReply) + 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.StandbyTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.SuspendTimeout = xgb.Get16(buf[b:]) + b += 2 + + v.OffTimeout = xgb.Get16(buf[b:]) + b += 2 + + b += 18 // padding + + return v +} + +// Write request to wire for GetTimeouts +// getTimeoutsRequest writes a GetTimeouts request to a byte slice. +func getTimeoutsRequest(c *xgb.Conn) []byte { size := 4 b := 0 buf := make([]byte, size) @@ -510,7 +409,7 @@ func disableRequest(c *xgb.Conn) []byte { buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 5 // request opcode + buf[b] = 2 // request opcode b += 1 xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units @@ -519,42 +418,79 @@ func disableRequest(c *xgb.Conn) []byte { return buf } -// ForceLevelCookie is a cookie used only for ForceLevel requests. -type ForceLevelCookie struct { +// GetVersionCookie is a cookie used only for GetVersion requests. +type GetVersionCookie struct { *xgb.Cookie } -// ForceLevel sends an unchecked request. -// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. -func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { +// 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["DPMS"]; !ok { - panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(false, false) - c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) - return ForceLevelCookie{cookie} + cookie := c.NewCookie(true, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} } -// ForceLevelChecked sends a checked request. -// If an error occurs, it can be retrieved using ForceLevelCookie.Check() -func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { +// 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["DPMS"]; !ok { - panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } - cookie := c.NewCookie(true, false) - c.NewRequest(forceLevelRequest(c, PowerLevel), cookie) - return ForceLevelCookie{cookie} + cookie := c.NewCookie(false, true) + c.NewRequest(getVersionRequest(c, ClientMajorVersion, ClientMinorVersion), cookie) + return GetVersionCookie{cookie} } -// Check returns an error if one occurred for checked requests that are not expecting a reply. -// This cannot be called for requests expecting a reply, nor for unchecked requests. -func (cook ForceLevelCookie) Check() error { - return cook.Cookie.Check() +// GetVersionReply represents the data returned from a GetVersion request. +type GetVersionReply struct { + 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 } -// Write request to wire for ForceLevel -// forceLevelRequest writes a ForceLevel request to a byte slice. -func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { +// 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 { + return nil, err + } + if buf == nil { + return nil, nil + } + return getVersionReply(buf), nil +} + +// getVersionReply reads a byte slice into a GetVersionReply value. +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 +// getVersionRequest writes a GetVersion request to a byte slice. +func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersion uint16) []byte { size := 8 b := 0 buf := make([]byte, size) @@ -562,13 +498,16 @@ func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { buf[b] = c.Extensions["DPMS"] b += 1 - buf[b] = 6 // request opcode + 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:], PowerLevel) + xgb.Put16(buf[b:], ClientMajorVersion) + b += 2 + + xgb.Put16(buf[b:], ClientMinorVersion) b += 2 return buf @@ -669,3 +608,64 @@ func infoRequest(c *xgb.Conn) []byte { return buf } + +// SetTimeoutsCookie is a cookie used only for SetTimeouts requests. +type SetTimeoutsCookie struct { + *xgb.Cookie +} + +// SetTimeouts sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. +func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } + cookie := c.NewCookie(false, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +// SetTimeoutsChecked sends a checked request. +// If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() +func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + if _, ok := c.Extensions["DPMS"]; !ok { + panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") + } + cookie := c.NewCookie(true, false) + c.NewRequest(setTimeoutsRequest(c, StandbyTimeout, SuspendTimeout, OffTimeout), cookie) + return SetTimeoutsCookie{cookie} +} + +// Check returns an error if one occurred for checked requests that are not expecting a reply. +// This cannot be called for requests expecting a reply, nor for unchecked requests. +func (cook SetTimeoutsCookie) Check() error { + return cook.Cookie.Check() +} + +// Write request to wire for SetTimeouts +// setTimeoutsRequest writes a SetTimeouts request to a byte slice. +func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) []byte { + size := 12 + b := 0 + buf := make([]byte, size) + + buf[b] = c.Extensions["DPMS"] + b += 1 + + buf[b] = 3 // request opcode + b += 1 + + xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units + b += 2 + + xgb.Put16(buf[b:], StandbyTimeout) + b += 2 + + xgb.Put16(buf[b:], SuspendTimeout) + b += 2 + + xgb.Put16(buf[b:], OffTimeout) + b += 2 + + 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/dpms/dpms.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index 96d82f0..75ec85d 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -1,10 +1,7 @@ // Package dpms is the X client API for the DPMS extension. package dpms -/* - This file was generated by dpms.xml on Aug 11 2013 8:39:43pm EDT. - This file is automatically generated. Edit at your peril! -*/ +// This file is automatically generated from dpms.xml. Edit at your peril! import ( "github.com/BurntSushi/xgb" -- 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/dpms/dpms.go | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'nexgb/dpms') diff --git a/nexgb/dpms/dpms.go b/nexgb/dpms/dpms.go index 75ec85d..4bf5883 100644 --- a/nexgb/dpms/dpms.go +++ b/nexgb/dpms/dpms.go @@ -19,16 +19,15 @@ func Init(c *xgb.Conn) error { return xgb.Errorf("No extension named DPMS could be found on on the server.") } - xgb.ExtLock.Lock() + c.ExtLock.Lock() c.Extensions["DPMS"] = reply.MajorOpcode + c.ExtLock.Unlock() for evNum, fun := range xgb.NewExtEventFuncs["DPMS"] { xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range xgb.NewExtErrorFuncs["DPMS"] { xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun } - xgb.ExtLock.Unlock() - return nil } @@ -76,6 +75,8 @@ type CapableCookie struct { // Capable sends a checked request. // If an error occurs, it will be returned with the reply by calling CapableCookie.Reply() func Capable(c *xgb.Conn) CapableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Capable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -87,6 +88,8 @@ func Capable(c *xgb.Conn) CapableCookie { // CapableUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CapableUnchecked(c *xgb.Conn) CapableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Capable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -148,7 +151,9 @@ func capableRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 1 // request opcode @@ -168,6 +173,8 @@ type DisableCookie struct { // Disable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Disable(c *xgb.Conn) DisableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -179,6 +186,8 @@ func Disable(c *xgb.Conn) DisableCookie { // DisableChecked sends a checked request. // If an error occurs, it can be retrieved using DisableCookie.Check() func DisableChecked(c *xgb.Conn) DisableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Disable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -200,7 +209,9 @@ func disableRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 5 // request opcode @@ -220,6 +231,8 @@ type EnableCookie struct { // Enable sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Enable(c *xgb.Conn) EnableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -231,6 +244,8 @@ func Enable(c *xgb.Conn) EnableCookie { // EnableChecked sends a checked request. // If an error occurs, it can be retrieved using EnableCookie.Check() func EnableChecked(c *xgb.Conn) EnableCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Enable' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -252,7 +267,9 @@ func enableRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 4 // request opcode @@ -272,6 +289,8 @@ type ForceLevelCookie struct { // ForceLevel sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -283,6 +302,8 @@ func ForceLevel(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { // ForceLevelChecked sends a checked request. // If an error occurs, it can be retrieved using ForceLevelCookie.Check() func ForceLevelChecked(c *xgb.Conn, PowerLevel uint16) ForceLevelCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'ForceLevel' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -304,7 +325,9 @@ func forceLevelRequest(c *xgb.Conn, PowerLevel uint16) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 6 // request opcode @@ -327,6 +350,8 @@ type GetTimeoutsCookie struct { // GetTimeouts sends a checked request. // If an error occurs, it will be returned with the reply by calling GetTimeoutsCookie.Reply() func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -338,6 +363,8 @@ func GetTimeouts(c *xgb.Conn) GetTimeoutsCookie { // GetTimeoutsUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetTimeoutsUnchecked(c *xgb.Conn) GetTimeoutsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'GetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -403,7 +430,9 @@ func getTimeoutsRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 2 // request opcode @@ -423,6 +452,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["DPMS"]; !ok { panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -434,6 +465,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["DPMS"]; !ok { panic("Cannot issue request 'GetVersion' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -492,7 +525,9 @@ func getVersionRequest(c *xgb.Conn, ClientMajorVersion uint16, ClientMinorVersio b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 0 // request opcode @@ -518,6 +553,8 @@ type InfoCookie struct { // Info sends a checked request. // If an error occurs, it will be returned with the reply by calling InfoCookie.Reply() func Info(c *xgb.Conn) InfoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Info' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -529,6 +566,8 @@ func Info(c *xgb.Conn) InfoCookie { // InfoUnchecked sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InfoUnchecked(c *xgb.Conn) InfoCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'Info' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -594,7 +633,9 @@ func infoRequest(c *xgb.Conn) []byte { b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 7 // request opcode @@ -614,6 +655,8 @@ type SetTimeoutsCookie struct { // SetTimeouts sends an unchecked request. // If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -625,6 +668,8 @@ func SetTimeouts(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffT // SetTimeoutsChecked sends a checked request. // If an error occurs, it can be retrieved using SetTimeoutsCookie.Check() func SetTimeoutsChecked(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint16, OffTimeout uint16) SetTimeoutsCookie { + c.ExtLock.RLock() + defer c.ExtLock.RUnlock() if _, ok := c.Extensions["DPMS"]; !ok { panic("Cannot issue request 'SetTimeouts' using the uninitialized extension 'DPMS'. dpms.Init(connObj) must be called first.") } @@ -646,7 +691,9 @@ func setTimeoutsRequest(c *xgb.Conn, StandbyTimeout uint16, SuspendTimeout uint1 b := 0 buf := make([]byte, size) + c.ExtLock.RLock() buf[b] = c.Extensions["DPMS"] + c.ExtLock.RUnlock() b += 1 buf[b] = 3 // request opcode -- cgit v1.2.3