aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/aligngap.go
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2014-05-10 11:41:51 -0400
committerPřemysl Janouch <p@janouch.name>2018-09-08 16:49:23 +0200
commitef8155bf17787473a58f00d54cfc8a7e16ee8708 (patch)
treec88a5feea3e109f82587ac76fd44cd2acd0ca68a /nexgb/xgbgen/aligngap.go
parenta548d9d0f7b889627c43b18811357fad88760b2d (diff)
downloadhaven-ef8155bf17787473a58f00d54cfc8a7e16ee8708.tar.gz
haven-ef8155bf17787473a58f00d54cfc8a7e16ee8708.tar.xz
haven-ef8155bf17787473a58f00d54cfc8a7e16ee8708.zip
Formatting and 80 cols.
Diffstat (limited to 'nexgb/xgbgen/aligngap.go')
-rw-r--r--nexgb/xgbgen/aligngap.go24
1 files changed, 7 insertions, 17 deletions
diff --git a/nexgb/xgbgen/aligngap.go b/nexgb/xgbgen/aligngap.go
index 1e07e18..0cd7ac4 100644
--- a/nexgb/xgbgen/aligngap.go
+++ b/nexgb/xgbgen/aligngap.go
@@ -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
}