Formatting and 80 cols.

This commit is contained in:
Andrew Gallant 2014-05-10 11:41:51 -04:00 committed by Přemysl Janouch
parent a548d9d0f7
commit ef8155bf17
Signed by: p
GPG Key ID: A0420B94F92B9493
3 changed files with 11 additions and 19 deletions

View File

@ -49,7 +49,8 @@ func main() {
bestMode := info.Modes[0] bestMode := info.Modes[0]
for _, mode := range resources.Modes { for _, mode := range resources.Modes {
if mode.Id == uint32(bestMode) { if mode.Id == uint32(bestMode) {
fmt.Printf("Width: %d, Height: %d\n", mode.Width, mode.Height) fmt.Printf("Width: %d, Height: %d\n",
mode.Width, mode.Height)
} }
} }
} }

View File

@ -20,9 +20,11 @@ func (p *Protocol) AddAlignGaps() {
} }
} }
for i := range p.Requests { for i := range p.Requests {
p.Requests[i].Fields = addAlignGapsToFields(p.Requests[i].xmlName, p.Requests[i].Fields) p.Requests[i].Fields = addAlignGapsToFields(
p.Requests[i].xmlName, p.Requests[i].Fields)
if p.Requests[i].Reply != nil { if p.Requests[i].Reply != nil {
p.Requests[i].Reply.Fields = addAlignGapsToFields(p.Requests[i].xmlName, p.Requests[i].Reply.Fields) p.Requests[i].Reply.Fields = addAlignGapsToFields(
p.Requests[i].xmlName, p.Requests[i].Reply.Fields)
} }
} }
} }
@ -57,17 +59,16 @@ func addAlignGapsToFields(name string, fields []Field) []Field {
case sz >= 4: case sz >= 4:
r = append(r, &PadField{0, 4}) r = append(r, &PadField{0, 4})
} }
case *LocalField: case *LocalField:
// nothing // nothing
default: default:
fmt.Fprintf(os.Stderr, "Can't add alignment gaps, mix of list and non-list fields: %s\n", name) fmt.Fprintf(os.Stderr,
"Can't add alignment gaps, mix of list and non-list "+
"fields: %s\n", name)
return fields return fields
} }
r = append(r, fields[i]) r = append(r, fields[i])
} }
return r return r
} }
@ -75,22 +76,16 @@ func xcbSizeOfField(fld Field) int {
switch f := fld.(type) { switch f := fld.(type) {
case *PadField: case *PadField:
return int(f.Bytes) return int(f.Bytes)
case *SingleField: case *SingleField:
return xcbSizeOfType(f.Type) return xcbSizeOfType(f.Type)
case *ListField: case *ListField:
return 0 return 0
case *ExprField: case *ExprField:
return xcbSizeOfType(f.Type) return xcbSizeOfType(f.Type)
case *ValueField: case *ValueField:
return xcbSizeOfType(f.MaskType) return xcbSizeOfType(f.MaskType)
case *SwitchField: case *SwitchField:
return 0 return 0
default: default:
return 0 return 0
} }
@ -100,20 +95,16 @@ func xcbSizeOfType(typ Type) int {
switch t := typ.(type) { switch t := typ.(type) {
case *Resource: case *Resource:
return 4 return 4
case *TypeDef: case *TypeDef:
return t.Size().Eval() return t.Size().Eval()
case *Base: case *Base:
return t.Size().Eval() return t.Size().Eval()
case *Struct: case *Struct:
sz := 0 sz := 0
for i := range t.Fields { for i := range t.Fields {
sz += xcbSizeOfField(t.Fields[i]) sz += xcbSizeOfField(t.Fields[i])
} }
return sz return sz
case *Union: case *Union:
sz := 0 sz := 0
for i := range t.Fields { for i := range t.Fields {
@ -123,7 +114,6 @@ func xcbSizeOfType(typ Type) int {
} }
} }
return sz return sz
default: default:
return 0 return 0
} }

View File

@ -155,7 +155,8 @@ func (r *Request) WriteRequest(c *Context) {
return return
} }
c.Putln("b = xgb.Pad(b)") c.Putln("b = xgb.Pad(b)")
c.Putln("xgb.Put16(buf[blen:], uint16(b / 4)) // write request size in 4-byte units") c.Putln("xgb.Put16(buf[blen:], uint16(b / 4)) " +
"// write request size in 4-byte units")
c.Putln("return buf[:b]") c.Putln("return buf[:b]")
} }
c.Putln("// Write request to wire for %s", r.SrcName()) c.Putln("// Write request to wire for %s", r.SrcName())