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://github.com/KhronosGroup/OpenGL-Registry 6# 7# Last modified 2013/06/14 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="" 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# group - identifies a functional subset of the namespace 94# alias - another enumerant this is semantically identical to 95# comment - unused 96Enum = element enum { 97 ( 98 attribute value { Integer } & 99 attribute api { text } ? & 100 attribute type { TypeSuffix } ? & 101 attribute name { text } & 102 attribute group { text } ? & 103 attribute alias { text } ? & 104 Comment ? 105 ) 106} 107# <unused> defines a range of enumerants not currently being used 108# start, end - beginning and end of an unused numeric range 109# vendor - unused 110# comment - unused 111Unused = element unused { 112 attribute start { Integer } , 113 attribute end { Integer } ? , 114 Vendor ? , 115 Comment ? 116} 117# <commands> defines a group of commands 118# namespace - identifies a function namespace 119Commands = element commands { 120 attribute namespace { text } ? , 121 Command * 122} 123# <command> defines a single command 124# <proto> is the C function prototype, including the return type 125# <param> are function parameters, in order 126# class - type of object name (object handle). Handles with different types are not compatible. So handle created as [class=buffer] can not be passed to [class=shader] 127# <ptype> is a <type> name, if present 128# <name> is the function / parameter name 129# The textual contents of <proto> and <param> should be legal C 130# for those parts of a function declaration. 131# <alias> - denotes function aliasing 132# name - name of aliased function 133# <vecequiv> - denotes scalar / vector function equivalence 134# name - name of corresponding vector form, e.g. (glColor3f -> glColor3fv) 135# <glx> - information about GLX protocol 136# type - "render", "single", or "vendor" for GLXRender, GLXSingle, GLXVendorPrivate{WithReply} 137# opcode - numeric opcode of specified type for this function 138# name - if present, protocol name (defaults to command name) 139# comment - unused 140Command = element command { 141 Comment ? , 142 element proto { 143 attribute group { text } ? , 144 attribute class { text } ? , 145 text , 146 element ptype { TypeName } ? , 147 text , 148 element name { text } , 149 text 150 } , 151 element param { 152 attribute group { text } ? , 153 attribute class { text } ? , 154 attribute len { text } ? , 155 text , 156 element ptype { TypeName } ? , 157 text , 158 element name { text } , 159 text 160 } * , 161 ( 162 element alias { 163 Name 164 } ? & 165 element vecequiv { 166 Name 167 } ? & 168 element glx { 169 attribute type { text } , 170 attribute opcode { xsd:integer } , 171 Name ? , 172 Comment ? 173 } * 174 ) 175} 176# Each <feature> defines the interface of an API version (e.g. OpenGL 1.2) 177# api - API tag (e.g. 'gl', 'gles2', etc. - used internally, not 178# neccessarily an actual API name 179# name - version name (C preprocessor name, e.g. GL_VERSION_4_2) 180# number - version number, e.g. 4.2 181# protect - additional #ifdef symbol to place around the feature 182# <require> / <remove> contains features to require or remove in 183# this version 184# profile - only require/remove when generated profile matches 185# comment - unused 186Feature = element feature { 187 attribute api { text } , 188 Name , 189 attribute number { xsd:float } , 190 attribute protect { text } ?, 191 Comment ? , 192 ( 193 element require { 194 ProfileName ? , 195 Comment ? , 196 InterfaceElement * 197 } | 198 element remove { 199 ProfileName ? , 200 Comment ? , 201 InterfaceElement * 202 } 203 ) * 204} 205Extensions = element extensions { 206 Extension * 207} 208# Defines the interface of an API <extension>. Like a <feature> 209# tag, but with a slightly different api attribute. 210# api - regexp pattern matching one or more API tags, indicating 211# which APIs the extension is known to work with. The only 212# syntax supported is <name>{|<name>}* and each name must 213# exactly match an API being generated (implicit ^$ surrounding). 214# In addition, <require> / <remove> tags also support an 215# api attribute: 216# api - only require/remove these features for the matching API. 217# Not a regular expression. 218Extension = element extension { 219 Name , 220 attribute protect { text } ?, 221 attribute supported { StringGroup } ? , 222 Comment ? , 223 ( 224 element require { 225 attribute api { text } ? , 226 ProfileName ? , 227 Comment ? , 228 InterfaceElement * 229 } | 230 element remove { 231 attribute api { text } ? , 232 ProfileName ? , 233 Comment ? , 234 InterfaceElement * 235 } 236 ) * 237} 238# Contents of a <require> / <remove> tag, defining a group 239# of features to require or remove. 240# <type> / <enum> / <command> all have attributes 241# name - feature name which must match 242InterfaceElement = 243 element type { 244 Name , 245 Comment ? 246 } | 247 element enum { 248 Name , 249 Comment ? 250 } | 251 element command { 252 Name , 253 Comment ? 254 } 255 256# Integers are allowed to be either decimal or C-hex (0x[0-9A-F]+), but 257# XML Schema types don't seem to support hex notation, so we use this 258# as a placeholder. 259Integer = text 260 261# TypeName is an argument/return value C type name 262TypeName = text 263 264# TypeSuffix is a C numeric type suffix, e.g. 'u' or 'ull' 265TypeSuffix = text 266 267# StringGroup is a regular expression with an implicit 268# '^(' and ')$' bracketing it. 269StringGroup = text 270 271# Repeatedly used attributes 272ProfileName = attribute profile { text } 273Vendor = attribute vendor { text } 274Comment = attribute comment { text } 275Name = attribute name { text } 276