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]
for _, mode := range resources.Modes {
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 {
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 {
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:
r = append(r, &PadField{0, 4})
}
case *LocalField:
// nothing
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
}
r = append(r, fields[i])
}
return r
}
@ -75,22 +76,16 @@ func xcbSizeOfField(fld Field) int {
switch f := fld.(type) {
case *PadField:
return int(f.Bytes)
case *SingleField:
return xcbSizeOfType(f.Type)
case *ListField:
return 0
case *ExprField:
return xcbSizeOfType(f.Type)
case *ValueField:
return xcbSizeOfType(f.MaskType)
case *SwitchField:
return 0
default:
return 0
}
@ -100,20 +95,16 @@ func xcbSizeOfType(typ Type) int {
switch t := typ.(type) {
case *Resource:
return 4
case *TypeDef:
return t.Size().Eval()
case *Base:
return t.Size().Eval()
case *Struct:
sz := 0
for i := range t.Fields {
sz += xcbSizeOfField(t.Fields[i])
}
return sz
case *Union:
sz := 0
for i := range t.Fields {
@ -123,7 +114,6 @@ func xcbSizeOfType(typ Type) int {
}
}
return sz
default:
return 0
}

View File

@ -155,7 +155,8 @@ func (r *Request) WriteRequest(c *Context) {
return
}
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("// Write request to wire for %s", r.SrcName())