• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2013-2020 The Khronos Group Inc.
2# SPDX-License-Identifier: Apache-2.0
3
4# Relax NG schema for Khronos Registry XML
5# See https://www.github.com/KhronosGroup/EGL-Registry
6#
7# Last modified 2017/02/03
8# This definition is subject to change (mostly in the form of additions)
9
10namespace xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
11
12# Toplevel is a <registry> tag.
13# May be led by an optional <comment> tag containing e.g. copyrights.
14start = element registry {
15    (
16        element comment { text } ? |
17        Types      * |
18        Groups     * |
19        Enums      * |
20        Commands   * |
21        Feature    * |
22        Extensions *
23    ) *
24}
25
26# <types> defines a group of types
27Types = element types {
28    Type *
29}
30
31# <type> defines a single type. It is usually a C typedef but
32# may contain arbitrary C code.
33#   name - name of this type, if not present in the <name> tag
34#   api - matches a <feature> api attribute, if present
35#   requires - name of another type definition required by this one
36#   type - "group", if present, indicating a group of values in the
37#       corresponding <enums> definition.
38#   comment - unused
39#   <apientry /> - substitutes for an APIENTRY-style macro on output
40#   <name> - contains typename
41Type = element type {
42    attribute api { text } ? ,
43    attribute requires { text } ? ,
44    attribute name { TypeName } ? ,
45    attribute type { text } ? ,
46    Comment ? ,
47    text ,
48    element apientry { text } ? ,
49    text ,
50    element name { TypeName } ? ,
51    text
52}
53
54# <groups> defines a group of enum groups
55Groups = element groups {
56    Group *
57}
58
59# <group> defines a single enum group. Enums may
60# be in multiple groups.
61#   name - group name
62#   comment - unused
63#   <enum name=""> - members of the group
64
65Group = element group {
66    Name ,
67    Comment ? ,
68    element enum { Name } *
69}
70
71# <enums> defines a group of enumerants
72#   namespace - identifies a numeric namespace
73#   group - identifies a functional subset of the namespace - same as <group name="">
74#   start, end - beginning and end of a numeric range in the namespace
75#   vendor - owner of the numeric range
76#   type - "bitmask", if present
77#   comment - unused
78Enums = element enums {
79    attribute namespace { text } ? ,
80    attribute group { text } ? ,
81    attribute type { text } ? ,
82    attribute start { Integer } ? ,
83    attribute end { Integer } ? ,
84    Vendor ? ,
85    Comment ? ,
86    (Enum | Unused) *
87}
88# <enum> defines a single enumerant
89#   value - integer (including hex) value of the enumerant
90#   api - matches a <feature> api attribute, if present
91#   type - "u" (unsigned), "ull" (uint64), or integer if not present
92#   name - enumerant name
93#   alias - another enumerant this is semantically identical to
94#   comment - unused
95Enum = element enum {
96    (
97        attribute value { Integer } &
98        attribute api { text } ? &
99        attribute type { TypeSuffix } ? &
100        attribute name { text } &
101        attribute alias { text } ? &
102        Comment ?
103    )
104}
105# <unused> defines a range of enumerants not currently being used
106#   start, end - beginning and end of an unused numeric range
107#   vendor - unused
108#   comment - unused
109Unused = element unused {
110    attribute start { Integer } ,
111    attribute end { Integer } ? ,
112    Vendor ? ,
113    Comment ?
114}
115# <commands> defines a group of commands
116#   namespace - identifies a function namespace
117Commands = element commands {
118    attribute namespace { text } ? ,
119    Command *
120}
121# <command> defines a single command
122#   <proto> is the C function prototype, including the return type
123#   <param> are function parameters, in order
124#     <ptype> is a <type> name, if present
125#     <name> is the function / parameter name
126# The textual contents of <proto> and <param> should be legal C
127# for those parts of a function declaration.
128#   <alias> - denotes function aliasing
129#     name - name of aliased function
130#   <vecequiv> - denotes scalar / vector function equivalence
131#     name - name of corresponding vector form, e.g. (glColor3f -> glColor3fv)
132#   <glx> - information about GLX protocol
133#     type - "render", "single", or "vendor" for GLXRender, GLXSingle, GLXVendorPrivate{WithReply}
134#     opcode - numeric opcode of specified type for this function
135#     name - if present, protocol name (defaults to command name)
136#     comment - unused
137Command = element command {
138    Comment ? ,
139    element proto {
140        attribute group { text } ? ,
141        text ,
142        element ptype { TypeName } ? ,
143        text ,
144        element name { text } ,
145        text
146    } ,
147    element param {
148        attribute group { text } ? ,
149        attribute len { text } ? ,
150        text ,
151        element ptype { TypeName } ? ,
152        text ,
153        element name { text } ,
154        text
155    } * ,
156    (
157        element alias {
158            Name
159        } ? &
160        element vecequiv {
161            Name
162        } ? &
163        element glx {
164            attribute type { text } ,
165            attribute opcode { xsd:integer } ,
166            Name ? ,
167            Comment ?
168        } *
169    )
170}
171# Each <feature> defines the interface of an API version (e.g. OpenGL 1.2)
172#   api - API tag (e.g. 'gl', 'gles2', etc. - used internally, not
173#     neccessarily an actual API name
174#   name - version name (C preprocessor name, e.g. GL_VERSION_4_2)
175#   number - version number, e.g. 4.2
176#   protect - additional #ifdef symbol to place around the feature
177#   <require> / <remove> contains features to require or remove in
178#                        this version
179#     profile - only require/remove when generated profile matches
180#     comment - unused
181Feature = element feature {
182    attribute api { text } ,
183    Name ,
184    attribute number { xsd:float } ,
185    attribute protect { text } ?,
186    Comment ? ,
187    (
188        element require {
189            ProfileName ? ,
190            Comment ? ,
191            InterfaceElement *
192        } |
193        element remove {
194            ProfileName ? ,
195            Comment ? ,
196            InterfaceElement *
197        }
198    ) *
199}
200Extensions = element extensions {
201    Extension *
202}
203# Defines the interface of an API <extension>. Like a <feature>
204# tag, but with a slightly different api attribute.
205#   api - regexp pattern matching one or more API tags, indicating
206#     which APIs the extension is known to work with. The only
207#     syntax supported is <name>{|<name>}* and each name must
208#     exactly match an API being generated (implicit ^$ surrounding).
209# In addition, <require> / <remove> tags also support an
210# api attribute:
211#     api - only require/remove these features for the matching API.
212#       Not a regular expression.
213Extension = element extension {
214    Name ,
215    attribute protect { text } ?,
216    attribute supported { StringGroup } ? ,
217    Comment ? ,
218    (
219        element require {
220            attribute api { text } ? ,
221            ProfileName ? ,
222            Comment ? ,
223            InterfaceElement *
224        } |
225        element remove {
226            attribute api { text } ? ,
227            ProfileName ? ,
228            Comment ? ,
229            InterfaceElement *
230        }
231    ) *
232}
233# Contents of a <require> / <remove> tag, defining a group
234# of features to require or remove.
235#   <type> / <enum> / <command> all have attributes
236#     name - feature name which must match
237InterfaceElement =
238    element type {
239        Name ,
240        Comment ?
241    } |
242    element enum {
243        Name ,
244        Comment ?
245    } |
246    element command {
247        Name ,
248        Comment ?
249    }
250
251# Integers are allowed to be either decimal or C-hex (0x[0-9A-F]+), but
252# XML Schema types don't seem to support hex notation, so we use this
253# as a placeholder.
254Integer = text
255
256# TypeName is an argument/return value C type name
257TypeName = text
258
259# TypeSuffix is a C numeric type suffix, e.g. 'u' or 'ull'
260TypeSuffix = text
261
262# StringGroup is a regular expression with an implicit
263#   '^(' and ')$' bracketing it.
264StringGroup = text
265
266# Repeatedly used attributes
267ProfileName = attribute profile { text }
268Vendor = attribute vendor { text }
269Comment = attribute comment { text }
270Name = attribute name { text }
271