lots of docs and examples
This commit is contained in:
@@ -86,7 +86,7 @@ func (c *Context) Morph(xmlBytes []byte) {
|
||||
c.Putln("case err != nil:")
|
||||
c.Putln("return err")
|
||||
c.Putln("case !reply.Present:")
|
||||
c.Putln("return newError(\"No extension named %s could be found on " +
|
||||
c.Putln("return newError(\"No extension named %s could be found on "+
|
||||
"on the server.\")", xname)
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
|
||||
@@ -220,7 +220,7 @@ func (f *ExprField) Initialize(p *Protocol) {
|
||||
// integers. The mask specifies which kinds of values are in the list.
|
||||
// (i.e., See ConfigureWindow, CreateWindow, ChangeWindowAttributes, etc.)
|
||||
type ValueField struct {
|
||||
Parent interface{}
|
||||
Parent interface{}
|
||||
MaskType Type
|
||||
MaskName string
|
||||
ListName string
|
||||
@@ -247,7 +247,7 @@ func (f *ValueField) Size() Size {
|
||||
listSize := newExpressionSize(&Function{
|
||||
Name: "pad",
|
||||
Expr: &BinaryOp{
|
||||
Op: "*",
|
||||
Op: "*",
|
||||
Expr1: &Value{v: 4},
|
||||
Expr2: &PopCount{
|
||||
Expr: &Function{
|
||||
|
||||
@@ -133,7 +133,7 @@ func (e *ErrorCopy) ImplementsError(c *Context) {
|
||||
func ErrorFieldString(c *Context, fields []Field, errName string) {
|
||||
c.Putln("fieldVals := make([]string, 0, %d)", len(fields))
|
||||
c.Putln("fieldVals = append(fieldVals, \"NiceName: \" + err.NiceName)")
|
||||
c.Putln("fieldVals = append(fieldVals, " +
|
||||
c.Putln("fieldVals = append(fieldVals, "+
|
||||
"sprintf(\"Sequence: %s\", err.Sequence))", "%d")
|
||||
for _, field := range fields {
|
||||
switch field.(type) {
|
||||
|
||||
@@ -165,7 +165,7 @@ func (e *EventCopy) Write(c *Context) {
|
||||
func EventFieldString(c *Context, fields []Field, evName string) {
|
||||
c.Putln("fieldVals := make([]string, 0, %d)", len(fields))
|
||||
if evName != "KeymapNotify" {
|
||||
c.Putln("fieldVals = append(fieldVals, " +
|
||||
c.Putln("fieldVals = append(fieldVals, "+
|
||||
"sprintf(\"Sequence: %s\", v.Sequence))", "%d")
|
||||
}
|
||||
for _, field := range fields {
|
||||
@@ -177,7 +177,8 @@ func EventFieldString(c *Context, fields []Field, evName string) {
|
||||
case *Base:
|
||||
case *Resource:
|
||||
case *TypeDef:
|
||||
default: continue
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
||||
switch field.SrcType() {
|
||||
|
||||
@@ -107,4 +107,3 @@ func (f *ListField) Write(c *Context, prefix string) {
|
||||
f.XmlName(), f.Type)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,14 +71,14 @@ func (r *Request) ReadReply(c *Context) {
|
||||
c.Putln("// Waits and reads reply data from request %s", r.SrcName())
|
||||
c.Putln("func (cook %s) Reply() (*%s, error) {",
|
||||
r.CookieName(), r.ReplyTypeName())
|
||||
c.Putln("buf, err := cook.reply()")
|
||||
c.Putln("if err != nil {")
|
||||
c.Putln("return nil, err")
|
||||
c.Putln("}")
|
||||
c.Putln("if buf == nil {")
|
||||
c.Putln("return nil, nil")
|
||||
c.Putln("}")
|
||||
c.Putln("return %s(buf), nil", r.ReplyName())
|
||||
c.Putln("buf, err := cook.reply()")
|
||||
c.Putln("if err != nil {")
|
||||
c.Putln("return nil, err")
|
||||
c.Putln("}")
|
||||
c.Putln("if buf == nil {")
|
||||
c.Putln("return nil, nil")
|
||||
c.Putln("}")
|
||||
c.Putln("return %s(buf), nil", r.ReplyName())
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
|
||||
@@ -107,7 +107,7 @@ func (r *Request) ReadReply(c *Context) {
|
||||
|
||||
func (r *Request) WriteRequest(c *Context) {
|
||||
writeSize := func() {
|
||||
c.Putln("Put16(buf[b:], uint16(size / 4)) "+
|
||||
c.Putln("Put16(buf[b:], uint16(size / 4)) " +
|
||||
"// write request size in 4-byte units")
|
||||
c.Putln("b += 2")
|
||||
c.Putln("")
|
||||
|
||||
@@ -139,4 +139,3 @@ func (u *Union) WriteListSize(c *Context) {
|
||||
c.Putln("}")
|
||||
c.Putln("")
|
||||
}
|
||||
|
||||
|
||||
@@ -38,4 +38,3 @@ func (p *Protocol) Initialize() {
|
||||
func (p *Protocol) isExt() bool {
|
||||
return strings.ToLower(p.Name) != "xproto"
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ type Request struct {
|
||||
srcName string // The Go name of this request.
|
||||
xmlName string // The XML name of this request.
|
||||
Opcode int
|
||||
Combine bool // Not currently used.
|
||||
Combine bool // Not currently used.
|
||||
Fields []Field // All fields in the request.
|
||||
Reply *Reply // A reply, if one exists for this request.
|
||||
Reply *Reply // A reply, if one exists for this request.
|
||||
}
|
||||
|
||||
// Initialize creates the proper Go source name for this request.
|
||||
|
||||
@@ -339,7 +339,7 @@ func (x *XMLField) Translate(parent interface{}) Field {
|
||||
}
|
||||
case "valueparam":
|
||||
return &ValueField{
|
||||
Parent: parent,
|
||||
Parent: parent,
|
||||
MaskType: newTranslation(x.ValueMaskType),
|
||||
MaskName: x.ValueMaskName,
|
||||
ListName: x.ValueListName,
|
||||
|
||||
@@ -17,11 +17,11 @@ type XML struct {
|
||||
|
||||
// Types for all top-level elements.
|
||||
// First are the simple ones.
|
||||
Imports XMLImports `xml:"import"`
|
||||
Enums []*XMLEnum `xml:"enum"`
|
||||
Xids []*XMLXid `xml:"xidtype"`
|
||||
XidUnions []*XMLXid `xml:"xidunion"`
|
||||
TypeDefs []*XMLTypeDef `xml:"typedef"`
|
||||
Imports XMLImports `xml:"import"`
|
||||
Enums []*XMLEnum `xml:"enum"`
|
||||
Xids []*XMLXid `xml:"xidtype"`
|
||||
XidUnions []*XMLXid `xml:"xidunion"`
|
||||
TypeDefs []*XMLTypeDef `xml:"typedef"`
|
||||
EventCopies []*XMLEventCopy `xml:"eventcopy"`
|
||||
ErrorCopies []*XMLErrorCopy `xml:"errorcopy"`
|
||||
|
||||
@@ -93,21 +93,21 @@ type XMLErrorCopy struct {
|
||||
}
|
||||
|
||||
type XMLStruct struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Fields []*XMLField `xml:",any"`
|
||||
}
|
||||
|
||||
type XMLUnion struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Fields []*XMLField `xml:",any"`
|
||||
}
|
||||
|
||||
type XMLRequest struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Opcode int `xml:"opcode,attr"`
|
||||
Combine bool `xml:"combine-adjacent,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Opcode int `xml:"opcode,attr"`
|
||||
Combine bool `xml:"combine-adjacent,attr"`
|
||||
Fields []*XMLField `xml:",any"`
|
||||
Reply *XMLReply `xml:"reply"`
|
||||
Reply *XMLReply `xml:"reply"`
|
||||
}
|
||||
|
||||
type XMLReply struct {
|
||||
@@ -115,15 +115,15 @@ type XMLReply struct {
|
||||
}
|
||||
|
||||
type XMLEvent struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Number int `xml:"number,attr"`
|
||||
NoSequence bool `xml:"no-sequence-number,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Number int `xml:"number,attr"`
|
||||
NoSequence bool `xml:"no-sequence-number,attr"`
|
||||
Fields []*XMLField `xml:",any"`
|
||||
}
|
||||
|
||||
type XMLError struct {
|
||||
Name string `xml:"name,attr"`
|
||||
Number int `xml:"number,attr"`
|
||||
Name string `xml:"name,attr"`
|
||||
Number int `xml:"number,attr"`
|
||||
Fields []*XMLField `xml:",any"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user