aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2013-12-28 09:33:09 -0500
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:20 +0200
commit2dc9914b5e6b74c353771e56e90dfd2dd33e0202 (patch)
tree8b9c5a460be7a11c23d46be1887ebcaee1eb33b7
parentf0385db3a71c33f19d27dafb2a5d158a8a875200 (diff)
downloadhaven-2dc9914b5e6b74c353771e56e90dfd2dd33e0202.tar.gz
haven-2dc9914b5e6b74c353771e56e90dfd2dd33e0202.tar.xz
haven-2dc9914b5e6b74c353771e56e90dfd2dd33e0202.zip
When writing, don't pad the length of bytes produced from inner
structs/unions. Each type should take care of its own padding. Close #14.
-rw-r--r--nexgb/damage/damage.go4
-rw-r--r--nexgb/randr/randr.go38
-rw-r--r--nexgb/record/record.go18
-rw-r--r--nexgb/render/render.go36
-rw-r--r--nexgb/res/res.go6
-rw-r--r--nexgb/xevie/xevie.go2
-rw-r--r--nexgb/xfixes/xfixes.go2
-rw-r--r--nexgb/xgbgen/go_single_field.go4
-rw-r--r--nexgb/xproto/xproto.go2
-rw-r--r--nexgb/xv/xv.go2
10 files changed, 57 insertions, 57 deletions
diff --git a/nexgb/damage/damage.go b/nexgb/damage/damage.go
index 0ab7668..e94936d 100644
--- a/nexgb/damage/damage.go
+++ b/nexgb/damage/damage.go
@@ -162,13 +162,13 @@ func (v NotifyEvent) Bytes() []byte {
{
structBytes := v.Area.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.Geometry.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
diff --git a/nexgb/randr/randr.go b/nexgb/randr/randr.go
index 11e1230..c7df090 100644
--- a/nexgb/randr/randr.go
+++ b/nexgb/randr/randr.go
@@ -504,15 +504,6 @@ 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
@@ -556,7 +547,7 @@ func (v NotifyEvent) Bytes() []byte {
{
unionBytes := v.U.Bytes()
copy(buf[b:], unionBytes)
- b += xgb.Pad(len(unionBytes))
+ b += len(unionBytes)
}
return buf
@@ -581,6 +572,15 @@ 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).
@@ -608,7 +608,7 @@ func NotifyDataUnionCcNew(Cc CrtcChange) NotifyDataUnion {
{
structBytes := Cc.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -651,7 +651,7 @@ func NotifyDataUnionOcNew(Oc OutputChange) NotifyDataUnion {
{
structBytes := Oc.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -694,7 +694,7 @@ func NotifyDataUnionOpNew(Op OutputProperty) NotifyDataUnion {
{
structBytes := Op.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -737,7 +737,7 @@ func NotifyDataUnionPcNew(Pc ProviderChange) NotifyDataUnion {
{
structBytes := Pc.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -780,7 +780,7 @@ func NotifyDataUnionPpNew(Pp ProviderProperty) NotifyDataUnion {
{
structBytes := Pp.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -823,7 +823,7 @@ func NotifyDataUnionRcNew(Rc ResourceChange) NotifyDataUnion {
{
structBytes := Rc.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
// Create the Union type
@@ -909,7 +909,7 @@ func (v NotifyDataUnion) Bytes() []byte {
{
structBytes := v.Cc.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
}
@@ -2133,7 +2133,7 @@ func createModeRequest(c *xgb.Conn, Window xproto.Window, ModeInfo ModeInfo, Nam
{
structBytes := ModeInfo.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
copy(buf[b:], Name[:len(Name)])
@@ -5139,7 +5139,7 @@ func setCrtcTransformRequest(c *xgb.Conn, Crtc Crtc, Transform render.Transform,
{
structBytes := Transform.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put16(buf[b:], FilterLen)
diff --git a/nexgb/record/record.go b/nexgb/record/record.go
index 2644f13..3777422 100644
--- a/nexgb/record/record.go
+++ b/nexgb/record/record.go
@@ -213,13 +213,13 @@ func (v ExtRange) Bytes() []byte {
{
structBytes := v.Major.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.Minor.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -315,43 +315,43 @@ func (v Range) Bytes() []byte {
{
structBytes := v.CoreRequests.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.CoreReplies.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.ExtRequests.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.ExtReplies.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.DeliveredEvents.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.DeviceEvents.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.Errors.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
if v.ClientStarted {
diff --git a/nexgb/render/render.go b/nexgb/render/render.go
index 7185d18..80f4be7 100644
--- a/nexgb/render/render.go
+++ b/nexgb/render/render.go
@@ -570,13 +570,13 @@ func (v Linefix) Bytes() []byte {
{
structBytes := v.P1.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.P2.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -898,7 +898,7 @@ func (v Pictforminfo) Bytes() []byte {
{
structBytes := v.Direct.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], uint32(v.Colormap))
@@ -1382,13 +1382,13 @@ func (v Trap) Bytes() []byte {
{
structBytes := v.Top.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.Bot.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -1456,13 +1456,13 @@ func (v Trapezoid) Bytes() []byte {
{
structBytes := v.Left.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.Right.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -1520,19 +1520,19 @@ func (v Triangle) Bytes() []byte {
{
structBytes := v.P1.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.P2.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := v.P3.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -2205,7 +2205,7 @@ func createConicalGradientRequest(c *xgb.Conn, Picture Picture, Center Pointfix,
{
structBytes := Center.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], uint32(Angle))
@@ -2402,13 +2402,13 @@ func createLinearGradientRequest(c *xgb.Conn, Picture Picture, P1 Pointfix, P2 P
{
structBytes := P1.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := P2.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], NumStops)
@@ -2549,13 +2549,13 @@ func createRadialGradientRequest(c *xgb.Conn, Picture Picture, Inner Pointfix, O
{
structBytes := Inner.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
{
structBytes := Outer.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], uint32(InnerRadius))
@@ -2633,7 +2633,7 @@ func createSolidFillRequest(c *xgb.Conn, Picture Picture, Color Color) []byte {
{
structBytes := Color.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
@@ -2699,7 +2699,7 @@ func fillRectanglesRequest(c *xgb.Conn, Op byte, Dst Picture, Color Color, Rects
{
structBytes := Color.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
b += xproto.RectangleListBytes(buf[b:], Rects)
@@ -3543,7 +3543,7 @@ func setPictureTransformRequest(c *xgb.Conn, Picture Picture, Transform Transfor
{
structBytes := Transform.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
return buf
diff --git a/nexgb/res/res.go b/nexgb/res/res.go
index 43480ec..59a416a 100644
--- a/nexgb/res/res.go
+++ b/nexgb/res/res.go
@@ -194,7 +194,7 @@ func (v ClientIdValue) Bytes() []byte {
{
structBytes := v.Spec.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], v.Length)
@@ -328,7 +328,7 @@ func (v ResourceSizeSpec) Bytes() []byte {
{
structBytes := v.Spec.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], v.Bytes)
@@ -395,7 +395,7 @@ func (v ResourceSizeValue) Bytes() []byte {
{
structBytes := v.Size.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], v.NumCrossReferences)
diff --git a/nexgb/xevie/xevie.go b/nexgb/xevie/xevie.go
index 6da9158..f77d405 100644
--- a/nexgb/xevie/xevie.go
+++ b/nexgb/xevie/xevie.go
@@ -467,7 +467,7 @@ func sendRequest(c *xgb.Conn, Event Event, DataType uint32) []byte {
{
structBytes := Event.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], DataType)
diff --git a/nexgb/xfixes/xfixes.go b/nexgb/xfixes/xfixes.go
index 0424585..a34df54 100644
--- a/nexgb/xfixes/xfixes.go
+++ b/nexgb/xfixes/xfixes.go
@@ -1801,7 +1801,7 @@ func invertRegionRequest(c *xgb.Conn, Source Region, Bounds xproto.Rectangle, De
{
structBytes := Bounds.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
xgb.Put32(buf[b:], uint32(Destination))
diff --git a/nexgb/xgbgen/go_single_field.go b/nexgb/xgbgen/go_single_field.go
index 3e3fa53..6c7218e 100644
--- a/nexgb/xgbgen/go_single_field.go
+++ b/nexgb/xgbgen/go_single_field.go
@@ -152,13 +152,13 @@ func (f *SingleField) Write(c *Context, prefix string) {
c.Putln("{")
c.Putln("unionBytes := %s%s.Bytes()", prefix, f.SrcName())
c.Putln("copy(buf[b:], unionBytes)")
- c.Putln("b += xgb.Pad(len(unionBytes))")
+ c.Putln("b += len(unionBytes)")
c.Putln("}")
case *Struct:
c.Putln("{")
c.Putln("structBytes := %s%s.Bytes()", prefix, f.SrcName())
c.Putln("copy(buf[b:], structBytes)")
- c.Putln("b += xgb.Pad(len(structBytes))")
+ c.Putln("b += len(structBytes)")
c.Putln("}")
default:
log.Fatalf("Cannot read field '%s' with %T type.", f.XmlName(), f.Type)
diff --git a/nexgb/xproto/xproto.go b/nexgb/xproto/xproto.go
index 9b33030..5579ba9 100644
--- a/nexgb/xproto/xproto.go
+++ b/nexgb/xproto/xproto.go
@@ -886,7 +886,7 @@ func (v ClientMessageEvent) Bytes() []byte {
{
unionBytes := v.Data.Bytes()
copy(buf[b:], unionBytes)
- b += xgb.Pad(len(unionBytes))
+ b += len(unionBytes)
}
return buf
diff --git a/nexgb/xv/xv.go b/nexgb/xv/xv.go
index 5eefe77..d79a594 100644
--- a/nexgb/xv/xv.go
+++ b/nexgb/xv/xv.go
@@ -458,7 +458,7 @@ func (v EncodingInfo) Bytes() []byte {
{
structBytes := v.Rate.Bytes()
copy(buf[b:], structBytes)
- b += xgb.Pad(len(structBytes))
+ b += len(structBytes)
}
copy(buf[b:], v.Name[:v.NameSize])