It appears that the "Str" type (which is built into the core X protocol)

doesn't specify any padding. So it has to be treated as a special case.

Close #12.
This commit is contained in:
Andrew Gallant 2013-12-28 10:02:18 -05:00 committed by Přemysl Janouch
parent ad9c35a02f
commit 33509dbeb0
Signed by: p
GPG Key ID: A0420B94F92B9493
10 changed files with 52 additions and 49 deletions

View File

@ -562,7 +562,7 @@ func connectReply(buf []byte) *ConnectReply {
byteString := make([]byte, v.DriverNameLength)
copy(byteString[:v.DriverNameLength], buf[b:])
v.DriverName = string(byteString)
b += xgb.Pad(int(v.DriverNameLength))
b += int(v.DriverNameLength)
}
v.AlignmentPad = make([]byte, (((int(v.DriverNameLength) + 3) & -4) - int(v.DriverNameLength)))
@ -573,7 +573,7 @@ func connectReply(buf []byte) *ConnectReply {
byteString := make([]byte, v.DeviceNameLength)
copy(byteString[:v.DeviceNameLength], buf[b:])
v.DeviceName = string(byteString)
b += xgb.Pad(int(v.DeviceNameLength))
b += int(v.DeviceNameLength)
}
return v

View File

@ -6885,7 +6885,7 @@ func getStringReply(buf []byte) *GetStringReply {
byteString := make([]byte, v.N)
copy(byteString[:v.N], buf[b:])
v.String = string(byteString)
b += xgb.Pad(int(v.N))
b += int(v.N)
}
return v
@ -9174,7 +9174,7 @@ func queryServerStringReply(buf []byte) *QueryServerStringReply {
byteString := make([]byte, v.StrLen)
copy(byteString[:v.StrLen], buf[b:])
v.String = string(byteString)
b += xgb.Pad(int(v.StrLen))
b += int(v.StrLen)
}
return v

View File

@ -504,6 +504,15 @@ func ModeInfoListBytes(buf []byte, list []ModeInfo) int {
return xgb.Pad(b)
}
const (
NotifyCrtcChange = 0
NotifyOutputChange = 1
NotifyOutputProperty = 2
NotifyProviderChange = 3
NotifyProviderProperty = 4
NotifyResourceChange = 5
)
// Notify is the event number for a NotifyEvent.
const Notify = 1
@ -572,15 +581,6 @@ func init() {
xgb.NewExtEventFuncs["RANDR"][1] = NotifyEventNew
}
const (
NotifyCrtcChange = 0
NotifyOutputChange = 1
NotifyOutputProperty = 2
NotifyProviderChange = 3
NotifyProviderProperty = 4
NotifyResourceChange = 5
)
// NotifyDataUnion is a represention of the NotifyDataUnion union type.
// Note that to *create* a Union, you should *never* create
// this struct directly (unless you know what you're doing).
@ -2826,7 +2826,7 @@ func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply {
byteString := make([]byte, v.PendingLen)
copy(byteString[:v.PendingLen], buf[b:])
v.PendingFilterName = string(byteString)
b += xgb.Pad(int(v.PendingLen))
b += int(v.PendingLen)
}
v.PendingParams = make([]render.Fixed, v.PendingNparams)
@ -2840,7 +2840,7 @@ func getCrtcTransformReply(buf []byte) *GetCrtcTransformReply {
byteString := make([]byte, v.CurrentLen)
copy(byteString[:v.CurrentLen], buf[b:])
v.CurrentFilterName = string(byteString)
b += xgb.Pad(int(v.CurrentLen))
b += int(v.CurrentLen)
}
v.CurrentParams = make([]render.Fixed, v.CurrentNparams)
@ -3518,7 +3518,7 @@ func getProviderInfoReply(buf []byte) *GetProviderInfoReply {
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameLen))
b += int(v.NameLen)
}
return v

View File

@ -659,7 +659,7 @@ func getClientDriverNameReply(buf []byte) *GetClientDriverNameReply {
byteString := make([]byte, v.ClientDriverNameLen)
copy(byteString[:v.ClientDriverNameLen], buf[b:])
v.ClientDriverName = string(byteString)
b += xgb.Pad(int(v.ClientDriverNameLen))
b += int(v.ClientDriverNameLen)
}
return v
@ -1017,7 +1017,7 @@ func openConnectionReply(buf []byte) *OpenConnectionReply {
byteString := make([]byte, v.BusIdLen)
copy(byteString[:v.BusIdLen], buf[b:])
v.BusId = string(byteString)
b += xgb.Pad(int(v.BusIdLen))
b += int(v.BusIdLen)
}
return v

View File

@ -1543,7 +1543,7 @@ func getMonitorReply(buf []byte) *GetMonitorReply {
byteString := make([]byte, v.VendorLength)
copy(byteString[:v.VendorLength], buf[b:])
v.Vendor = string(byteString)
b += xgb.Pad(int(v.VendorLength))
b += int(v.VendorLength)
}
v.AlignmentPad = make([]byte, (((int(v.VendorLength) + 3) & -4) - int(v.VendorLength)))
@ -1554,7 +1554,7 @@ func getMonitorReply(buf []byte) *GetMonitorReply {
byteString := make([]byte, v.ModelLength)
copy(byteString[:v.ModelLength], buf[b:])
v.Model = string(byteString)
b += xgb.Pad(int(v.ModelLength))
b += int(v.ModelLength)
}
return v

View File

@ -1495,7 +1495,7 @@ func getCursorImageAndNameReply(buf []byte) *GetCursorImageAndNameReply {
byteString := make([]byte, v.Nbytes)
copy(byteString[:v.Nbytes], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.Nbytes))
b += int(v.Nbytes)
}
v.CursorImage = make([]uint32, (int(v.Width) * int(v.Height)))
@ -1602,7 +1602,7 @@ func getCursorNameReply(buf []byte) *GetCursorNameReply {
byteString := make([]byte, v.Nbytes)
copy(byteString[:v.Nbytes], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.Nbytes))
b += int(v.Nbytes)
}
return v

View File

@ -29,7 +29,10 @@ func (f *ListField) Read(c *Context, prefix string) {
c.Putln("byteString := make([]%s, %s)", t.SrcName(), length)
c.Putln("copy(byteString[:%s], buf[b:])", length)
c.Putln("%s%s = string(byteString)", prefix, f.SrcName())
c.Putln("b += xgb.Pad(int(%s))", length)
// This is apparently a special case. The "Str" type itself
// doesn't specify any padding. I suppose it's up to the
// request/reply spec that uses it to get the padding right?
c.Putln("b += int(%s)", length)
c.Putln("}")
} else if t.SrcName() == "byte" {
c.Putln("%s%s = make([]%s, %s)",

View File

@ -5404,7 +5404,7 @@ func SetupAuthenticateRead(buf []byte, v *SetupAuthenticate) int {
byteString := make([]byte, (int(v.Length) * 4))
copy(byteString[:(int(v.Length)*4)], buf[b:])
v.Reason = string(byteString)
b += xgb.Pad(int((int(v.Length) * 4)))
b += int((int(v.Length) * 4))
}
return b
@ -5492,7 +5492,7 @@ func SetupFailedRead(buf []byte, v *SetupFailed) int {
byteString := make([]byte, v.ReasonLen)
copy(byteString[:v.ReasonLen], buf[b:])
v.Reason = string(byteString)
b += xgb.Pad(int(v.ReasonLen))
b += int(v.ReasonLen)
}
return b
@ -5647,7 +5647,7 @@ func SetupInfoRead(buf []byte, v *SetupInfo) int {
byteString := make([]byte, v.VendorLen)
copy(byteString[:v.VendorLen], buf[b:])
v.Vendor = string(byteString)
b += xgb.Pad(int(v.VendorLen))
b += int(v.VendorLen)
}
v.PixmapFormats = make([]Format, v.PixmapFormatsLen)
@ -5802,14 +5802,14 @@ func SetupRequestRead(buf []byte, v *SetupRequest) int {
byteString := make([]byte, v.AuthorizationProtocolNameLen)
copy(byteString[:v.AuthorizationProtocolNameLen], buf[b:])
v.AuthorizationProtocolName = string(byteString)
b += xgb.Pad(int(v.AuthorizationProtocolNameLen))
b += int(v.AuthorizationProtocolNameLen)
}
{
byteString := make([]byte, v.AuthorizationProtocolDataLen)
copy(byteString[:v.AuthorizationProtocolDataLen], buf[b:])
v.AuthorizationProtocolData = string(byteString)
b += xgb.Pad(int(v.AuthorizationProtocolDataLen))
b += int(v.AuthorizationProtocolDataLen)
}
return b
@ -5903,7 +5903,7 @@ func StrRead(buf []byte, v *Str) int {
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameLen))
b += int(v.NameLen)
}
return b
@ -9036,7 +9036,7 @@ func getAtomNameReply(buf []byte) *GetAtomNameReply {
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameLen))
b += int(v.NameLen)
}
return v
@ -11406,7 +11406,7 @@ func listFontsWithInfoReply(buf []byte) *ListFontsWithInfoReply {
byteString := make([]byte, v.NameLen)
copy(byteString[:v.NameLen], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameLen))
b += int(v.NameLen)
}
return v

View File

@ -62,14 +62,14 @@ func ListItemRead(buf []byte, v *ListItem) int {
byteString := make([]byte, v.ObjectContextLen)
copy(byteString[:v.ObjectContextLen], buf[b:])
v.ObjectContext = string(byteString)
b += xgb.Pad(int(v.ObjectContextLen))
b += int(v.ObjectContextLen)
}
{
byteString := make([]byte, v.DataContextLen)
copy(byteString[:v.DataContextLen], buf[b:])
v.DataContext = string(byteString)
b += xgb.Pad(int(v.DataContextLen))
b += int(v.DataContextLen)
}
return b
@ -224,7 +224,7 @@ func getClientContextReply(buf []byte) *GetClientContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -323,7 +323,7 @@ func getDeviceContextReply(buf []byte) *GetDeviceContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -422,7 +422,7 @@ func getDeviceCreateContextReply(buf []byte) *GetDeviceCreateContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -518,7 +518,7 @@ func getPropertyContextReply(buf []byte) *GetPropertyContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -620,7 +620,7 @@ func getPropertyCreateContextReply(buf []byte) *GetPropertyCreateContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -716,7 +716,7 @@ func getPropertyDataContextReply(buf []byte) *GetPropertyDataContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -818,7 +818,7 @@ func getPropertyUseContextReply(buf []byte) *GetPropertyUseContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -914,7 +914,7 @@ func getSelectionContextReply(buf []byte) *GetSelectionContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -1013,7 +1013,7 @@ func getSelectionCreateContextReply(buf []byte) *GetSelectionCreateContextReply
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -1109,7 +1109,7 @@ func getSelectionDataContextReply(buf []byte) *GetSelectionDataContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -1208,7 +1208,7 @@ func getSelectionUseContextReply(buf []byte) *GetSelectionUseContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -1304,7 +1304,7 @@ func getWindowContextReply(buf []byte) *GetWindowContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v
@ -1403,7 +1403,7 @@ func getWindowCreateContextReply(buf []byte) *GetWindowCreateContextReply {
byteString := make([]byte, v.ContextLen)
copy(byteString[:v.ContextLen], buf[b:])
v.Context = string(byteString)
b += xgb.Pad(int(v.ContextLen))
b += int(v.ContextLen)
}
return v

View File

@ -74,7 +74,7 @@ func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int {
byteString := make([]byte, v.NameSize)
copy(byteString[:v.NameSize], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameSize))
b += int(v.NameSize)
}
v.Formats = make([]Format, v.NumFormats)
@ -177,7 +177,7 @@ func AttributeInfoRead(buf []byte, v *AttributeInfo) int {
byteString := make([]byte, v.Size)
copy(byteString[:v.Size], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.Size))
b += int(v.Size)
}
return b
@ -420,7 +420,7 @@ func EncodingInfoRead(buf []byte, v *EncodingInfo) int {
byteString := make([]byte, v.NameSize)
copy(byteString[:v.NameSize], buf[b:])
v.Name = string(byteString)
b += xgb.Pad(int(v.NameSize))
b += int(v.NameSize)
}
return b