gofmt
This commit is contained in:
		@@ -1,15 +0,0 @@
 | 
				
			|||||||
package main
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	A buffer count is a mechanism by which to keep track of which byte one
 | 
					 | 
				
			||||||
	is reading or writing to/from the wire.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	It's an abstraction over the fact that while such a counter is usually
 | 
					 | 
				
			||||||
	fixed, it can be made variable based on values at run-time.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type BufCount struct {
 | 
					 | 
				
			||||||
	Fixed int
 | 
					 | 
				
			||||||
	Exprs []*Expression
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@@ -9,7 +9,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type Context struct {
 | 
					type Context struct {
 | 
				
			||||||
	protocol *Protocol
 | 
						protocol *Protocol
 | 
				
			||||||
	out *bytes.Buffer
 | 
						out      *bytes.Buffer
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newContext() *Context {
 | 
					func newContext() *Context {
 | 
				
			||||||
@@ -20,7 +20,7 @@ func newContext() *Context {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Putln calls put and adds a new line to the end of 'format'.
 | 
					// Putln calls put and adds a new line to the end of 'format'.
 | 
				
			||||||
func (c *Context) Putln(format string, v ...interface{}) {
 | 
					func (c *Context) Putln(format string, v ...interface{}) {
 | 
				
			||||||
	c.Put(format + "\n", v...)
 | 
						c.Put(format+"\n", v...)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Put is a short alias to write to 'out'.
 | 
					// Put is a short alias to write to 'out'.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ type Expression interface {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type BinaryOp struct {
 | 
					type BinaryOp struct {
 | 
				
			||||||
	Op string
 | 
						Op    string
 | 
				
			||||||
	Expr1 Expression
 | 
						Expr1 Expression
 | 
				
			||||||
	Expr2 Expression
 | 
						Expr2 Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -23,7 +23,7 @@ func newBinaryOp(op string, expr1, expr2 Expression) Expression {
 | 
				
			|||||||
	switch {
 | 
						switch {
 | 
				
			||||||
	case expr1 != nil && expr2 != nil:
 | 
						case expr1 != nil && expr2 != nil:
 | 
				
			||||||
		return &BinaryOp{
 | 
							return &BinaryOp{
 | 
				
			||||||
			Op: op,
 | 
								Op:    op,
 | 
				
			||||||
			Expr1: expr1,
 | 
								Expr1: expr1,
 | 
				
			||||||
			Expr2: expr2,
 | 
								Expr2: expr2,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -79,7 +79,7 @@ func (e *BinaryOp) Initialize(p *Protocol) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type UnaryOp struct {
 | 
					type UnaryOp struct {
 | 
				
			||||||
	Op string
 | 
						Op   string
 | 
				
			||||||
	Expr Expression
 | 
						Expr Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -159,7 +159,7 @@ func (e *Value) String() string {
 | 
				
			|||||||
	return e.Reduce("", "")
 | 
						return e.Reduce("", "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *Value) Initialize(p *Protocol) { }
 | 
					func (e *Value) Initialize(p *Protocol) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Bit struct {
 | 
					type Bit struct {
 | 
				
			||||||
	b uint
 | 
						b uint
 | 
				
			||||||
@@ -181,7 +181,7 @@ func (e *Bit) String() string {
 | 
				
			|||||||
	return e.Reduce("", "")
 | 
						return e.Reduce("", "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *Bit) Initialize(p *Protocol) { }
 | 
					func (e *Bit) Initialize(p *Protocol) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type FieldRef struct {
 | 
					type FieldRef struct {
 | 
				
			||||||
	Name string
 | 
						Name string
 | 
				
			||||||
@@ -273,4 +273,3 @@ func (e *SumOf) String() string {
 | 
				
			|||||||
func (e *SumOf) Initialize(p *Protocol) {
 | 
					func (e *SumOf) Initialize(p *Protocol) {
 | 
				
			||||||
	e.Name = SrcName(e.Name)
 | 
						e.Name = SrcName(e.Name)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,7 +31,7 @@ func (p *PadField) Size() Size {
 | 
				
			|||||||
type SingleField struct {
 | 
					type SingleField struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Type Type
 | 
						Type    Type
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (f *SingleField) Initialize(p *Protocol) {
 | 
					func (f *SingleField) Initialize(p *Protocol) {
 | 
				
			||||||
@@ -52,9 +52,9 @@ func (f *SingleField) Size() Size {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ListField struct {
 | 
					type ListField struct {
 | 
				
			||||||
	srcName string
 | 
						srcName    string
 | 
				
			||||||
	xmlName string
 | 
						xmlName    string
 | 
				
			||||||
	Type Type
 | 
						Type       Type
 | 
				
			||||||
	LengthExpr Expression
 | 
						LengthExpr Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -85,8 +85,8 @@ type LocalField struct {
 | 
				
			|||||||
type ExprField struct {
 | 
					type ExprField struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Type Type
 | 
						Type    Type
 | 
				
			||||||
	Expr Expression
 | 
						Expr    Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (f *ExprField) SrcName() string {
 | 
					func (f *ExprField) SrcName() string {
 | 
				
			||||||
@@ -132,8 +132,8 @@ func (f *ValueField) Initialize(p *Protocol) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type SwitchField struct {
 | 
					type SwitchField struct {
 | 
				
			||||||
	Name string
 | 
						Name     string
 | 
				
			||||||
	Expr Expression
 | 
						Expr     Expression
 | 
				
			||||||
	Bitcases []*Bitcase
 | 
						Bitcases []*Bitcase
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -165,6 +165,5 @@ func (f *SwitchField) Initialize(p *Protocol) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type Bitcase struct {
 | 
					type Bitcase struct {
 | 
				
			||||||
	Fields []Field
 | 
						Fields []Field
 | 
				
			||||||
	Expr Expression
 | 
						Expr   Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,37 +16,37 @@ var xgbGenResourceIdName = "Id"
 | 
				
			|||||||
// XML protocol description will produce an invalid Go program.
 | 
					// XML protocol description will produce an invalid Go program.
 | 
				
			||||||
// The types on the left *never* show themselves in the source.
 | 
					// The types on the left *never* show themselves in the source.
 | 
				
			||||||
var BaseTypeMap = map[string]string{
 | 
					var BaseTypeMap = map[string]string{
 | 
				
			||||||
	"CARD8": "byte",
 | 
						"CARD8":  "byte",
 | 
				
			||||||
	"CARD16": "uint16",
 | 
						"CARD16": "uint16",
 | 
				
			||||||
	"CARD32": "uint32",
 | 
						"CARD32": "uint32",
 | 
				
			||||||
	"INT8": "int8",
 | 
						"INT8":   "int8",
 | 
				
			||||||
	"INT16": "int16",
 | 
						"INT16":  "int16",
 | 
				
			||||||
	"INT32": "int32",
 | 
						"INT32":  "int32",
 | 
				
			||||||
	"BYTE": "byte",
 | 
						"BYTE":   "byte",
 | 
				
			||||||
	"BOOL": "bool",
 | 
						"BOOL":   "bool",
 | 
				
			||||||
	"float": "float64",
 | 
						"float":  "float64",
 | 
				
			||||||
	"double": "float64",
 | 
						"double": "float64",
 | 
				
			||||||
	"char": "byte",
 | 
						"char":   "byte",
 | 
				
			||||||
	"void": "byte",
 | 
						"void":   "byte",
 | 
				
			||||||
	"Id": "Id",
 | 
						"Id":     "Id",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// BaseTypeSizes should have precisely the same keys as in BaseTypeMap,
 | 
					// BaseTypeSizes should have precisely the same keys as in BaseTypeMap,
 | 
				
			||||||
// and the values should correspond to the size of the type in bytes.
 | 
					// and the values should correspond to the size of the type in bytes.
 | 
				
			||||||
var BaseTypeSizes = map[string]uint{
 | 
					var BaseTypeSizes = map[string]uint{
 | 
				
			||||||
	"CARD8": 1,
 | 
						"CARD8":  1,
 | 
				
			||||||
	"CARD16": 2,
 | 
						"CARD16": 2,
 | 
				
			||||||
	"CARD32": 4,
 | 
						"CARD32": 4,
 | 
				
			||||||
	"INT8": 1,
 | 
						"INT8":   1,
 | 
				
			||||||
	"INT16": 2,
 | 
						"INT16":  2,
 | 
				
			||||||
	"INT32": 4,
 | 
						"INT32":  4,
 | 
				
			||||||
	"BYTE": 1,
 | 
						"BYTE":   1,
 | 
				
			||||||
	"BOOL": 1,
 | 
						"BOOL":   1,
 | 
				
			||||||
	"float": 4,
 | 
						"float":  4,
 | 
				
			||||||
	"double": 8,
 | 
						"double": 8,
 | 
				
			||||||
	"char": 1,
 | 
						"char":   1,
 | 
				
			||||||
	"void": 1,
 | 
						"void":   1,
 | 
				
			||||||
	"Id": 4,
 | 
						"Id":     4,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TypeMap is a map from types in the XML to type names that is used
 | 
					// TypeMap is a map from types in the XML to type names that is used
 | 
				
			||||||
@@ -54,13 +54,13 @@ var BaseTypeSizes = map[string]uint{
 | 
				
			|||||||
// type is replaced with the value type.
 | 
					// type is replaced with the value type.
 | 
				
			||||||
var TypeMap = map[string]string{
 | 
					var TypeMap = map[string]string{
 | 
				
			||||||
	"VISUALTYPE": "VisualInfo",
 | 
						"VISUALTYPE": "VisualInfo",
 | 
				
			||||||
	"DEPTH": "DepthInfo",
 | 
						"DEPTH":      "DepthInfo",
 | 
				
			||||||
	"SCREEN": "ScreenInfo",
 | 
						"SCREEN":     "ScreenInfo",
 | 
				
			||||||
	"Setup": "SetupInfo",
 | 
						"Setup":      "SetupInfo",
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NameMap is the same as TypeMap, but for names.
 | 
					// NameMap is the same as TypeMap, but for names.
 | 
				
			||||||
var NameMap = map[string]string{ }
 | 
					var NameMap = map[string]string{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Reading, writing and defining...
 | 
					// Reading, writing and defining...
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -151,8 +151,8 @@ func (s *Struct) ReadList(c *Context) {
 | 
				
			|||||||
	c.Putln("consumed := 0")
 | 
						c.Putln("consumed := 0")
 | 
				
			||||||
	c.Putln("consumed = 0 + consumed // no-op") // dirty hack for a no-op
 | 
						c.Putln("consumed = 0 + consumed // no-op") // dirty hack for a no-op
 | 
				
			||||||
	c.Putln("for i := 0; i < length; i++ {")
 | 
						c.Putln("for i := 0; i < length; i++ {")
 | 
				
			||||||
		c.Putln("v[i], consumed = New%s(buf[b:])", s.SrcName())
 | 
						c.Putln("v[i], consumed = New%s(buf[b:])", s.SrcName())
 | 
				
			||||||
		c.Putln("b += consumed")
 | 
						c.Putln("b += consumed")
 | 
				
			||||||
	c.Putln("}")
 | 
						c.Putln("}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c.Putln("return v, pad(b)")
 | 
						c.Putln("return v, pad(b)")
 | 
				
			||||||
@@ -347,14 +347,14 @@ func (f *ListField) Read(c *Context) {
 | 
				
			|||||||
		length := f.LengthExpr.Reduce("v.", "")
 | 
							length := f.LengthExpr.Reduce("v.", "")
 | 
				
			||||||
		c.Putln("v.%s = make([]Id, %s)", f.SrcName(), length)
 | 
							c.Putln("v.%s = make([]Id, %s)", f.SrcName(), length)
 | 
				
			||||||
		c.Putln("for i := 0; i < %s; i++ {", length)
 | 
							c.Putln("for i := 0; i < %s; i++ {", length)
 | 
				
			||||||
			ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t)
 | 
							ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t)
 | 
				
			||||||
		c.Putln("}")
 | 
							c.Putln("}")
 | 
				
			||||||
		c.Putln("")
 | 
							c.Putln("")
 | 
				
			||||||
	case *Base:
 | 
						case *Base:
 | 
				
			||||||
		length := f.LengthExpr.Reduce("v.", "")
 | 
							length := f.LengthExpr.Reduce("v.", "")
 | 
				
			||||||
		c.Putln("v.%s = make([]%s, %s)", f.SrcName(), t.SrcName(), length)
 | 
							c.Putln("v.%s = make([]%s, %s)", f.SrcName(), t.SrcName(), length)
 | 
				
			||||||
		c.Putln("for i := 0; i < %s; i++ {", length)
 | 
							c.Putln("for i := 0; i < %s; i++ {", length)
 | 
				
			||||||
			ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t)
 | 
							ReadSimpleSingleField(c, fmt.Sprintf("v.%s[i]", f.SrcName()), t)
 | 
				
			||||||
		c.Putln("}")
 | 
							c.Putln("}")
 | 
				
			||||||
		c.Putln("")
 | 
							c.Putln("")
 | 
				
			||||||
	case *Struct:
 | 
						case *Struct:
 | 
				
			||||||
@@ -408,4 +408,3 @@ func (f *SwitchField) Define(c *Context) {
 | 
				
			|||||||
func (f *SwitchField) Read(c *Context) {
 | 
					func (f *SwitchField) Read(c *Context) {
 | 
				
			||||||
	c.Putln("// reading switch field: %s (%s)", f.Name, f.Expr)
 | 
						c.Putln("// reading switch field: %s (%s)", f.Name, f.Expr)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,4 +62,3 @@ func main() {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,50 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
// Morph cascades down all of the XML and calls each type's corresponding
 | 
					 | 
				
			||||||
// Morph function with itself as an argument (the context).
 | 
					 | 
				
			||||||
func (x *XML) Morph(c *Context) {
 | 
					 | 
				
			||||||
	// Start the header...
 | 
					 | 
				
			||||||
	c.Putln("package xgb")
 | 
					 | 
				
			||||||
	c.Putln("/*")
 | 
					 | 
				
			||||||
	c.Putln("\tX protocol API for '%s.xml'.", c.xml.Header)
 | 
					 | 
				
			||||||
	c.Putln("\tThis file is automatically generated. Edit at your own peril!")
 | 
					 | 
				
			||||||
	c.Putln("\tGenerated on %s",
 | 
					 | 
				
			||||||
		time.Now().Format("Jan 2, 2006 at 3:04:05pm MST"))
 | 
					 | 
				
			||||||
	c.Putln("*/")
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Imports.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Enums.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Xids.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.XidUnions.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.TypeDefs.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Structs.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Unions.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Requests.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Errors.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.ErrorCopies.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.Events.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	x.EventCopies.Morph(c)
 | 
					 | 
				
			||||||
	c.Putln("")
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,14 +1,14 @@
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Protocol struct {
 | 
					type Protocol struct {
 | 
				
			||||||
	Name string
 | 
						Name         string
 | 
				
			||||||
	ExtXName string
 | 
						ExtXName     string
 | 
				
			||||||
	ExtName string
 | 
						ExtName      string
 | 
				
			||||||
	MajorVersion string
 | 
						MajorVersion string
 | 
				
			||||||
	MinorVersion string
 | 
						MinorVersion string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Imports []*Protocol
 | 
						Imports  []*Protocol
 | 
				
			||||||
	Types []Type
 | 
						Types    []Type
 | 
				
			||||||
	Requests []*Request
 | 
						Requests []*Request
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -28,10 +28,10 @@ func (p *Protocol) Initialize() {
 | 
				
			|||||||
type Request struct {
 | 
					type Request struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Opcode int
 | 
						Opcode  int
 | 
				
			||||||
	Combine bool
 | 
						Combine bool
 | 
				
			||||||
	Fields []Field
 | 
						Fields  []Field
 | 
				
			||||||
	Reply *Reply
 | 
						Reply   *Reply
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *Request) Initialize(p *Protocol) {
 | 
					func (r *Request) Initialize(p *Protocol) {
 | 
				
			||||||
@@ -53,4 +53,3 @@ func (r *Reply) Initialize(p *Protocol) {
 | 
				
			|||||||
		field.Initialize(p)
 | 
							field.Initialize(p)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,4 +19,3 @@ func (s1 Size) Add(s2 Size) Size {
 | 
				
			|||||||
func (s1 Size) Multiply(s2 Size) Size {
 | 
					func (s1 Size) Multiply(s2 Size) Size {
 | 
				
			||||||
	return Size{newBinaryOp("*", s1, s2)}
 | 
						return Size{newBinaryOp("*", s1, s2)}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
	translation.go provides a 'Translate' method on every XML type that converts
 | 
						translation.go provides a 'Translate' method on every XML type that converts
 | 
				
			||||||
	the XML type into our "better" representation.
 | 
						the XML type into our "better" representation.
 | 
				
			||||||
@@ -19,14 +20,14 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (xml *XML) Translate() *Protocol {
 | 
					func (xml *XML) Translate() *Protocol {
 | 
				
			||||||
	protocol := &Protocol{
 | 
						protocol := &Protocol{
 | 
				
			||||||
		Name: xml.Header,
 | 
							Name:         xml.Header,
 | 
				
			||||||
		ExtXName: xml.ExtensionXName,
 | 
							ExtXName:     xml.ExtensionXName,
 | 
				
			||||||
		ExtName: xml.ExtensionName,
 | 
							ExtName:      xml.ExtensionName,
 | 
				
			||||||
		MajorVersion: xml.MajorVersion,
 | 
							MajorVersion: xml.MajorVersion,
 | 
				
			||||||
		MinorVersion: xml.MinorVersion,
 | 
							MinorVersion: xml.MinorVersion,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Imports: make([]*Protocol, 0),
 | 
							Imports:  make([]*Protocol, 0),
 | 
				
			||||||
		Types: make([]Type, 0),
 | 
							Types:    make([]Type, 0),
 | 
				
			||||||
		Requests: make([]*Request, len(xml.Requests)),
 | 
							Requests: make([]*Request, len(xml.Requests)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,7 +41,7 @@ func (xml *XML) Translate() *Protocol {
 | 
				
			|||||||
		newBaseType := &Base{
 | 
							newBaseType := &Base{
 | 
				
			||||||
			srcName: srcName,
 | 
								srcName: srcName,
 | 
				
			||||||
			xmlName: xmlName,
 | 
								xmlName: xmlName,
 | 
				
			||||||
			size: newFixedSize(BaseTypeSizes[xmlName]),
 | 
								size:    newFixedSize(BaseTypeSizes[xmlName]),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		protocol.Types = append(protocol.Types, newBaseType)
 | 
							protocol.Types = append(protocol.Types, newBaseType)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -105,12 +106,12 @@ func (xml *XML) Translate() *Protocol {
 | 
				
			|||||||
func (x *XMLEnum) Translate() *Enum {
 | 
					func (x *XMLEnum) Translate() *Enum {
 | 
				
			||||||
	enum := &Enum{
 | 
						enum := &Enum{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Items: make([]*EnumItem, len(x.Items)),
 | 
							Items:   make([]*EnumItem, len(x.Items)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, item := range x.Items {
 | 
						for i, item := range x.Items {
 | 
				
			||||||
		enum.Items[i] = &EnumItem{
 | 
							enum.Items[i] = &EnumItem{
 | 
				
			||||||
			xmlName: item.Name,
 | 
								xmlName: item.Name,
 | 
				
			||||||
			Expr: item.Expr.Translate(),
 | 
								Expr:    item.Expr.Translate(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return enum
 | 
						return enum
 | 
				
			||||||
@@ -125,16 +126,16 @@ func (x *XMLXid) Translate() *Resource {
 | 
				
			|||||||
func (x *XMLTypeDef) Translate() *TypeDef {
 | 
					func (x *XMLTypeDef) Translate() *TypeDef {
 | 
				
			||||||
	return &TypeDef{
 | 
						return &TypeDef{
 | 
				
			||||||
		xmlName: x.New,
 | 
							xmlName: x.New,
 | 
				
			||||||
		Old: newTranslation(x.Old),
 | 
							Old:     newTranslation(x.Old),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (x *XMLEvent) Translate() *Event {
 | 
					func (x *XMLEvent) Translate() *Event {
 | 
				
			||||||
	ev := &Event{
 | 
						ev := &Event{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName:    x.Name,
 | 
				
			||||||
		Number: x.Number,
 | 
							Number:     x.Number,
 | 
				
			||||||
		NoSequence: x.NoSequence,
 | 
							NoSequence: x.NoSequence,
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields:     make([]Field, len(x.Fields)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
		ev.Fields[i] = field.Translate()
 | 
							ev.Fields[i] = field.Translate()
 | 
				
			||||||
@@ -145,16 +146,16 @@ func (x *XMLEvent) Translate() *Event {
 | 
				
			|||||||
func (x *XMLEventCopy) Translate() *EventCopy {
 | 
					func (x *XMLEventCopy) Translate() *EventCopy {
 | 
				
			||||||
	return &EventCopy{
 | 
						return &EventCopy{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Number: x.Number,
 | 
							Number:  x.Number,
 | 
				
			||||||
		Old: newTranslation(x.Ref),
 | 
							Old:     newTranslation(x.Ref),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (x *XMLError) Translate() *Error {
 | 
					func (x *XMLError) Translate() *Error {
 | 
				
			||||||
	err := &Error{
 | 
						err := &Error{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Number: x.Number,
 | 
							Number:  x.Number,
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields:  make([]Field, len(x.Fields)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
		err.Fields[i] = field.Translate()
 | 
							err.Fields[i] = field.Translate()
 | 
				
			||||||
@@ -165,15 +166,15 @@ func (x *XMLError) Translate() *Error {
 | 
				
			|||||||
func (x *XMLErrorCopy) Translate() *ErrorCopy {
 | 
					func (x *XMLErrorCopy) Translate() *ErrorCopy {
 | 
				
			||||||
	return &ErrorCopy{
 | 
						return &ErrorCopy{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Number: x.Number,
 | 
							Number:  x.Number,
 | 
				
			||||||
		Old: newTranslation(x.Ref),
 | 
							Old:     newTranslation(x.Ref),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (x *XMLStruct) Translate() *Struct {
 | 
					func (x *XMLStruct) Translate() *Struct {
 | 
				
			||||||
	s := &Struct{
 | 
						s := &Struct{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields:  make([]Field, len(x.Fields)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
		s.Fields[i] = field.Translate()
 | 
							s.Fields[i] = field.Translate()
 | 
				
			||||||
@@ -184,7 +185,7 @@ func (x *XMLStruct) Translate() *Struct {
 | 
				
			|||||||
func (x *XMLUnion) Translate() *Union {
 | 
					func (x *XMLUnion) Translate() *Union {
 | 
				
			||||||
	u := &Union{
 | 
						u := &Union{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields:  make([]Field, len(x.Fields)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
		u.Fields[i] = field.Translate()
 | 
							u.Fields[i] = field.Translate()
 | 
				
			||||||
@@ -195,10 +196,10 @@ func (x *XMLUnion) Translate() *Union {
 | 
				
			|||||||
func (x *XMLRequest) Translate() *Request {
 | 
					func (x *XMLRequest) Translate() *Request {
 | 
				
			||||||
	r := &Request{
 | 
						r := &Request{
 | 
				
			||||||
		xmlName: x.Name,
 | 
							xmlName: x.Name,
 | 
				
			||||||
		Opcode: x.Opcode,
 | 
							Opcode:  x.Opcode,
 | 
				
			||||||
		Combine: x.Combine,
 | 
							Combine: x.Combine,
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields:  make([]Field, len(x.Fields)),
 | 
				
			||||||
		Reply: x.Reply.Translate(),
 | 
							Reply:   x.Reply.Translate(),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
		r.Fields[i] = field.Translate()
 | 
							r.Fields[i] = field.Translate()
 | 
				
			||||||
@@ -211,7 +212,7 @@ func (x *XMLRequest) Translate() *Request {
 | 
				
			|||||||
	// (i.e., a parameter in the caller but does not get send over the wire.)
 | 
						// (i.e., a parameter in the caller but does not get send over the wire.)
 | 
				
			||||||
	stringLenLocal := &LocalField{&SingleField{
 | 
						stringLenLocal := &LocalField{&SingleField{
 | 
				
			||||||
		xmlName: "string_len",
 | 
							xmlName: "string_len",
 | 
				
			||||||
		Type: newTranslation("CARD16"),
 | 
							Type:    newTranslation("CARD16"),
 | 
				
			||||||
	}}
 | 
						}}
 | 
				
			||||||
	r.Fields = append(r.Fields, stringLenLocal)
 | 
						r.Fields = append(r.Fields, stringLenLocal)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -243,7 +244,7 @@ func (x *XMLExpression) Translate() Expression {
 | 
				
			|||||||
			log.Panicf("'op' found %d expressions; expected 2.", len(x.Exprs))
 | 
								log.Panicf("'op' found %d expressions; expected 2.", len(x.Exprs))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return &BinaryOp{
 | 
							return &BinaryOp{
 | 
				
			||||||
			Op: x.Op,
 | 
								Op:    x.Op,
 | 
				
			||||||
			Expr1: x.Exprs[0].Translate(),
 | 
								Expr1: x.Exprs[0].Translate(),
 | 
				
			||||||
			Expr2: x.Exprs[1].Translate(),
 | 
								Expr2: x.Exprs[1].Translate(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -252,7 +253,7 @@ func (x *XMLExpression) Translate() Expression {
 | 
				
			|||||||
			log.Panicf("'unop' found %d expressions; expected 1.", len(x.Exprs))
 | 
								log.Panicf("'unop' found %d expressions; expected 1.", len(x.Exprs))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return &UnaryOp{
 | 
							return &UnaryOp{
 | 
				
			||||||
			Op: x.Op,
 | 
								Op:   x.Op,
 | 
				
			||||||
			Expr: x.Exprs[0].Translate(),
 | 
								Expr: x.Exprs[0].Translate(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "popcount":
 | 
						case "popcount":
 | 
				
			||||||
@@ -279,7 +280,7 @@ func (x *XMLExpression) Translate() Expression {
 | 
				
			|||||||
				x.Data)
 | 
									x.Data)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if bit < 0 || bit > 31 {
 | 
							if bit < 0 || bit > 31 {
 | 
				
			||||||
			log.Panicf("A 'bit' literal must be in the range [0, 31], but " +
 | 
								log.Panicf("A 'bit' literal must be in the range [0, 31], but "+
 | 
				
			||||||
				" is %d", bit)
 | 
									" is %d", bit)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return &Bit{
 | 
							return &Bit{
 | 
				
			||||||
@@ -300,7 +301,7 @@ func (x *XMLExpression) Translate() Expression {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Panicf("Unrecognized tag '%s' in expression context. Expected one of " +
 | 
						log.Panicf("Unrecognized tag '%s' in expression context. Expected one of "+
 | 
				
			||||||
		"op, fieldref, value, bit, enumref, unop, sumof or popcount.",
 | 
							"op, fieldref, value, bit, enumref, unop, sumof or popcount.",
 | 
				
			||||||
		x.XMLName.Local)
 | 
							x.XMLName.Local)
 | 
				
			||||||
	panic("unreachable")
 | 
						panic("unreachable")
 | 
				
			||||||
@@ -315,24 +316,24 @@ func (x *XMLField) Translate() Field {
 | 
				
			|||||||
	case "field":
 | 
						case "field":
 | 
				
			||||||
		return &SingleField{
 | 
							return &SingleField{
 | 
				
			||||||
			xmlName: x.Name,
 | 
								xmlName: x.Name,
 | 
				
			||||||
			Type: newTranslation(x.Type),
 | 
								Type:    newTranslation(x.Type),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "list":
 | 
						case "list":
 | 
				
			||||||
		return &ListField{
 | 
							return &ListField{
 | 
				
			||||||
			xmlName: x.Name,
 | 
								xmlName:    x.Name,
 | 
				
			||||||
			Type: newTranslation(x.Type),
 | 
								Type:       newTranslation(x.Type),
 | 
				
			||||||
			LengthExpr: x.Expr.Translate(),
 | 
								LengthExpr: x.Expr.Translate(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "localfield":
 | 
						case "localfield":
 | 
				
			||||||
		return &LocalField{&SingleField{
 | 
							return &LocalField{&SingleField{
 | 
				
			||||||
			xmlName: x.Name,
 | 
								xmlName: x.Name,
 | 
				
			||||||
			Type: newTranslation(x.Type),
 | 
								Type:    newTranslation(x.Type),
 | 
				
			||||||
		}}
 | 
							}}
 | 
				
			||||||
	case "exprfield":
 | 
						case "exprfield":
 | 
				
			||||||
		return &ExprField{
 | 
							return &ExprField{
 | 
				
			||||||
			xmlName: x.Name,
 | 
								xmlName: x.Name,
 | 
				
			||||||
			Type: newTranslation(x.Type),
 | 
								Type:    newTranslation(x.Type),
 | 
				
			||||||
			Expr: x.Expr.Translate(),
 | 
								Expr:    x.Expr.Translate(),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "valueparam":
 | 
						case "valueparam":
 | 
				
			||||||
		return &ValueField{
 | 
							return &ValueField{
 | 
				
			||||||
@@ -342,8 +343,8 @@ func (x *XMLField) Translate() Field {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	case "switch":
 | 
						case "switch":
 | 
				
			||||||
		swtch := &SwitchField{
 | 
							swtch := &SwitchField{
 | 
				
			||||||
			Name: x.Name,
 | 
								Name:     x.Name,
 | 
				
			||||||
			Expr: x.Expr.Translate(),
 | 
								Expr:     x.Expr.Translate(),
 | 
				
			||||||
			Bitcases: make([]*Bitcase, len(x.Bitcases)),
 | 
								Bitcases: make([]*Bitcase, len(x.Bitcases)),
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for i, bitcase := range x.Bitcases {
 | 
							for i, bitcase := range x.Bitcases {
 | 
				
			||||||
@@ -358,7 +359,7 @@ func (x *XMLField) Translate() Field {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (x *XMLBitcase) Translate() *Bitcase {
 | 
					func (x *XMLBitcase) Translate() *Bitcase {
 | 
				
			||||||
	b := &Bitcase{
 | 
						b := &Bitcase{
 | 
				
			||||||
		Expr: x.Expr().Translate(),
 | 
							Expr:   x.Expr().Translate(),
 | 
				
			||||||
		Fields: make([]Field, len(x.Fields)),
 | 
							Fields: make([]Field, len(x.Fields)),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for i, field := range x.Fields {
 | 
						for i, field := range x.Fields {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -77,7 +77,7 @@ func (t *Translation) Initialize(p *Protocol) {
 | 
				
			|||||||
type Base struct {
 | 
					type Base struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	size Size
 | 
						size    Size
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (b *Base) SrcName() string {
 | 
					func (b *Base) SrcName() string {
 | 
				
			||||||
@@ -99,13 +99,13 @@ func (b *Base) Initialize(p *Protocol) {
 | 
				
			|||||||
type Enum struct {
 | 
					type Enum struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Items []*EnumItem
 | 
						Items   []*EnumItem
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type EnumItem struct {
 | 
					type EnumItem struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Expr Expression
 | 
						Expr    Expression
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (enum *Enum) SrcName() string {
 | 
					func (enum *Enum) SrcName() string {
 | 
				
			||||||
@@ -154,7 +154,7 @@ func (r *Resource) Initialize(p *Protocol) {
 | 
				
			|||||||
type TypeDef struct {
 | 
					type TypeDef struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Old Type
 | 
						Old     Type
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (t *TypeDef) SrcName() string {
 | 
					func (t *TypeDef) SrcName() string {
 | 
				
			||||||
@@ -175,11 +175,11 @@ func (t *TypeDef) Initialize(p *Protocol) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Event struct {
 | 
					type Event struct {
 | 
				
			||||||
	srcName string
 | 
						srcName    string
 | 
				
			||||||
	xmlName string
 | 
						xmlName    string
 | 
				
			||||||
	Number int
 | 
						Number     int
 | 
				
			||||||
	NoSequence bool
 | 
						NoSequence bool
 | 
				
			||||||
	Fields []Field
 | 
						Fields     []Field
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *Event) SrcName() string {
 | 
					func (e *Event) SrcName() string {
 | 
				
			||||||
@@ -208,8 +208,8 @@ func (e *Event) EvType() string {
 | 
				
			|||||||
type EventCopy struct {
 | 
					type EventCopy struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Old Type
 | 
						Old     Type
 | 
				
			||||||
	Number int
 | 
						Number  int
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *EventCopy) SrcName() string {
 | 
					func (e *EventCopy) SrcName() string {
 | 
				
			||||||
@@ -239,8 +239,8 @@ func (e *EventCopy) EvType() string {
 | 
				
			|||||||
type Error struct {
 | 
					type Error struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Number int
 | 
						Number  int
 | 
				
			||||||
	Fields []Field
 | 
						Fields  []Field
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *Error) SrcName() string {
 | 
					func (e *Error) SrcName() string {
 | 
				
			||||||
@@ -270,8 +270,8 @@ func (e *Error) ErrType() string {
 | 
				
			|||||||
type ErrorCopy struct {
 | 
					type ErrorCopy struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Old Type
 | 
						Old     Type
 | 
				
			||||||
	Number int
 | 
						Number  int
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (e *ErrorCopy) SrcName() string {
 | 
					func (e *ErrorCopy) SrcName() string {
 | 
				
			||||||
@@ -305,7 +305,7 @@ func (e *ErrorCopy) ErrType() string {
 | 
				
			|||||||
type Struct struct {
 | 
					type Struct struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Fields []Field
 | 
						Fields  []Field
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *Struct) SrcName() string {
 | 
					func (s *Struct) SrcName() string {
 | 
				
			||||||
@@ -334,7 +334,7 @@ func (s *Struct) Initialize(p *Protocol) {
 | 
				
			|||||||
type Union struct {
 | 
					type Union struct {
 | 
				
			||||||
	srcName string
 | 
						srcName string
 | 
				
			||||||
	xmlName string
 | 
						xmlName string
 | 
				
			||||||
	Fields []Field
 | 
						Fields  []Field
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (u *Union) SrcName() string {
 | 
					func (u *Union) SrcName() string {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,29 +8,29 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type XML struct {
 | 
					type XML struct {
 | 
				
			||||||
	// Root 'xcb' element properties.
 | 
						// Root 'xcb' element properties.
 | 
				
			||||||
	XMLName xml.Name `xml:"xcb"`
 | 
						XMLName        xml.Name `xml:"xcb"`
 | 
				
			||||||
	Header string `xml:"header,attr"`
 | 
						Header         string   `xml:"header,attr"`
 | 
				
			||||||
	ExtensionXName string `xml:"extension-xname,attr"`
 | 
						ExtensionXName string   `xml:"extension-xname,attr"`
 | 
				
			||||||
	ExtensionName string `xml:"extension-name,attr"`
 | 
						ExtensionName  string   `xml:"extension-name,attr"`
 | 
				
			||||||
	MajorVersion string `xml:"major-version,attr"`
 | 
						MajorVersion   string   `xml:"major-version,attr"`
 | 
				
			||||||
	MinorVersion string `xml:"minor-version,attr"`
 | 
						MinorVersion   string   `xml:"minor-version,attr"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Types for all top-level elements.
 | 
						// Types for all top-level elements.
 | 
				
			||||||
	// First are the simple ones.
 | 
						// First are the simple ones.
 | 
				
			||||||
	Imports XMLImports `xml:"import"`
 | 
						Imports     XMLImports     `xml:"import"`
 | 
				
			||||||
	Enums XMLEnums `xml:"enum"`
 | 
						Enums       XMLEnums       `xml:"enum"`
 | 
				
			||||||
	Xids XMLXids `xml:"xidtype"`
 | 
						Xids        XMLXids        `xml:"xidtype"`
 | 
				
			||||||
	XidUnions XMLXids `xml:"xidunion"`
 | 
						XidUnions   XMLXids        `xml:"xidunion"`
 | 
				
			||||||
	TypeDefs XMLTypeDefs `xml:"typedef"`
 | 
						TypeDefs    XMLTypeDefs    `xml:"typedef"`
 | 
				
			||||||
	EventCopies XMLEventCopies `xml:"eventcopy"`
 | 
						EventCopies XMLEventCopies `xml:"eventcopy"`
 | 
				
			||||||
	ErrorCopies XMLErrorCopies `xml:"errorcopy"`
 | 
						ErrorCopies XMLErrorCopies `xml:"errorcopy"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Here are the complex ones, i.e., anything with "structure contents"
 | 
						// Here are the complex ones, i.e., anything with "structure contents"
 | 
				
			||||||
	Structs XMLStructs `xml:"struct"`
 | 
						Structs  XMLStructs  `xml:"struct"`
 | 
				
			||||||
	Unions XMLUnions `xml:"union"`
 | 
						Unions   XMLUnions   `xml:"union"`
 | 
				
			||||||
	Requests XMLRequests `xml:"request"`
 | 
						Requests XMLRequests `xml:"request"`
 | 
				
			||||||
	Events XMLEvents `xml:"event"`
 | 
						Events   XMLEvents   `xml:"event"`
 | 
				
			||||||
	Errors XMLErrors `xml:"error"`
 | 
						Errors   XMLErrors   `xml:"error"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLImports []*XMLImport
 | 
					type XMLImports []*XMLImport
 | 
				
			||||||
@@ -39,14 +39,14 @@ func (imports XMLImports) Eval() {
 | 
				
			|||||||
	for _, imp := range imports {
 | 
						for _, imp := range imports {
 | 
				
			||||||
		xmlBytes, err := ioutil.ReadFile(*protoPath + "/" + imp.Name + ".xml")
 | 
							xmlBytes, err := ioutil.ReadFile(*protoPath + "/" + imp.Name + ".xml")
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Fatalf("Could not read X protocol description for import " +
 | 
								log.Fatalf("Could not read X protocol description for import "+
 | 
				
			||||||
				"'%s' because: %s", imp.Name, err)
 | 
									"'%s' because: %s", imp.Name, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		imp.xml = &XML{}
 | 
							imp.xml = &XML{}
 | 
				
			||||||
		err = xml.Unmarshal(xmlBytes, imp.xml)
 | 
							err = xml.Unmarshal(xmlBytes, imp.xml)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			log.Fatal("Could not parse X protocol description for import " +
 | 
								log.Fatal("Could not parse X protocol description for import "+
 | 
				
			||||||
				"'%s' because: %s", imp.Name, err)
 | 
									"'%s' because: %s", imp.Name, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -57,18 +57,18 @@ func (imports XMLImports) Eval() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type XMLImport struct {
 | 
					type XMLImport struct {
 | 
				
			||||||
	Name string `xml:",chardata"`
 | 
						Name string `xml:",chardata"`
 | 
				
			||||||
	xml *XML `xml:"-"`
 | 
						xml  *XML   `xml:"-"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLEnums []XMLEnum
 | 
					type XMLEnums []XMLEnum
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLEnum struct {
 | 
					type XMLEnum struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name  string         `xml:"name,attr"`
 | 
				
			||||||
	Items []*XMLEnumItem `xml:"item"`
 | 
						Items []*XMLEnumItem `xml:"item"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLEnumItem struct {
 | 
					type XMLEnumItem struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name string         `xml:"name,attr"`
 | 
				
			||||||
	Expr *XMLExpression `xml:",any"`
 | 
						Expr *XMLExpression `xml:",any"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,7 +76,7 @@ type XMLXids []*XMLXid
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type XMLXid struct {
 | 
					type XMLXid struct {
 | 
				
			||||||
	XMLName xml.Name
 | 
						XMLName xml.Name
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name    string `xml:"name,attr"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLTypeDefs []*XMLTypeDef
 | 
					type XMLTypeDefs []*XMLTypeDef
 | 
				
			||||||
@@ -89,41 +89,41 @@ type XMLTypeDef struct {
 | 
				
			|||||||
type XMLEventCopies []*XMLEventCopy
 | 
					type XMLEventCopies []*XMLEventCopy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLEventCopy struct {
 | 
					type XMLEventCopy struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name   string `xml:"name,attr"`
 | 
				
			||||||
	Number int `xml:"number,attr"`
 | 
						Number int    `xml:"number,attr"`
 | 
				
			||||||
	Ref string `xml:"ref,attr"`
 | 
						Ref    string `xml:"ref,attr"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLErrorCopies []*XMLErrorCopy
 | 
					type XMLErrorCopies []*XMLErrorCopy
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLErrorCopy struct {
 | 
					type XMLErrorCopy struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name   string `xml:"name,attr"`
 | 
				
			||||||
	Number int `xml:"number,attr"`
 | 
						Number int    `xml:"number,attr"`
 | 
				
			||||||
	Ref string `xml:"ref,attr"`
 | 
						Ref    string `xml:"ref,attr"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLStructs []*XMLStruct
 | 
					type XMLStructs []*XMLStruct
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLStruct struct {
 | 
					type XMLStruct struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name   string    `xml:"name,attr"`
 | 
				
			||||||
	Fields XMLFields `xml:",any"`
 | 
						Fields XMLFields `xml:",any"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLUnions []*XMLUnion
 | 
					type XMLUnions []*XMLUnion
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLUnion struct {
 | 
					type XMLUnion struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name   string    `xml:"name,attr"`
 | 
				
			||||||
	Fields XMLFields `xml:",any"`
 | 
						Fields XMLFields `xml:",any"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLRequests []*XMLRequest
 | 
					type XMLRequests []*XMLRequest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLRequest struct {
 | 
					type XMLRequest struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name    string    `xml:"name,attr"`
 | 
				
			||||||
	Opcode int `xml:"opcode,attr"`
 | 
						Opcode  int       `xml:"opcode,attr"`
 | 
				
			||||||
	Combine bool `xml:"combine-adjacent,attr"`
 | 
						Combine bool      `xml:"combine-adjacent,attr"`
 | 
				
			||||||
	Fields XMLFields `xml:",any"`
 | 
						Fields  XMLFields `xml:",any"`
 | 
				
			||||||
	Reply *XMLReply `xml:"reply"`
 | 
						Reply   *XMLReply `xml:"reply"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLReply struct {
 | 
					type XMLReply struct {
 | 
				
			||||||
@@ -133,17 +133,16 @@ type XMLReply struct {
 | 
				
			|||||||
type XMLEvents []*XMLEvent
 | 
					type XMLEvents []*XMLEvent
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLEvent struct {
 | 
					type XMLEvent struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name       string    `xml:"name,attr"`
 | 
				
			||||||
	Number int `xml:"number,attr"`
 | 
						Number     int       `xml:"number,attr"`
 | 
				
			||||||
	NoSequence bool `xml:"no-sequence-number,true"`
 | 
						NoSequence bool      `xml:"no-sequence-number,true"`
 | 
				
			||||||
	Fields XMLFields `xml:",any"`
 | 
						Fields     XMLFields `xml:",any"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLErrors []*XMLError
 | 
					type XMLErrors []*XMLError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type XMLError struct {
 | 
					type XMLError struct {
 | 
				
			||||||
	Name string `xml:"name,attr"`
 | 
						Name   string    `xml:"name,attr"`
 | 
				
			||||||
	Number int `xml:"number,attr"`
 | 
						Number int       `xml:"number,attr"`
 | 
				
			||||||
	Fields XMLFields `xml:",any"`
 | 
						Fields XMLFields `xml:",any"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,14 +13,14 @@ type XMLExpression struct {
 | 
				
			|||||||
	Exprs []*XMLExpression `xml:",any"`
 | 
						Exprs []*XMLExpression `xml:",any"`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Data string `xml:",chardata"`
 | 
						Data string `xml:",chardata"`
 | 
				
			||||||
	Op string `xml:"op,attr"`
 | 
						Op   string `xml:"op,attr"`
 | 
				
			||||||
	Ref string `xml:"ref,attr"`
 | 
						Ref  string `xml:"ref,attr"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newValueExpression(v uint) *XMLExpression {
 | 
					func newValueExpression(v uint) *XMLExpression {
 | 
				
			||||||
	return &XMLExpression{
 | 
						return &XMLExpression{
 | 
				
			||||||
		XMLName: xml.Name{Local: "value"},
 | 
							XMLName: xml.Name{Local: "value"},
 | 
				
			||||||
		Data: fmt.Sprintf("%d", v),
 | 
							Data:    fmt.Sprintf("%d", v),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -87,22 +87,22 @@ func (e *XMLExpression) Eval() uint {
 | 
				
			|||||||
				e.Data)
 | 
									e.Data)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if bit < 0 || bit > 31 {
 | 
							if bit < 0 || bit > 31 {
 | 
				
			||||||
			log.Panicf("A 'bit' literal must be in the range [0, 31], but " +
 | 
								log.Panicf("A 'bit' literal must be in the range [0, 31], but "+
 | 
				
			||||||
				" is %d", bit)
 | 
									" is %d", bit)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return 1 << uint(bit)
 | 
							return 1 << uint(bit)
 | 
				
			||||||
	case "fieldref":
 | 
						case "fieldref":
 | 
				
			||||||
		log.Panicf("Cannot compute concrete value of 'fieldref' in " +
 | 
							log.Panicf("Cannot compute concrete value of 'fieldref' in "+
 | 
				
			||||||
			"expression '%s'.", e)
 | 
								"expression '%s'.", e)
 | 
				
			||||||
	case "enumref":
 | 
						case "enumref":
 | 
				
			||||||
		log.Panicf("Cannot compute concrete value of 'enumref' in " +
 | 
							log.Panicf("Cannot compute concrete value of 'enumref' in "+
 | 
				
			||||||
			"expression '%s'.", e)
 | 
								"expression '%s'.", e)
 | 
				
			||||||
	case "sumof":
 | 
						case "sumof":
 | 
				
			||||||
		log.Panicf("Cannot compute concrete value of 'sumof' in " +
 | 
							log.Panicf("Cannot compute concrete value of 'sumof' in "+
 | 
				
			||||||
			"expression '%s'.", e)
 | 
								"expression '%s'.", e)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Panicf("Unrecognized tag '%s' in expression context. Expected one of " +
 | 
						log.Panicf("Unrecognized tag '%s' in expression context. Expected one of "+
 | 
				
			||||||
		"op, fieldref, value, bit, enumref, unop, sumof or popcount.",
 | 
							"op, fieldref, value, bit, enumref, unop, sumof or popcount.",
 | 
				
			||||||
		e.XMLName.Local)
 | 
							e.XMLName.Local)
 | 
				
			||||||
	panic("unreachable")
 | 
						panic("unreachable")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
	A series of fields should be taken as "structure contents", and *not*
 | 
						A series of fields should be taken as "structure contents", and *not*
 | 
				
			||||||
	just the single 'field' elements. Namely, 'fields' subsumes 'field'
 | 
						just the single 'field' elements. Namely, 'fields' subsumes 'field'
 | 
				
			||||||
@@ -50,8 +51,8 @@ type XMLField struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// I don't know which elements these are for. The documentation is vague.
 | 
						// I don't know which elements these are for. The documentation is vague.
 | 
				
			||||||
	// They also seem to be completely optional.
 | 
						// They also seem to be completely optional.
 | 
				
			||||||
	OptEnum string `xml:"enum,attr"`
 | 
						OptEnum    string `xml:"enum,attr"`
 | 
				
			||||||
	OptMask string `xml:"mask,attr"`
 | 
						OptMask    string `xml:"mask,attr"`
 | 
				
			||||||
	OptAltEnum string `xml:"altenum,attr"`
 | 
						OptAltEnum string `xml:"altenum,attr"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -103,14 +104,14 @@ type XMLBitcase struct {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// All the different expressions.
 | 
						// All the different expressions.
 | 
				
			||||||
	// When it comes time to choose one, use the 'Expr' method.
 | 
						// When it comes time to choose one, use the 'Expr' method.
 | 
				
			||||||
	ExprOp *XMLExpression `xml:"op"`
 | 
						ExprOp    *XMLExpression `xml:"op"`
 | 
				
			||||||
	ExprUnOp *XMLExpression `xml:"unop"`
 | 
						ExprUnOp  *XMLExpression `xml:"unop"`
 | 
				
			||||||
	ExprField *XMLExpression `xml:"fieldref"`
 | 
						ExprField *XMLExpression `xml:"fieldref"`
 | 
				
			||||||
	ExprValue *XMLExpression `xml:"value"`
 | 
						ExprValue *XMLExpression `xml:"value"`
 | 
				
			||||||
	ExprBit *XMLExpression `xml:"bit"`
 | 
						ExprBit   *XMLExpression `xml:"bit"`
 | 
				
			||||||
	ExprEnum *XMLExpression `xml:"enumref"`
 | 
						ExprEnum  *XMLExpression `xml:"enumref"`
 | 
				
			||||||
	ExprSum *XMLExpression `xml:"sumof"`
 | 
						ExprSum   *XMLExpression `xml:"sumof"`
 | 
				
			||||||
	ExprPop *XMLExpression `xml:"popcount"`
 | 
						ExprPop   *XMLExpression `xml:"popcount"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StringPrefix is for debugging purposes only.
 | 
					// StringPrefix is for debugging purposes only.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user