package xgb /* This file was generated by sync.xml on May 7 2012 9:17:57pm EDT. This file is automatically generated. Edit at your peril! */ // Imports are not necessary for XGB because everything is // in one package. They are still listed here for reference. // import "xproto" // SyncInit must be called before using the SYNC extension. func (c *Conn) SyncInit() error { reply, err := c.QueryExtension(4, "SYNC").Reply() switch { case err != nil: return err case !reply.Present: return errorf("No extension named SYNC could be found on on the server.") } c.extLock.Lock() c.extensions["SYNC"] = reply.MajorOpcode for evNum, fun := range newExtEventFuncs["SYNC"] { newEventFuncs[int(reply.FirstEvent)+evNum] = fun } for errNum, fun := range newExtErrorFuncs["SYNC"] { newErrorFuncs[int(reply.FirstError)+errNum] = fun } c.extLock.Unlock() return nil } func init() { newExtEventFuncs["SYNC"] = make(map[int]newEventFun) newExtErrorFuncs["SYNC"] = make(map[int]newErrorFun) } // Skipping definition for base type 'Card16' // Skipping definition for base type 'Char' // Skipping definition for base type 'Card32' // Skipping definition for base type 'Double' // Skipping definition for base type 'Bool' // Skipping definition for base type 'Float' // Skipping definition for base type 'Id' // 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' const ( SyncAlarmstateActive = 0 SyncAlarmstateInactive = 1 SyncAlarmstateDestroyed = 2 ) const ( SyncTesttypePositiveTransition = 0 SyncTesttypeNegativeTransition = 1 SyncTesttypePositiveComparison = 2 SyncTesttypeNegativeComparison = 3 ) const ( SyncValuetypeAbsolute = 0 SyncValuetypeRelative = 1 ) const ( SyncCaCounter = 1 SyncCaValueType = 2 SyncCaValue = 4 SyncCaTestType = 8 SyncCaDelta = 16 SyncCaEvents = 32 ) // Skipping resource definition of 'Alarm' // Skipping resource definition of 'Counter' // Skipping resource definition of 'Fence' // 'SyncInt64' struct definition // Size: 8 type SyncInt64 struct { Hi int32 Lo uint32 } // Struct read SyncInt64 func ReadSyncInt64(buf []byte, v *SyncInt64) int { b := 0 v.Hi = int32(Get32(buf[b:])) b += 4 v.Lo = Get32(buf[b:]) b += 4 return b } // Struct list read SyncInt64 func ReadSyncInt64List(buf []byte, dest []SyncInt64) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = SyncInt64{} b += ReadSyncInt64(buf[b:], &dest[i]) } return pad(b) } // Struct write SyncInt64 func (v SyncInt64) Bytes() []byte { buf := make([]byte, 8) b := 0 Put32(buf[b:], uint32(v.Hi)) b += 4 Put32(buf[b:], v.Lo) b += 4 return buf } // Write struct list SyncInt64 func SyncInt64ListBytes(buf []byte, list []SyncInt64) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return b } // 'SyncSystemcounter' struct definition // Size: (14 + pad((int(NameLen) * 1))) type SyncSystemcounter struct { Counter Id Resolution SyncInt64 NameLen uint16 Name string // size: pad((int(NameLen) * 1)) } // Struct read SyncSystemcounter func ReadSyncSystemcounter(buf []byte, v *SyncSystemcounter) int { b := 0 v.Counter = Id(Get32(buf[b:])) b += 4 v.Resolution = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.Resolution) v.NameLen = Get16(buf[b:]) b += 2 { byteString := make([]byte, v.NameLen) copy(byteString[:v.NameLen], buf[b:]) v.Name = string(byteString) b += pad(int(v.NameLen)) } return b } // Struct list read SyncSystemcounter func ReadSyncSystemcounterList(buf []byte, dest []SyncSystemcounter) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = SyncSystemcounter{} b += ReadSyncSystemcounter(buf[b:], &dest[i]) } return pad(b) } // Struct write SyncSystemcounter func (v SyncSystemcounter) Bytes() []byte { buf := make([]byte, (14 + pad((int(v.NameLen) * 1)))) b := 0 Put32(buf[b:], uint32(v.Counter)) b += 4 { structBytes := v.Resolution.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } Put16(buf[b:], v.NameLen) b += 2 copy(buf[b:], v.Name[:v.NameLen]) b += pad(int(v.NameLen)) return buf } // Write struct list SyncSystemcounter func SyncSystemcounterListBytes(buf []byte, list []SyncSystemcounter) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return b } // Struct list size SyncSystemcounter func SyncSystemcounterListSize(list []SyncSystemcounter) int { size := 0 for _, item := range list { size += (14 + pad((int(item.NameLen) * 1))) } return size } // 'SyncTrigger' struct definition // Size: 20 type SyncTrigger struct { Counter Id WaitType uint32 WaitValue SyncInt64 TestType uint32 } // Struct read SyncTrigger func ReadSyncTrigger(buf []byte, v *SyncTrigger) int { b := 0 v.Counter = Id(Get32(buf[b:])) b += 4 v.WaitType = Get32(buf[b:]) b += 4 v.WaitValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.WaitValue) v.TestType = Get32(buf[b:]) b += 4 return b } // Struct list read SyncTrigger func ReadSyncTriggerList(buf []byte, dest []SyncTrigger) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = SyncTrigger{} b += ReadSyncTrigger(buf[b:], &dest[i]) } return pad(b) } // Struct write SyncTrigger func (v SyncTrigger) Bytes() []byte { buf := make([]byte, 20) b := 0 Put32(buf[b:], uint32(v.Counter)) b += 4 Put32(buf[b:], v.WaitType) b += 4 { structBytes := v.WaitValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } Put32(buf[b:], v.TestType) b += 4 return buf } // Write struct list SyncTrigger func SyncTriggerListBytes(buf []byte, list []SyncTrigger) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return b } // 'SyncWaitcondition' struct definition // Size: 28 type SyncWaitcondition struct { Trigger SyncTrigger EventThreshold SyncInt64 } // Struct read SyncWaitcondition func ReadSyncWaitcondition(buf []byte, v *SyncWaitcondition) int { b := 0 v.Trigger = SyncTrigger{} b += ReadSyncTrigger(buf[b:], &v.Trigger) v.EventThreshold = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.EventThreshold) return b } // Struct list read SyncWaitcondition func ReadSyncWaitconditionList(buf []byte, dest []SyncWaitcondition) int { b := 0 for i := 0; i < len(dest); i++ { dest[i] = SyncWaitcondition{} b += ReadSyncWaitcondition(buf[b:], &dest[i]) } return pad(b) } // Struct write SyncWaitcondition func (v SyncWaitcondition) Bytes() []byte { buf := make([]byte, 28) b := 0 { structBytes := v.Trigger.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } { structBytes := v.EventThreshold.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return buf } // Write struct list SyncWaitcondition func SyncWaitconditionListBytes(buf []byte, list []SyncWaitcondition) int { b := 0 var structBytes []byte for _, item := range list { structBytes = item.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return b } // Event definition SyncCounterNotify (0) // Size: 32 const SyncCounterNotify = 0 type SyncCounterNotifyEvent struct { Sequence uint16 Kind byte Counter Id WaitValue SyncInt64 CounterValue SyncInt64 Timestamp Timestamp Count uint16 Destroyed bool // padding: 1 bytes } // Event read SyncCounterNotify func NewSyncCounterNotifyEvent(buf []byte) Event { v := SyncCounterNotifyEvent{} b := 1 // don't read event number v.Kind = buf[b] b += 1 v.Sequence = Get16(buf[b:]) b += 2 v.Counter = Id(Get32(buf[b:])) b += 4 v.WaitValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.WaitValue) v.CounterValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.CounterValue) v.Timestamp = Timestamp(Get32(buf[b:])) b += 4 v.Count = Get16(buf[b:]) b += 2 if buf[b] == 1 { v.Destroyed = true } else { v.Destroyed = false } b += 1 b += 1 // padding return v } // Event write SyncCounterNotify func (v SyncCounterNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number buf[b] = 0 b += 1 buf[b] = v.Kind b += 1 b += 2 // skip sequence number Put32(buf[b:], uint32(v.Counter)) b += 4 { structBytes := v.WaitValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } { structBytes := v.CounterValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } Put32(buf[b:], uint32(v.Timestamp)) b += 4 Put16(buf[b:], v.Count) b += 2 if v.Destroyed { buf[b] = 1 } else { buf[b] = 0 } b += 1 b += 1 // padding return buf } func (v SyncCounterNotifyEvent) ImplementsEvent() {} func (v SyncCounterNotifyEvent) SequenceId() uint16 { return v.Sequence } func (v SyncCounterNotifyEvent) String() string { fieldVals := make([]string, 0, 8) fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) fieldVals = append(fieldVals, sprintf("Counter: %d", v.Counter)) fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) fieldVals = append(fieldVals, sprintf("Count: %d", v.Count)) fieldVals = append(fieldVals, sprintf("Destroyed: %t", v.Destroyed)) return "SyncCounterNotify {" + stringsJoin(fieldVals, ", ") + "}" } func init() { newExtEventFuncs["SYNC"][0] = NewSyncCounterNotifyEvent } // Event definition SyncAlarmNotify (1) // Size: 32 const SyncAlarmNotify = 1 type SyncAlarmNotifyEvent struct { Sequence uint16 Kind byte Alarm Id CounterValue SyncInt64 AlarmValue SyncInt64 Timestamp Timestamp State byte // padding: 3 bytes } // Event read SyncAlarmNotify func NewSyncAlarmNotifyEvent(buf []byte) Event { v := SyncAlarmNotifyEvent{} b := 1 // don't read event number v.Kind = buf[b] b += 1 v.Sequence = Get16(buf[b:]) b += 2 v.Alarm = Id(Get32(buf[b:])) b += 4 v.CounterValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.CounterValue) v.AlarmValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.AlarmValue) v.Timestamp = Timestamp(Get32(buf[b:])) b += 4 v.State = buf[b] b += 1 b += 3 // padding return v } // Event write SyncAlarmNotify func (v SyncAlarmNotifyEvent) Bytes() []byte { buf := make([]byte, 32) b := 0 // write event number buf[b] = 1 b += 1 buf[b] = v.Kind b += 1 b += 2 // skip sequence number Put32(buf[b:], uint32(v.Alarm)) b += 4 { structBytes := v.CounterValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } { structBytes := v.AlarmValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } Put32(buf[b:], uint32(v.Timestamp)) b += 4 buf[b] = v.State b += 1 b += 3 // padding return buf } func (v SyncAlarmNotifyEvent) ImplementsEvent() {} func (v SyncAlarmNotifyEvent) SequenceId() uint16 { return v.Sequence } func (v SyncAlarmNotifyEvent) String() string { fieldVals := make([]string, 0, 7) fieldVals = append(fieldVals, sprintf("Sequence: %d", v.Sequence)) fieldVals = append(fieldVals, sprintf("Kind: %d", v.Kind)) fieldVals = append(fieldVals, sprintf("Alarm: %d", v.Alarm)) fieldVals = append(fieldVals, sprintf("Timestamp: %d", v.Timestamp)) fieldVals = append(fieldVals, sprintf("State: %d", v.State)) return "SyncAlarmNotify {" + stringsJoin(fieldVals, ", ") + "}" } func init() { newExtEventFuncs["SYNC"][1] = NewSyncAlarmNotifyEvent } // Error definition SyncCounter (0) // Size: 32 const BadSyncCounter = 0 type SyncCounterError struct { Sequence uint16 NiceName string BadCounter uint32 MinorOpcode uint16 MajorOpcode byte } // Error read SyncCounter func NewSyncCounterError(buf []byte) Error { v := SyncCounterError{} v.NiceName = "SyncCounter" b := 1 // skip error determinant b += 1 // don't read error number v.Sequence = Get16(buf[b:]) b += 2 v.BadCounter = Get32(buf[b:]) b += 4 v.MinorOpcode = Get16(buf[b:]) b += 2 v.MajorOpcode = buf[b] b += 1 return v } func (err SyncCounterError) ImplementsError() {} func (err SyncCounterError) SequenceId() uint16 { return err.Sequence } func (err SyncCounterError) BadId() Id { return 0 } func (err SyncCounterError) Error() string { fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, sprintf("BadCounter: %d", err.BadCounter)) fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) return "BadSyncCounter {" + stringsJoin(fieldVals, ", ") + "}" } func init() { newExtErrorFuncs["SYNC"][0] = NewSyncCounterError } // Error definition SyncAlarm (1) // Size: 32 const BadSyncAlarm = 1 type SyncAlarmError struct { Sequence uint16 NiceName string BadAlarm uint32 MinorOpcode uint16 MajorOpcode byte } // Error read SyncAlarm func NewSyncAlarmError(buf []byte) Error { v := SyncAlarmError{} v.NiceName = "SyncAlarm" b := 1 // skip error determinant b += 1 // don't read error number v.Sequence = Get16(buf[b:]) b += 2 v.BadAlarm = Get32(buf[b:]) b += 4 v.MinorOpcode = Get16(buf[b:]) b += 2 v.MajorOpcode = buf[b] b += 1 return v } func (err SyncAlarmError) ImplementsError() {} func (err SyncAlarmError) SequenceId() uint16 { return err.Sequence } func (err SyncAlarmError) BadId() Id { return 0 } func (err SyncAlarmError) Error() string { fieldVals := make([]string, 0, 3) fieldVals = append(fieldVals, "NiceName: "+err.NiceName) fieldVals = append(fieldVals, sprintf("Sequence: %d", err.Sequence)) fieldVals = append(fieldVals, sprintf("BadAlarm: %d", err.BadAlarm)) fieldVals = append(fieldVals, sprintf("MinorOpcode: %d", err.MinorOpcode)) fieldVals = append(fieldVals, sprintf("MajorOpcode: %d", err.MajorOpcode)) return "BadSyncAlarm {" + stringsJoin(fieldVals, ", ") + "}" } func init() { newExtErrorFuncs["SYNC"][1] = NewSyncAlarmError } // Request SyncInitialize // size: 8 type SyncInitializeCookie struct { *cookie } func (c *Conn) SyncInitialize(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) return SyncInitializeCookie{cookie} } func (c *Conn) SyncInitializeUnchecked(DesiredMajorVersion byte, DesiredMinorVersion byte) SyncInitializeCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncInitializeRequest(DesiredMajorVersion, DesiredMinorVersion), cookie) return SyncInitializeCookie{cookie} } // Request reply for SyncInitialize // size: 32 type SyncInitializeReply struct { Sequence uint16 Length uint32 // padding: 1 bytes MajorVersion byte MinorVersion byte // padding: 22 bytes } // Waits and reads reply data from request SyncInitialize func (cook SyncInitializeCookie) Reply() (*SyncInitializeReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncInitializeReply(buf), nil } // Read reply into structure from buffer for SyncInitialize func syncInitializeReply(buf []byte) *SyncInitializeReply { v := new(SyncInitializeReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 v.MajorVersion = buf[b] b += 1 v.MinorVersion = buf[b] b += 1 b += 22 // padding return v } func (cook SyncInitializeCookie) Check() error { return cook.check() } // Write request to wire for SyncInitialize func (c *Conn) syncInitializeRequest(DesiredMajorVersion byte, DesiredMinorVersion byte) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 0 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 buf[b] = DesiredMajorVersion b += 1 buf[b] = DesiredMinorVersion b += 1 return buf } // Request SyncListSystemCounters // size: 4 type SyncListSystemCountersCookie struct { *cookie } func (c *Conn) SyncListSystemCounters() SyncListSystemCountersCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncListSystemCountersRequest(), cookie) return SyncListSystemCountersCookie{cookie} } func (c *Conn) SyncListSystemCountersUnchecked() SyncListSystemCountersCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncListSystemCountersRequest(), cookie) return SyncListSystemCountersCookie{cookie} } // Request reply for SyncListSystemCounters // size: (32 + SyncSystemcounterListSize(Counters)) type SyncListSystemCountersReply struct { Sequence uint16 Length uint32 // padding: 1 bytes CountersLen uint32 // padding: 20 bytes Counters []SyncSystemcounter // size: SyncSystemcounterListSize(Counters) } // Waits and reads reply data from request SyncListSystemCounters func (cook SyncListSystemCountersCookie) Reply() (*SyncListSystemCountersReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncListSystemCountersReply(buf), nil } // Read reply into structure from buffer for SyncListSystemCounters func syncListSystemCountersReply(buf []byte) *SyncListSystemCountersReply { v := new(SyncListSystemCountersReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 v.CountersLen = Get32(buf[b:]) b += 4 b += 20 // padding v.Counters = make([]SyncSystemcounter, v.CountersLen) b += ReadSyncSystemcounterList(buf[b:], v.Counters) return v } func (cook SyncListSystemCountersCookie) Check() error { return cook.check() } // Write request to wire for SyncListSystemCounters func (c *Conn) syncListSystemCountersRequest() []byte { size := 4 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 1 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 return buf } // Request SyncCreateCounter // size: 16 type SyncCreateCounterCookie struct { *cookie } // Write request to wire for SyncCreateCounter func (c *Conn) SyncCreateCounter(Id Id, InitialValue SyncInt64) SyncCreateCounterCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) return SyncCreateCounterCookie{cookie} } func (c *Conn) SyncCreateCounterChecked(Id Id, InitialValue SyncInt64) SyncCreateCounterCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncCreateCounterRequest(Id, InitialValue), cookie) return SyncCreateCounterCookie{cookie} } func (cook SyncCreateCounterCookie) Check() error { return cook.check() } // Write request to wire for SyncCreateCounter func (c *Conn) syncCreateCounterRequest(Id Id, InitialValue SyncInt64) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 2 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Id)) b += 4 { structBytes := InitialValue.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return buf } // Request SyncDestroyCounter // size: 8 type SyncDestroyCounterCookie struct { *cookie } // Write request to wire for SyncDestroyCounter func (c *Conn) SyncDestroyCounter(Counter Id) SyncDestroyCounterCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) return SyncDestroyCounterCookie{cookie} } func (c *Conn) SyncDestroyCounterChecked(Counter Id) SyncDestroyCounterCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncDestroyCounterRequest(Counter), cookie) return SyncDestroyCounterCookie{cookie} } func (cook SyncDestroyCounterCookie) Check() error { return cook.check() } // Write request to wire for SyncDestroyCounter func (c *Conn) syncDestroyCounterRequest(Counter Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 6 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Counter)) b += 4 return buf } // Request SyncQueryCounter // size: 8 type SyncQueryCounterCookie struct { *cookie } func (c *Conn) SyncQueryCounter(Counter Id) SyncQueryCounterCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncQueryCounterRequest(Counter), cookie) return SyncQueryCounterCookie{cookie} } func (c *Conn) SyncQueryCounterUnchecked(Counter Id) SyncQueryCounterCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncQueryCounterRequest(Counter), cookie) return SyncQueryCounterCookie{cookie} } // Request reply for SyncQueryCounter // size: 16 type SyncQueryCounterReply struct { Sequence uint16 Length uint32 // padding: 1 bytes CounterValue SyncInt64 } // Waits and reads reply data from request SyncQueryCounter func (cook SyncQueryCounterCookie) Reply() (*SyncQueryCounterReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncQueryCounterReply(buf), nil } // Read reply into structure from buffer for SyncQueryCounter func syncQueryCounterReply(buf []byte) *SyncQueryCounterReply { v := new(SyncQueryCounterReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 v.CounterValue = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.CounterValue) return v } func (cook SyncQueryCounterCookie) Check() error { return cook.check() } // Write request to wire for SyncQueryCounter func (c *Conn) syncQueryCounterRequest(Counter Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 5 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Counter)) b += 4 return buf } // Request SyncAwait // size: pad((4 + pad((len(WaitList) * 28)))) type SyncAwaitCookie struct { *cookie } // Write request to wire for SyncAwait func (c *Conn) SyncAwait(WaitList []SyncWaitcondition) SyncAwaitCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncAwaitRequest(WaitList), cookie) return SyncAwaitCookie{cookie} } func (c *Conn) SyncAwaitChecked(WaitList []SyncWaitcondition) SyncAwaitCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncAwaitRequest(WaitList), cookie) return SyncAwaitCookie{cookie} } func (cook SyncAwaitCookie) Check() error { return cook.check() } // Write request to wire for SyncAwait func (c *Conn) syncAwaitRequest(WaitList []SyncWaitcondition) []byte { size := pad((4 + pad((len(WaitList) * 28)))) b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 7 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 b += SyncWaitconditionListBytes(buf[b:], WaitList) return buf } // Request SyncChangeCounter // size: 16 type SyncChangeCounterCookie struct { *cookie } // Write request to wire for SyncChangeCounter func (c *Conn) SyncChangeCounter(Counter Id, Amount SyncInt64) SyncChangeCounterCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) return SyncChangeCounterCookie{cookie} } func (c *Conn) SyncChangeCounterChecked(Counter Id, Amount SyncInt64) SyncChangeCounterCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncChangeCounterRequest(Counter, Amount), cookie) return SyncChangeCounterCookie{cookie} } func (cook SyncChangeCounterCookie) Check() error { return cook.check() } // Write request to wire for SyncChangeCounter func (c *Conn) syncChangeCounterRequest(Counter Id, Amount SyncInt64) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 4 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Counter)) b += 4 { structBytes := Amount.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return buf } // Request SyncSetCounter // size: 16 type SyncSetCounterCookie struct { *cookie } // Write request to wire for SyncSetCounter func (c *Conn) SyncSetCounter(Counter Id, Value SyncInt64) SyncSetCounterCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) return SyncSetCounterCookie{cookie} } func (c *Conn) SyncSetCounterChecked(Counter Id, Value SyncInt64) SyncSetCounterCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncSetCounterRequest(Counter, Value), cookie) return SyncSetCounterCookie{cookie} } func (cook SyncSetCounterCookie) Check() error { return cook.check() } // Write request to wire for SyncSetCounter func (c *Conn) syncSetCounterRequest(Counter Id, Value SyncInt64) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 3 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Counter)) b += 4 { structBytes := Value.Bytes() copy(buf[b:], structBytes) b += pad(len(structBytes)) } return buf } // Request SyncCreateAlarm // size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) type SyncCreateAlarmCookie struct { *cookie } // Write request to wire for SyncCreateAlarm func (c *Conn) SyncCreateAlarm(Id Id, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) return SyncCreateAlarmCookie{cookie} } func (c *Conn) SyncCreateAlarmChecked(Id Id, ValueMask uint32, ValueList []uint32) SyncCreateAlarmCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncCreateAlarmRequest(Id, ValueMask, ValueList), cookie) return SyncCreateAlarmCookie{cookie} } func (cook SyncCreateAlarmCookie) Check() error { return cook.check() } // Write request to wire for SyncCreateAlarm func (c *Conn) syncCreateAlarmRequest(Id Id, ValueMask uint32, ValueList []uint32) []byte { size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 8 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Id)) b += 4 Put32(buf[b:], ValueMask) b += 4 for i := 0; i < popCount(int(ValueMask)); i++ { Put32(buf[b:], ValueList[i]) b += 4 } b = pad(b) return buf } // Request SyncChangeAlarm // size: pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) type SyncChangeAlarmCookie struct { *cookie } // Write request to wire for SyncChangeAlarm func (c *Conn) SyncChangeAlarm(Id Id, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) return SyncChangeAlarmCookie{cookie} } func (c *Conn) SyncChangeAlarmChecked(Id Id, ValueMask uint32, ValueList []uint32) SyncChangeAlarmCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncChangeAlarmRequest(Id, ValueMask, ValueList), cookie) return SyncChangeAlarmCookie{cookie} } func (cook SyncChangeAlarmCookie) Check() error { return cook.check() } // Write request to wire for SyncChangeAlarm func (c *Conn) syncChangeAlarmRequest(Id Id, ValueMask uint32, ValueList []uint32) []byte { size := pad((8 + (4 + pad((4 * popCount(int(ValueMask))))))) b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 9 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Id)) b += 4 Put32(buf[b:], ValueMask) b += 4 for i := 0; i < popCount(int(ValueMask)); i++ { Put32(buf[b:], ValueList[i]) b += 4 } b = pad(b) return buf } // Request SyncDestroyAlarm // size: 8 type SyncDestroyAlarmCookie struct { *cookie } // Write request to wire for SyncDestroyAlarm func (c *Conn) SyncDestroyAlarm(Alarm Id) SyncDestroyAlarmCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) return SyncDestroyAlarmCookie{cookie} } func (c *Conn) SyncDestroyAlarmChecked(Alarm Id) SyncDestroyAlarmCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncDestroyAlarmRequest(Alarm), cookie) return SyncDestroyAlarmCookie{cookie} } func (cook SyncDestroyAlarmCookie) Check() error { return cook.check() } // Write request to wire for SyncDestroyAlarm func (c *Conn) syncDestroyAlarmRequest(Alarm Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 11 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Alarm)) b += 4 return buf } // Request SyncQueryAlarm // size: 8 type SyncQueryAlarmCookie struct { *cookie } func (c *Conn) SyncQueryAlarm(Alarm Id) SyncQueryAlarmCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) return SyncQueryAlarmCookie{cookie} } func (c *Conn) SyncQueryAlarmUnchecked(Alarm Id) SyncQueryAlarmCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncQueryAlarmRequest(Alarm), cookie) return SyncQueryAlarmCookie{cookie} } // Request reply for SyncQueryAlarm // size: 40 type SyncQueryAlarmReply struct { Sequence uint16 Length uint32 // padding: 1 bytes Trigger SyncTrigger Delta SyncInt64 Events bool State byte // padding: 2 bytes } // Waits and reads reply data from request SyncQueryAlarm func (cook SyncQueryAlarmCookie) Reply() (*SyncQueryAlarmReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncQueryAlarmReply(buf), nil } // Read reply into structure from buffer for SyncQueryAlarm func syncQueryAlarmReply(buf []byte) *SyncQueryAlarmReply { v := new(SyncQueryAlarmReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 v.Trigger = SyncTrigger{} b += ReadSyncTrigger(buf[b:], &v.Trigger) v.Delta = SyncInt64{} b += ReadSyncInt64(buf[b:], &v.Delta) if buf[b] == 1 { v.Events = true } else { v.Events = false } b += 1 v.State = buf[b] b += 1 b += 2 // padding return v } func (cook SyncQueryAlarmCookie) Check() error { return cook.check() } // Write request to wire for SyncQueryAlarm func (c *Conn) syncQueryAlarmRequest(Alarm Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 10 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Alarm)) b += 4 return buf } // Request SyncSetPriority // size: 12 type SyncSetPriorityCookie struct { *cookie } // Write request to wire for SyncSetPriority func (c *Conn) SyncSetPriority(Id uint32, Priority int32) SyncSetPriorityCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) return SyncSetPriorityCookie{cookie} } func (c *Conn) SyncSetPriorityChecked(Id uint32, Priority int32) SyncSetPriorityCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncSetPriorityRequest(Id, Priority), cookie) return SyncSetPriorityCookie{cookie} } func (cook SyncSetPriorityCookie) Check() error { return cook.check() } // Write request to wire for SyncSetPriority func (c *Conn) syncSetPriorityRequest(Id uint32, Priority int32) []byte { size := 12 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 12 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], Id) b += 4 Put32(buf[b:], uint32(Priority)) b += 4 return buf } // Request SyncGetPriority // size: 8 type SyncGetPriorityCookie struct { *cookie } func (c *Conn) SyncGetPriority(Id uint32) SyncGetPriorityCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncGetPriorityRequest(Id), cookie) return SyncGetPriorityCookie{cookie} } func (c *Conn) SyncGetPriorityUnchecked(Id uint32) SyncGetPriorityCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncGetPriorityRequest(Id), cookie) return SyncGetPriorityCookie{cookie} } // Request reply for SyncGetPriority // size: 12 type SyncGetPriorityReply struct { Sequence uint16 Length uint32 // padding: 1 bytes Priority int32 } // Waits and reads reply data from request SyncGetPriority func (cook SyncGetPriorityCookie) Reply() (*SyncGetPriorityReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncGetPriorityReply(buf), nil } // Read reply into structure from buffer for SyncGetPriority func syncGetPriorityReply(buf []byte) *SyncGetPriorityReply { v := new(SyncGetPriorityReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 v.Priority = int32(Get32(buf[b:])) b += 4 return v } func (cook SyncGetPriorityCookie) Check() error { return cook.check() } // Write request to wire for SyncGetPriority func (c *Conn) syncGetPriorityRequest(Id uint32) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 13 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], Id) b += 4 return buf } // Request SyncCreateFence // size: 16 type SyncCreateFenceCookie struct { *cookie } // Write request to wire for SyncCreateFence func (c *Conn) SyncCreateFence(Drawable Id, Fence Id, InitiallyTriggered bool) SyncCreateFenceCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) return SyncCreateFenceCookie{cookie} } func (c *Conn) SyncCreateFenceChecked(Drawable Id, Fence Id, InitiallyTriggered bool) SyncCreateFenceCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncCreateFenceRequest(Drawable, Fence, InitiallyTriggered), cookie) return SyncCreateFenceCookie{cookie} } func (cook SyncCreateFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncCreateFence func (c *Conn) syncCreateFenceRequest(Drawable Id, Fence Id, InitiallyTriggered bool) []byte { size := 16 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 14 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Drawable)) b += 4 Put32(buf[b:], uint32(Fence)) b += 4 if InitiallyTriggered { buf[b] = 1 } else { buf[b] = 0 } b += 1 return buf } // Request SyncTriggerFence // size: 8 type SyncTriggerFenceCookie struct { *cookie } // Write request to wire for SyncTriggerFence func (c *Conn) SyncTriggerFence(Fence Id) SyncTriggerFenceCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) return SyncTriggerFenceCookie{cookie} } func (c *Conn) SyncTriggerFenceChecked(Fence Id) SyncTriggerFenceCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncTriggerFenceRequest(Fence), cookie) return SyncTriggerFenceCookie{cookie} } func (cook SyncTriggerFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncTriggerFence func (c *Conn) syncTriggerFenceRequest(Fence Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 15 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Fence)) b += 4 return buf } // Request SyncResetFence // size: 8 type SyncResetFenceCookie struct { *cookie } // Write request to wire for SyncResetFence func (c *Conn) SyncResetFence(Fence Id) SyncResetFenceCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncResetFenceRequest(Fence), cookie) return SyncResetFenceCookie{cookie} } func (c *Conn) SyncResetFenceChecked(Fence Id) SyncResetFenceCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncResetFenceRequest(Fence), cookie) return SyncResetFenceCookie{cookie} } func (cook SyncResetFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncResetFence func (c *Conn) syncResetFenceRequest(Fence Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 16 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Fence)) b += 4 return buf } // Request SyncDestroyFence // size: 8 type SyncDestroyFenceCookie struct { *cookie } // Write request to wire for SyncDestroyFence func (c *Conn) SyncDestroyFence(Fence Id) SyncDestroyFenceCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) return SyncDestroyFenceCookie{cookie} } func (c *Conn) SyncDestroyFenceChecked(Fence Id) SyncDestroyFenceCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncDestroyFenceRequest(Fence), cookie) return SyncDestroyFenceCookie{cookie} } func (cook SyncDestroyFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncDestroyFence func (c *Conn) syncDestroyFenceRequest(Fence Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 17 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Fence)) b += 4 return buf } // Request SyncQueryFence // size: 8 type SyncQueryFenceCookie struct { *cookie } func (c *Conn) SyncQueryFence(Fence Id) SyncQueryFenceCookie { cookie := c.newCookie(true, true) c.newRequest(c.syncQueryFenceRequest(Fence), cookie) return SyncQueryFenceCookie{cookie} } func (c *Conn) SyncQueryFenceUnchecked(Fence Id) SyncQueryFenceCookie { cookie := c.newCookie(false, true) c.newRequest(c.syncQueryFenceRequest(Fence), cookie) return SyncQueryFenceCookie{cookie} } // Request reply for SyncQueryFence // size: 32 type SyncQueryFenceReply struct { Sequence uint16 Length uint32 // padding: 1 bytes Triggered bool // padding: 23 bytes } // Waits and reads reply data from request SyncQueryFence func (cook SyncQueryFenceCookie) Reply() (*SyncQueryFenceReply, error) { buf, err := cook.reply() if err != nil { return nil, err } if buf == nil { return nil, nil } return syncQueryFenceReply(buf), nil } // Read reply into structure from buffer for SyncQueryFence func syncQueryFenceReply(buf []byte) *SyncQueryFenceReply { v := new(SyncQueryFenceReply) b := 1 // skip reply determinant b += 1 // padding v.Sequence = Get16(buf[b:]) b += 2 v.Length = Get32(buf[b:]) // 4-byte units b += 4 if buf[b] == 1 { v.Triggered = true } else { v.Triggered = false } b += 1 b += 23 // padding return v } func (cook SyncQueryFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncQueryFence func (c *Conn) syncQueryFenceRequest(Fence Id) []byte { size := 8 b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 18 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 Put32(buf[b:], uint32(Fence)) b += 4 return buf } // Request SyncAwaitFence // size: pad((4 + pad((len(FenceList) * 4)))) type SyncAwaitFenceCookie struct { *cookie } // Write request to wire for SyncAwaitFence func (c *Conn) SyncAwaitFence(FenceList []Id) SyncAwaitFenceCookie { cookie := c.newCookie(false, false) c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) return SyncAwaitFenceCookie{cookie} } func (c *Conn) SyncAwaitFenceChecked(FenceList []Id) SyncAwaitFenceCookie { cookie := c.newCookie(true, false) c.newRequest(c.syncAwaitFenceRequest(FenceList), cookie) return SyncAwaitFenceCookie{cookie} } func (cook SyncAwaitFenceCookie) Check() error { return cook.check() } // Write request to wire for SyncAwaitFence func (c *Conn) syncAwaitFenceRequest(FenceList []Id) []byte { size := pad((4 + pad((len(FenceList) * 4)))) b := 0 buf := make([]byte, size) buf[b] = c.extensions["SYNC"] b += 1 buf[b] = 19 // request opcode b += 1 Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units b += 2 for i := 0; i < int(len(FenceList)); i++ { Put32(buf[b:], uint32(FenceList[i])) b += 4 } b = pad(b) return buf }