xgbgen: process <doc> elements

Most of XCB documentation now ends up in Go sources,
although the end result is of mixed quality.
This commit is contained in:
2018-09-29 21:42:23 +02:00
parent 0056720d05
commit 3e9ed4eac6
9 changed files with 187 additions and 24 deletions

View File

@@ -6,6 +6,22 @@ import (
"unicode"
)
// Doc contains any documentation, if present. Example C code is excluded.
type Doc struct {
Brief string // short description
Description string // long description
Fields map[string]string // from field name to description
Errors map[string]string // from error type to description
}
// DescribeField is an accessor that supports nil receivers.
func (d *Doc) DescribeField(name string) string {
if d == nil {
return ""
}
return d.Fields[name]
}
// Request represents all XML 'request' nodes.
// If the request doesn't have a reply, Reply is nil.
type Request struct {
@@ -15,6 +31,7 @@ type Request struct {
Combine bool // Not currently used.
Fields []Field // All fields in the request.
Reply *Reply // A reply, if one exists for this request.
Doc Doc // Documentation.
}
type Requests []*Request
@@ -126,6 +143,7 @@ func (r *Request) Size(c *Context) Size {
// Reply encapsulates the fields associated with a 'reply' element.
type Reply struct {
Fields []Field
Doc Doc
}
// Size gets the number of bytes in this request's reply.