diff options
Diffstat (limited to 'nexgb/xgbgen/aligngap.go')
-rw-r--r-- | nexgb/xgbgen/aligngap.go | 24 |
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 } |