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/sync/sync.go | 368 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 222 insertions(+), 146 deletions(-) (limited to 'nexgb/sync') diff --git a/nexgb/sync/sync.go b/nexgb/sync/sync.go index cde5cab..7a32bc4 100644 --- a/nexgb/sync/sync.go +++ b/nexgb/sync/sync.go @@ -2,7 +2,7 @@ package sync /* - This file was generated by sync.xml on May 10 2012 8:04:32pm EDT. + This file was generated by sync.xml on May 10 2012 11:56:19pm EDT. This file is automatically generated. Edit at your peril! */ @@ -40,6 +40,10 @@ func init() { xgb.NewExtErrorFuncs["SYNC"] = 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' @@ -60,10 +64,6 @@ func init() { // Skipping definition for base type 'Float' -// Skipping definition for base type 'Card8' - -// Skipping definition for base type 'Int16' - const ( AlarmstateActive = 0 AlarmstateInactive = 1 @@ -121,14 +121,12 @@ func NewFenceId(c *xgb.Conn) (Fence, error) { return Fence(id), nil } -// 'Int64' struct definition -// Size: 8 type Int64 struct { Hi int32 Lo uint32 } -// Struct read Int64 +// Int64Read reads a byte slice into a Int64 value. func Int64Read(buf []byte, v *Int64) int { b := 0 @@ -141,7 +139,7 @@ func Int64Read(buf []byte, v *Int64) int { return b } -// Struct list read Int64 +// Int64ReadList reads a byte slice into a list of Int64 values. func Int64ReadList(buf []byte, dest []Int64) int { b := 0 for i := 0; i < len(dest); i++ { @@ -151,7 +149,7 @@ func Int64ReadList(buf []byte, dest []Int64) int { return xgb.Pad(b) } -// Struct write Int64 +// Bytes writes a Int64 value to a byte slice. func (v Int64) Bytes() []byte { buf := make([]byte, 8) b := 0 @@ -165,7 +163,7 @@ func (v Int64) Bytes() []byte { return buf } -// Write struct list Int64 +// Int64ListBytes writes a list of %s(MISSING) values to a byte slice. func Int64ListBytes(buf []byte, list []Int64) int { b := 0 var structBytes []byte @@ -177,8 +175,6 @@ func Int64ListBytes(buf []byte, list []Int64) int { return b } -// 'Systemcounter' struct definition -// Size: (14 + xgb.Pad((int(NameLen) * 1))) type Systemcounter struct { Counter Counter Resolution Int64 @@ -186,7 +182,7 @@ type Systemcounter struct { Name string // size: xgb.Pad((int(NameLen) * 1)) } -// Struct read Systemcounter +// SystemcounterRead reads a byte slice into a Systemcounter value. func SystemcounterRead(buf []byte, v *Systemcounter) int { b := 0 @@ -209,7 +205,7 @@ func SystemcounterRead(buf []byte, v *Systemcounter) int { return b } -// Struct list read Systemcounter +// SystemcounterReadList reads a byte slice into a list of Systemcounter values. func SystemcounterReadList(buf []byte, dest []Systemcounter) int { b := 0 for i := 0; i < len(dest); i++ { @@ -219,7 +215,7 @@ func SystemcounterReadList(buf []byte, dest []Systemcounter) int { return xgb.Pad(b) } -// Struct write Systemcounter +// Bytes writes a Systemcounter value to a byte slice. func (v Systemcounter) Bytes() []byte { buf := make([]byte, (14 + xgb.Pad((int(v.NameLen) * 1)))) b := 0 @@ -242,7 +238,7 @@ func (v Systemcounter) Bytes() []byte { return buf } -// Write struct list Systemcounter +// SystemcounterListBytes writes a list of %s(MISSING) values to a byte slice. func SystemcounterListBytes(buf []byte, list []Systemcounter) int { b := 0 var structBytes []byte @@ -254,7 +250,7 @@ func SystemcounterListBytes(buf []byte, list []Systemcounter) int { return b } -// Struct list size Systemcounter +// SystemcounterListSize computes the size (bytes) of a list of Systemcounter values. func SystemcounterListSize(list []Systemcounter) int { size := 0 for _, item := range list { @@ -263,8 +259,6 @@ func SystemcounterListSize(list []Systemcounter) int { return size } -// 'Trigger' struct definition -// Size: 20 type Trigger struct { Counter Counter WaitType uint32 @@ -272,7 +266,7 @@ type Trigger struct { TestType uint32 } -// Struct read Trigger +// TriggerRead reads a byte slice into a Trigger value. func TriggerRead(buf []byte, v *Trigger) int { b := 0 @@ -291,7 +285,7 @@ func TriggerRead(buf []byte, v *Trigger) int { return b } -// Struct list read Trigger +// TriggerReadList reads a byte slice into a list of Trigger values. func TriggerReadList(buf []byte, dest []Trigger) int { b := 0 for i := 0; i < len(dest); i++ { @@ -301,7 +295,7 @@ func TriggerReadList(buf []byte, dest []Trigger) int { return xgb.Pad(b) } -// Struct write Trigger +// Bytes writes a Trigger value to a byte slice. func (v Trigger) Bytes() []byte { buf := make([]byte, 20) b := 0 @@ -324,7 +318,7 @@ func (v Trigger) Bytes() []byte { return buf } -// Write struct list Trigger +// TriggerListBytes writes a list of %s(MISSING) values to a byte slice. func TriggerListBytes(buf []byte, list []Trigger) int { b := 0 var structBytes []byte @@ -336,14 +330,12 @@ func TriggerListBytes(buf []byte, list []Trigger) int { return b } -// 'Waitcondition' struct definition -// Size: 28 type Waitcondition struct { Trigger Trigger EventThreshold Int64 } -// Struct read Waitcondition +// WaitconditionRead reads a byte slice into a Waitcondition value. func WaitconditionRead(buf []byte, v *Waitcondition) int { b := 0 @@ -356,7 +348,7 @@ func WaitconditionRead(buf []byte, v *Waitcondition) int { return b } -// Struct list read Waitcondition +// WaitconditionReadList reads a byte slice into a list of Waitcondition values. func WaitconditionReadList(buf []byte, dest []Waitcondition) int { b := 0 for i := 0; i < len(dest); i++ { @@ -366,7 +358,7 @@ func WaitconditionReadList(buf []byte, dest []Waitcondition) int { return xgb.Pad(b) } -// Struct write Waitcondition +// Bytes writes a Waitcondition value to a byte slice. func (v Waitcondition) Bytes() []byte { buf := make([]byte, 28) b := 0 @@ -386,7 +378,7 @@ func (v Waitcondition) Bytes() []byte { return buf } -// Write struct list Waitcondition +// WaitconditionListBytes writes a list of %s(MISSING) values to a byte slice. func WaitconditionListBytes(buf []byte, list []Waitcondition) int { b := 0 var structBytes []byte @@ -398,9 +390,7 @@ func WaitconditionListBytes(buf []byte, list []Waitcondition) int { return b } -// Event definition CounterNotify (0) -// Size: 32 - +// CounterNotify is the event number for a CounterNotifyEvent. const CounterNotify = 0 type CounterNotifyEvent struct { @@ -415,7 +405,7 @@ type CounterNotifyEvent struct { // padding: 1 bytes } -// Event read CounterNotify +// CounterNotifyEventNew constructs a CounterNotifyEvent value that implements xgb.Event from a byte slice. func CounterNotifyEventNew(buf []byte) xgb.Event { v := CounterNotifyEvent{} b := 1 // don't read event number @@ -453,7 +443,7 @@ func CounterNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write CounterNotify +// Bytes writes a CounterNotifyEvent value to a byte slice. func (v CounterNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -500,12 +490,14 @@ func (v CounterNotifyEvent) Bytes() []byte { return buf } -func (v CounterNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the CounterNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v CounterNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of CounterNotifyEvent. func (v CounterNotifyEvent) String() string { fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -521,9 +513,7 @@ func init() { xgb.NewExtEventFuncs["SYNC"][0] = CounterNotifyEventNew } -// Event definition AlarmNotify (1) -// Size: 32 - +// AlarmNotify is the event number for a AlarmNotifyEvent. const AlarmNotify = 1 type AlarmNotifyEvent struct { @@ -537,7 +527,7 @@ type AlarmNotifyEvent struct { // padding: 3 bytes } -// Event read AlarmNotify +// AlarmNotifyEventNew constructs a AlarmNotifyEvent value that implements xgb.Event from a byte slice. func AlarmNotifyEventNew(buf []byte) xgb.Event { v := AlarmNotifyEvent{} b := 1 // don't read event number @@ -568,7 +558,7 @@ func AlarmNotifyEventNew(buf []byte) xgb.Event { return v } -// Event write AlarmNotify +// Bytes writes a AlarmNotifyEvent value to a byte slice. func (v AlarmNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 @@ -608,12 +598,14 @@ func (v AlarmNotifyEvent) Bytes() []byte { return buf } -func (v AlarmNotifyEvent) ImplementsEvent() {} - +// SequenceId returns the sequence id attached to the AlarmNotify event. +// Events without a sequence number (KeymapNotify) return 0. +// This is mostly used internally. func (v AlarmNotifyEvent) SequenceId() uint16 { return v.Sequence } +// String is a rudimentary string representation of AlarmNotifyEvent. func (v AlarmNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence)) @@ -628,9 +620,7 @@ func init() { xgb.NewExtEventFuncs["SYNC"][1] = AlarmNotifyEventNew } -// Error definition Counter (0) -// Size: 32 - +// BadCounter is the error number for a BadCounter. const BadCounter = 0 type CounterError struct { @@ -641,7 +631,7 @@ type CounterError struct { MajorOpcode byte } -// Error read Counter +// CounterErrorNew constructs a CounterError value that implements xgb.Error from a byte slice. func CounterErrorNew(buf []byte) xgb.Error { v := CounterError{} v.NiceName = "Counter" @@ -664,8 +654,8 @@ func CounterErrorNew(buf []byte) xgb.Error { return v } -func (err CounterError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadCounter error. +// This is mostly used internally. func (err CounterError) SequenceId() uint16 { return err.Sequence } @@ -688,9 +678,7 @@ func init() { xgb.NewExtErrorFuncs["SYNC"][0] = CounterErrorNew } -// Error definition Alarm (1) -// Size: 32 - +// BadAlarm is the error number for a BadAlarm. const BadAlarm = 1 type AlarmError struct { @@ -701,7 +689,7 @@ type AlarmError struct { MajorOpcode byte } -// Error read Alarm +// AlarmErrorNew constructs a AlarmError value that implements xgb.Error from a byte slice. func AlarmErrorNew(buf []byte) xgb.Error { v := AlarmError{} v.NiceName = "Alarm" @@ -724,8 +712,8 @@ func AlarmErrorNew(buf []byte) xgb.Error { return v } -func (err AlarmError) ImplementsError() {} - +// SequenceId returns the sequence id attached to the BadAlarm error. +// This is mostly used internally. func (err AlarmError) SequenceId() uint16 { return err.Sequence } @@ -748,36 +736,38 @@ func init() { xgb.NewExtErrorFuncs["SYNC"][1] = AlarmErrorNew } -// Request Initialize -// size: 8 +// InitializeCookie is a cookie used only for Initialize requests. type InitializeCookie struct { *xgb.Cookie } +// Initialize sends a checked request. +// If an error occurs, it will be returned with the reply by calling InitializeCookie.Reply() func Initialize(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { cookie := c.NewCookie(true, true) c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) return InitializeCookie{cookie} } +// InitializeUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func InitializeUnchecked(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) InitializeCookie { cookie := c.NewCookie(false, true) c.NewRequest(initializeRequest(c, DesiredMajorVersion, DesiredMinorVersion), cookie) return InitializeCookie{cookie} } -// Request reply for Initialize -// size: 32 +// InitializeReply represents the data returned from a Initialize request. type InitializeReply 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 MajorVersion byte MinorVersion byte // padding: 22 bytes } -// Waits and reads reply data from request Initialize +// Reply blocks and returns the reply data for a Initialize request. func (cook InitializeCookie) Reply() (*InitializeReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -789,7 +779,7 @@ func (cook InitializeCookie) Reply() (*InitializeReply, error) { return initializeReply(buf), nil } -// Read reply into structure from buffer for Initialize +// initializeReply reads a byte slice into a InitializeReply value. func initializeReply(buf []byte) *InitializeReply { v := new(InitializeReply) b := 1 // skip reply determinant @@ -814,6 +804,7 @@ func initializeReply(buf []byte) *InitializeReply { } // Write request to wire for Initialize +// initializeRequest writes a Initialize request to a byte slice. func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { size := 8 b := 0 @@ -837,36 +828,38 @@ func initializeRequest(c *xgb.Conn, DesiredMajorVersion byte, DesiredMinorVersio return buf } -// Request ListSystemCounters -// size: 4 +// ListSystemCountersCookie is a cookie used only for ListSystemCounters requests. type ListSystemCountersCookie struct { *xgb.Cookie } +// ListSystemCounters sends a checked request. +// If an error occurs, it will be returned with the reply by calling ListSystemCountersCookie.Reply() func ListSystemCounters(c *xgb.Conn) ListSystemCountersCookie { cookie := c.NewCookie(true, true) c.NewRequest(listSystemCountersRequest(c), cookie) return ListSystemCountersCookie{cookie} } +// ListSystemCountersUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ListSystemCountersUnchecked(c *xgb.Conn) ListSystemCountersCookie { cookie := c.NewCookie(false, true) c.NewRequest(listSystemCountersRequest(c), cookie) return ListSystemCountersCookie{cookie} } -// Request reply for ListSystemCounters -// size: (32 + SystemcounterListSize(Counters)) +// ListSystemCountersReply represents the data returned from a ListSystemCounters request. type ListSystemCountersReply 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 CountersLen uint32 // padding: 20 bytes Counters []Systemcounter // size: SystemcounterListSize(Counters) } -// Waits and reads reply data from request ListSystemCounters +// Reply blocks and returns the reply data for a ListSystemCounters request. func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -878,7 +871,7 @@ func (cook ListSystemCountersCookie) Reply() (*ListSystemCountersReply, error) { return listSystemCountersReply(buf), nil } -// Read reply into structure from buffer for ListSystemCounters +// listSystemCountersReply reads a byte slice into a ListSystemCountersReply value. func listSystemCountersReply(buf []byte) *ListSystemCountersReply { v := new(ListSystemCountersReply) b := 1 // skip reply determinant @@ -903,6 +896,7 @@ func listSystemCountersReply(buf []byte) *ListSystemCountersReply { } // Write request to wire for ListSystemCounters +// listSystemCountersRequest writes a ListSystemCounters request to a byte slice. func listSystemCountersRequest(c *xgb.Conn) []byte { size := 4 b := 0 @@ -920,30 +914,35 @@ func listSystemCountersRequest(c *xgb.Conn) []byte { return buf } -// Request CreateCounter -// size: 16 +// CreateCounterCookie is a cookie used only for CreateCounter requests. type CreateCounterCookie struct { *xgb.Cookie } -// Write request to wire for CreateCounter +// CreateCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateCounter(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) return CreateCounterCookie{cookie} } +// CreateCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateCounterCookie.Check() func CreateCounterChecked(c *xgb.Conn, Id Counter, InitialValue Int64) CreateCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(createCounterRequest(c, Id, InitialValue), cookie) return CreateCounterCookie{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 CreateCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateCounter +// createCounterRequest writes a CreateCounter request to a byte slice. func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { size := 16 b := 0 @@ -970,30 +969,35 @@ func createCounterRequest(c *xgb.Conn, Id Counter, InitialValue Int64) []byte { return buf } -// Request DestroyCounter -// size: 8 +// DestroyCounterCookie is a cookie used only for DestroyCounter requests. type DestroyCounterCookie struct { *xgb.Cookie } -// Write request to wire for DestroyCounter +// DestroyCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyCounter(c *xgb.Conn, Counter Counter) DestroyCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyCounterRequest(c, Counter), cookie) return DestroyCounterCookie{cookie} } +// DestroyCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyCounterCookie.Check() func DestroyCounterChecked(c *xgb.Conn, Counter Counter) DestroyCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyCounterRequest(c, Counter), cookie) return DestroyCounterCookie{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 DestroyCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyCounter +// destroyCounterRequest writes a DestroyCounter request to a byte slice. func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { size := 8 b := 0 @@ -1014,34 +1018,36 @@ func destroyCounterRequest(c *xgb.Conn, Counter Counter) []byte { return buf } -// Request QueryCounter -// size: 8 +// QueryCounterCookie is a cookie used only for QueryCounter requests. type QueryCounterCookie struct { *xgb.Cookie } +// QueryCounter sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryCounterCookie.Reply() func QueryCounter(c *xgb.Conn, Counter Counter) QueryCounterCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryCounterRequest(c, Counter), cookie) return QueryCounterCookie{cookie} } +// QueryCounterUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryCounterUnchecked(c *xgb.Conn, Counter Counter) QueryCounterCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryCounterRequest(c, Counter), cookie) return QueryCounterCookie{cookie} } -// Request reply for QueryCounter -// size: 16 +// QueryCounterReply represents the data returned from a QueryCounter request. type QueryCounterReply 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 CounterValue Int64 } -// Waits and reads reply data from request QueryCounter +// Reply blocks and returns the reply data for a QueryCounter request. func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1053,7 +1059,7 @@ func (cook QueryCounterCookie) Reply() (*QueryCounterReply, error) { return queryCounterReply(buf), nil } -// Read reply into structure from buffer for QueryCounter +// queryCounterReply reads a byte slice into a QueryCounterReply value. func queryCounterReply(buf []byte) *QueryCounterReply { v := new(QueryCounterReply) b := 1 // skip reply determinant @@ -1073,6 +1079,7 @@ func queryCounterReply(buf []byte) *QueryCounterReply { } // Write request to wire for QueryCounter +// queryCounterRequest writes a QueryCounter request to a byte slice. func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { size := 8 b := 0 @@ -1093,30 +1100,35 @@ func queryCounterRequest(c *xgb.Conn, Counter Counter) []byte { return buf } -// Request Await -// size: xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) +// AwaitCookie is a cookie used only for Await requests. type AwaitCookie struct { *xgb.Cookie } -// Write request to wire for Await +// Await sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func Await(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { cookie := c.NewCookie(false, false) c.NewRequest(awaitRequest(c, WaitList), cookie) return AwaitCookie{cookie} } +// AwaitChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitCookie.Check() func AwaitChecked(c *xgb.Conn, WaitList []Waitcondition) AwaitCookie { cookie := c.NewCookie(true, false) c.NewRequest(awaitRequest(c, WaitList), cookie) return AwaitCookie{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 AwaitCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for Await +// awaitRequest writes a Await request to a byte slice. func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { size := xgb.Pad((4 + xgb.Pad((len(WaitList) * 28)))) b := 0 @@ -1136,30 +1148,35 @@ func awaitRequest(c *xgb.Conn, WaitList []Waitcondition) []byte { return buf } -// Request ChangeCounter -// size: 16 +// ChangeCounterCookie is a cookie used only for ChangeCounter requests. type ChangeCounterCookie struct { *xgb.Cookie } -// Write request to wire for ChangeCounter +// ChangeCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeCounter(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) return ChangeCounterCookie{cookie} } +// ChangeCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeCounterCookie.Check() func ChangeCounterChecked(c *xgb.Conn, Counter Counter, Amount Int64) ChangeCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeCounterRequest(c, Counter, Amount), cookie) return ChangeCounterCookie{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 ChangeCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeCounter +// changeCounterRequest writes a ChangeCounter request to a byte slice. func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { size := 16 b := 0 @@ -1186,30 +1203,35 @@ func changeCounterRequest(c *xgb.Conn, Counter Counter, Amount Int64) []byte { return buf } -// Request SetCounter -// size: 16 +// SetCounterCookie is a cookie used only for SetCounter requests. type SetCounterCookie struct { *xgb.Cookie } -// Write request to wire for SetCounter +// SetCounter sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetCounter(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { cookie := c.NewCookie(false, false) c.NewRequest(setCounterRequest(c, Counter, Value), cookie) return SetCounterCookie{cookie} } +// SetCounterChecked sends a checked request. +// If an error occurs, it can be retrieved using SetCounterCookie.Check() func SetCounterChecked(c *xgb.Conn, Counter Counter, Value Int64) SetCounterCookie { cookie := c.NewCookie(true, false) c.NewRequest(setCounterRequest(c, Counter, Value), cookie) return SetCounterCookie{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 SetCounterCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetCounter +// setCounterRequest writes a SetCounter request to a byte slice. func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { size := 16 b := 0 @@ -1236,30 +1258,35 @@ func setCounterRequest(c *xgb.Conn, Counter Counter, Value Int64) []byte { return buf } -// Request CreateAlarm -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// CreateAlarmCookie is a cookie used only for CreateAlarm requests. type CreateAlarmCookie struct { *xgb.Cookie } -// Write request to wire for CreateAlarm +// CreateAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) return CreateAlarmCookie{cookie} } +// CreateAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateAlarmCookie.Check() func CreateAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) CreateAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(createAlarmRequest(c, Id, ValueMask, ValueList), cookie) return CreateAlarmCookie{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 CreateAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateAlarm +// createAlarmRequest writes a CreateAlarm request to a byte slice. func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -1288,30 +1315,35 @@ func createAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uin return buf } -// Request ChangeAlarm -// size: xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) +// ChangeAlarmCookie is a cookie used only for ChangeAlarm requests. type ChangeAlarmCookie struct { *xgb.Cookie } -// Write request to wire for ChangeAlarm +// ChangeAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ChangeAlarm(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) return ChangeAlarmCookie{cookie} } +// ChangeAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using ChangeAlarmCookie.Check() func ChangeAlarmChecked(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) ChangeAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(changeAlarmRequest(c, Id, ValueMask, ValueList), cookie) return ChangeAlarmCookie{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 ChangeAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ChangeAlarm +// changeAlarmRequest writes a ChangeAlarm request to a byte slice. func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uint32) []byte { size := xgb.Pad((8 + (4 + xgb.Pad((4 * xgb.PopCount(int(ValueMask))))))) b := 0 @@ -1340,30 +1372,35 @@ func changeAlarmRequest(c *xgb.Conn, Id Alarm, ValueMask uint32, ValueList []uin return buf } -// Request DestroyAlarm -// size: 8 +// DestroyAlarmCookie is a cookie used only for DestroyAlarm requests. type DestroyAlarmCookie struct { *xgb.Cookie } -// Write request to wire for DestroyAlarm +// DestroyAlarm sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyAlarm(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) return DestroyAlarmCookie{cookie} } +// DestroyAlarmChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyAlarmCookie.Check() func DestroyAlarmChecked(c *xgb.Conn, Alarm Alarm) DestroyAlarmCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyAlarmRequest(c, Alarm), cookie) return DestroyAlarmCookie{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 DestroyAlarmCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyAlarm +// destroyAlarmRequest writes a DestroyAlarm request to a byte slice. func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { size := 8 b := 0 @@ -1384,29 +1421,31 @@ func destroyAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { return buf } -// Request QueryAlarm -// size: 8 +// QueryAlarmCookie is a cookie used only for QueryAlarm requests. type QueryAlarmCookie struct { *xgb.Cookie } +// QueryAlarm sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryAlarmCookie.Reply() func QueryAlarm(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryAlarmRequest(c, Alarm), cookie) return QueryAlarmCookie{cookie} } +// QueryAlarmUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryAlarmUnchecked(c *xgb.Conn, Alarm Alarm) QueryAlarmCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryAlarmRequest(c, Alarm), cookie) return QueryAlarmCookie{cookie} } -// Request reply for QueryAlarm -// size: 40 +// QueryAlarmReply represents the data returned from a QueryAlarm request. type QueryAlarmReply 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 Trigger Trigger Delta Int64 @@ -1415,7 +1454,7 @@ type QueryAlarmReply struct { // padding: 2 bytes } -// Waits and reads reply data from request QueryAlarm +// Reply blocks and returns the reply data for a QueryAlarm request. func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1427,7 +1466,7 @@ func (cook QueryAlarmCookie) Reply() (*QueryAlarmReply, error) { return queryAlarmReply(buf), nil } -// Read reply into structure from buffer for QueryAlarm +// queryAlarmReply reads a byte slice into a QueryAlarmReply value. func queryAlarmReply(buf []byte) *QueryAlarmReply { v := new(QueryAlarmReply) b := 1 // skip reply determinant @@ -1462,6 +1501,7 @@ func queryAlarmReply(buf []byte) *QueryAlarmReply { } // Write request to wire for QueryAlarm +// queryAlarmRequest writes a QueryAlarm request to a byte slice. func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { size := 8 b := 0 @@ -1482,30 +1522,35 @@ func queryAlarmRequest(c *xgb.Conn, Alarm Alarm) []byte { return buf } -// Request SetPriority -// size: 12 +// SetPriorityCookie is a cookie used only for SetPriority requests. type SetPriorityCookie struct { *xgb.Cookie } -// Write request to wire for SetPriority +// SetPriority sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func SetPriority(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { cookie := c.NewCookie(false, false) c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) return SetPriorityCookie{cookie} } +// SetPriorityChecked sends a checked request. +// If an error occurs, it can be retrieved using SetPriorityCookie.Check() func SetPriorityChecked(c *xgb.Conn, Id uint32, Priority int32) SetPriorityCookie { cookie := c.NewCookie(true, false) c.NewRequest(setPriorityRequest(c, Id, Priority), cookie) return SetPriorityCookie{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 SetPriorityCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for SetPriority +// setPriorityRequest writes a SetPriority request to a byte slice. func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { size := 12 b := 0 @@ -1529,34 +1574,36 @@ func setPriorityRequest(c *xgb.Conn, Id uint32, Priority int32) []byte { return buf } -// Request GetPriority -// size: 8 +// GetPriorityCookie is a cookie used only for GetPriority requests. type GetPriorityCookie struct { *xgb.Cookie } +// GetPriority sends a checked request. +// If an error occurs, it will be returned with the reply by calling GetPriorityCookie.Reply() func GetPriority(c *xgb.Conn, Id uint32) GetPriorityCookie { cookie := c.NewCookie(true, true) c.NewRequest(getPriorityRequest(c, Id), cookie) return GetPriorityCookie{cookie} } +// GetPriorityUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func GetPriorityUnchecked(c *xgb.Conn, Id uint32) GetPriorityCookie { cookie := c.NewCookie(false, true) c.NewRequest(getPriorityRequest(c, Id), cookie) return GetPriorityCookie{cookie} } -// Request reply for GetPriority -// size: 12 +// GetPriorityReply represents the data returned from a GetPriority request. type GetPriorityReply 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 Priority int32 } -// Waits and reads reply data from request GetPriority +// Reply blocks and returns the reply data for a GetPriority request. func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1568,7 +1615,7 @@ func (cook GetPriorityCookie) Reply() (*GetPriorityReply, error) { return getPriorityReply(buf), nil } -// Read reply into structure from buffer for GetPriority +// getPriorityReply reads a byte slice into a GetPriorityReply value. func getPriorityReply(buf []byte) *GetPriorityReply { v := new(GetPriorityReply) b := 1 // skip reply determinant @@ -1588,6 +1635,7 @@ func getPriorityReply(buf []byte) *GetPriorityReply { } // Write request to wire for GetPriority +// getPriorityRequest writes a GetPriority request to a byte slice. func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { size := 8 b := 0 @@ -1608,30 +1656,35 @@ func getPriorityRequest(c *xgb.Conn, Id uint32) []byte { return buf } -// Request CreateFence -// size: 16 +// CreateFenceCookie is a cookie used only for CreateFence requests. type CreateFenceCookie struct { *xgb.Cookie } -// Write request to wire for CreateFence +// CreateFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func CreateFence(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) return CreateFenceCookie{cookie} } +// CreateFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using CreateFenceCookie.Check() func CreateFenceChecked(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) CreateFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(createFenceRequest(c, Drawable, Fence, InitiallyTriggered), cookie) return CreateFenceCookie{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 CreateFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for CreateFence +// createFenceRequest writes a CreateFence request to a byte slice. func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, InitiallyTriggered bool) []byte { size := 16 b := 0 @@ -1662,30 +1715,35 @@ func createFenceRequest(c *xgb.Conn, Drawable xproto.Drawable, Fence Fence, Init return buf } -// Request TriggerFence -// size: 8 +// TriggerFenceCookie is a cookie used only for TriggerFence requests. type TriggerFenceCookie struct { *xgb.Cookie } -// Write request to wire for TriggerFence +// TriggerFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func TriggerFence(c *xgb.Conn, Fence Fence) TriggerFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(triggerFenceRequest(c, Fence), cookie) return TriggerFenceCookie{cookie} } +// TriggerFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using TriggerFenceCookie.Check() func TriggerFenceChecked(c *xgb.Conn, Fence Fence) TriggerFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(triggerFenceRequest(c, Fence), cookie) return TriggerFenceCookie{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 TriggerFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for TriggerFence +// triggerFenceRequest writes a TriggerFence request to a byte slice. func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1706,30 +1764,35 @@ func triggerFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request ResetFence -// size: 8 +// ResetFenceCookie is a cookie used only for ResetFence requests. type ResetFenceCookie struct { *xgb.Cookie } -// Write request to wire for ResetFence +// ResetFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func ResetFence(c *xgb.Conn, Fence Fence) ResetFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(resetFenceRequest(c, Fence), cookie) return ResetFenceCookie{cookie} } +// ResetFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using ResetFenceCookie.Check() func ResetFenceChecked(c *xgb.Conn, Fence Fence) ResetFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(resetFenceRequest(c, Fence), cookie) return ResetFenceCookie{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 ResetFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for ResetFence +// resetFenceRequest writes a ResetFence request to a byte slice. func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1750,30 +1813,35 @@ func resetFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request DestroyFence -// size: 8 +// DestroyFenceCookie is a cookie used only for DestroyFence requests. type DestroyFenceCookie struct { *xgb.Cookie } -// Write request to wire for DestroyFence +// DestroyFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func DestroyFence(c *xgb.Conn, Fence Fence) DestroyFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(destroyFenceRequest(c, Fence), cookie) return DestroyFenceCookie{cookie} } +// DestroyFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using DestroyFenceCookie.Check() func DestroyFenceChecked(c *xgb.Conn, Fence Fence) DestroyFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(destroyFenceRequest(c, Fence), cookie) return DestroyFenceCookie{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 DestroyFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for DestroyFence +// destroyFenceRequest writes a DestroyFence request to a byte slice. func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1794,35 +1862,37 @@ func destroyFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request QueryFence -// size: 8 +// QueryFenceCookie is a cookie used only for QueryFence requests. type QueryFenceCookie struct { *xgb.Cookie } +// QueryFence sends a checked request. +// If an error occurs, it will be returned with the reply by calling QueryFenceCookie.Reply() func QueryFence(c *xgb.Conn, Fence Fence) QueryFenceCookie { cookie := c.NewCookie(true, true) c.NewRequest(queryFenceRequest(c, Fence), cookie) return QueryFenceCookie{cookie} } +// QueryFenceUnchecked sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func QueryFenceUnchecked(c *xgb.Conn, Fence Fence) QueryFenceCookie { cookie := c.NewCookie(false, true) c.NewRequest(queryFenceRequest(c, Fence), cookie) return QueryFenceCookie{cookie} } -// Request reply for QueryFence -// size: 32 +// QueryFenceReply represents the data returned from a QueryFence request. type QueryFenceReply 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 Triggered bool // padding: 23 bytes } -// Waits and reads reply data from request QueryFence +// Reply blocks and returns the reply data for a QueryFence request. func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { buf, err := cook.Cookie.Reply() if err != nil { @@ -1834,7 +1904,7 @@ func (cook QueryFenceCookie) Reply() (*QueryFenceReply, error) { return queryFenceReply(buf), nil } -// Read reply into structure from buffer for QueryFence +// queryFenceReply reads a byte slice into a QueryFenceReply value. func queryFenceReply(buf []byte) *QueryFenceReply { v := new(QueryFenceReply) b := 1 // skip reply determinant @@ -1860,6 +1930,7 @@ func queryFenceReply(buf []byte) *QueryFenceReply { } // Write request to wire for QueryFence +// queryFenceRequest writes a QueryFence request to a byte slice. func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { size := 8 b := 0 @@ -1880,30 +1951,35 @@ func queryFenceRequest(c *xgb.Conn, Fence Fence) []byte { return buf } -// Request AwaitFence -// size: xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) +// AwaitFenceCookie is a cookie used only for AwaitFence requests. type AwaitFenceCookie struct { *xgb.Cookie } -// Write request to wire for AwaitFence +// AwaitFence sends an unchecked request. +// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent. func AwaitFence(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { cookie := c.NewCookie(false, false) c.NewRequest(awaitFenceRequest(c, FenceList), cookie) return AwaitFenceCookie{cookie} } +// AwaitFenceChecked sends a checked request. +// If an error occurs, it can be retrieved using AwaitFenceCookie.Check() func AwaitFenceChecked(c *xgb.Conn, FenceList []Fence) AwaitFenceCookie { cookie := c.NewCookie(true, false) c.NewRequest(awaitFenceRequest(c, FenceList), cookie) return AwaitFenceCookie{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 AwaitFenceCookie) Check() error { return cook.Cookie.Check() } // Write request to wire for AwaitFence +// awaitFenceRequest writes a AwaitFence request to a byte slice. func awaitFenceRequest(c *xgb.Conn, FenceList []Fence) []byte { size := xgb.Pad((4 + xgb.Pad((len(FenceList) * 4)))) b := 0 -- cgit v1.2.3