aboutsummaryrefslogtreecommitdiff
path: root/nexgb/xgbgen/request_reply.go
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2018-09-29 21:42:23 +0200
committerPřemysl Janouch <p@janouch.name>2018-09-30 17:34:26 +0200
commit3e9ed4eac6a953b2616bcf129b515a857271acdc (patch)
treeb7e674aa21fe3044eec6071e0d990c3933ba5f0d /nexgb/xgbgen/request_reply.go
parent0056720d05d72d7b3a1b3cbdae5b5c5d80e167d3 (diff)
downloadhaven-3e9ed4eac6a953b2616bcf129b515a857271acdc.tar.gz
haven-3e9ed4eac6a953b2616bcf129b515a857271acdc.tar.xz
haven-3e9ed4eac6a953b2616bcf129b515a857271acdc.zip
xgbgen: process <doc> elements
Most of XCB documentation now ends up in Go sources, although the end result is of mixed quality.
Diffstat (limited to 'nexgb/xgbgen/request_reply.go')
-rw-r--r--nexgb/xgbgen/request_reply.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/nexgb/xgbgen/request_reply.go b/nexgb/xgbgen/request_reply.go
index 5032e31..ab3d9d3 100644
--- a/nexgb/xgbgen/request_reply.go
+++ b/nexgb/xgbgen/request_reply.go
@@ -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.