From 3e9ed4eac6a953b2616bcf129b515a857271acdc Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 29 Sep 2018 21:42:23 +0200
Subject: xgbgen: process elements
Most of XCB documentation now ends up in Go sources,
although the end result is of mixed quality.
---
nexgb/xgbgen/request_reply.go | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
(limited to 'nexgb/xgbgen/request_reply.go')
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.
--
cgit v1.2.3-70-g09d2