... | ... |
@@ -13,6 +13,12 @@ appropriate each line is in a widely supported format, usable with e.g. |
13 | 13 |
-q`][]` <(glregistry audit)`) and [GNU Emacs][]' [Compilation Mode][] ([`M-x |
14 | 14 |
compile`][]` glregistry audit`). |
15 | 15 |
|
16 |
+The vendors `KHR` (Khronos), `ARB` (Architecture Review Board), and `EXT` |
|
17 |
+(Extension) are treated specially and are sorted before other vendors. When |
|
18 |
+querying for enums, either directly or indirectly, enums with the same name, |
|
19 |
+except for one of these vendors added as a suffix, and the same value is |
|
20 |
+matched as well. |
|
21 |
+ |
|
16 | 22 |
Note that only the OpenGL (not OpenGL ES) API, and only the core (not |
17 | 23 |
compatibility) [profile][] is considered. |
18 | 24 |
|
... | ... |
@@ -52,7 +58,9 @@ Usage: |
52 | 58 |
glregistry exts |
53 | 59 |
glregistry exts-download |
54 | 60 |
glregistry exts-all <name> |
61 |
+ glregistry vendors |
|
55 | 62 |
glregistry type <type> |
63 |
+ glregistry aliases <enum> |
|
56 | 64 |
glregistry value <enum> |
57 | 65 |
glregistry enum <value> |
58 | 66 |
glregistry supports <name> |
... | ... |
@@ -83,8 +91,12 @@ Commands: |
83 | 91 |
Download all extension specs. |
84 | 92 |
exts-all <name> |
85 | 93 |
Print all downloaded extensions that mention <name>. |
94 |
+ vendors |
|
95 |
+ Print all vendor abbreviations. |
|
86 | 96 |
type <type> |
87 | 97 |
Print the definition of <type>. |
98 |
+ aliases <enum> |
|
99 |
+ Print the KHR, ARB, and EXT aliases of <enum>. |
|
88 | 100 |
value <enum> |
89 | 101 |
Print the value of <enum>. |
90 | 102 |
enum <value> |
... | ... |
@@ -15,7 +15,9 @@ Usage: |
15 | 15 |
glregistry exts |
16 | 16 |
glregistry exts-download |
17 | 17 |
glregistry exts-all <name> |
18 |
+ glregistry vendors |
|
18 | 19 |
glregistry type <type> |
20 |
+ glregistry aliases <enum> |
|
19 | 21 |
glregistry value <enum> |
20 | 22 |
glregistry enum <value> |
21 | 23 |
glregistry supports <name> |
... | ... |
@@ -46,8 +48,12 @@ Commands: |
46 | 48 |
Download all extension specs. |
47 | 49 |
exts-all <name> |
48 | 50 |
Print all downloaded extensions that mention <name>. |
51 |
+ vendors |
|
52 |
+ Print all vendor abbreviations. |
|
49 | 53 |
type <type> |
50 | 54 |
Print the definition of <type>. |
55 |
+ aliases <enum> |
|
56 |
+ Print the KHR, ARB, and EXT aliases of <enum>. |
|
51 | 57 |
value <enum> |
52 | 58 |
Print the value of <enum>. |
53 | 59 |
enum <value> |
... | ... |
@@ -165,8 +171,11 @@ CHANGE_PREFIXES = [ |
165 | 171 |
[REQUIRE, '' ], |
166 | 172 |
[REMOVE, '<'], |
167 | 173 |
] |
174 |
+VENDORS = ['KHR', 'ARB', 'EXT'] |
|
168 | 175 |
KEY_SUBS = [ |
169 |
- *[[f'^{prefix}', f''] for _, prefix in CHANGE_PREFIXES], |
|
176 |
+ *[[f'^{ prefix}', f'' ] for _, prefix in CHANGE_PREFIXES], |
|
177 |
+ *[[f'{ vendor}$', f'{ i}' ] for i, vendor in enumerate(VENDORS)], |
|
178 |
+ *[[f'^GL_{vendor}_', f'GL_{i}_'] for i, vendor in enumerate(VENDORS)], |
|
170 | 179 |
] |
171 | 180 |
|
172 | 181 |
|
... | ... |
@@ -294,7 +303,7 @@ def ext(extension): |
294 | 303 |
def exts(xml): |
295 | 304 |
category, attrib = CATEGORY_ATTRIBS['EXTENSION'] |
296 | 305 |
exts = xml.xpath(f"{category}/@{attrib}") |
297 |
- return sorted(exts) |
|
306 |
+ return sorted(exts, key=key) |
|
298 | 307 |
|
299 | 308 |
|
300 | 309 |
### `exts_download` |
... | ... |
@@ -317,7 +326,13 @@ def exts_all(xml, name): |
317 | 326 |
for file, *_ in |
318 | 327 |
grep(os.path.join(CACHE, 'extensions'), rf'\b{name}\b', [], []) |
319 | 328 |
) |
320 |
- return sorted(exts_all) |
|
329 |
+ return sorted(exts_all, key=key) |
|
330 |
+ |
|
331 |
+ |
|
332 |
+### `vendors` |
|
333 |
+def vendors(xml): |
|
334 |
+ vendors = set(extension.split('_')[1] for extension in exts(xml)) |
|
335 |
+ return sorted(vendors, key=key) |
|
321 | 336 |
|
322 | 337 |
|
323 | 338 |
### `type` |
... | ... |
@@ -325,6 +340,29 @@ def type(xml, type): |
325 | 340 |
return [xml.xpath(f"string({TYPES}/type/name[text()='{type}']/..)")] |
326 | 341 |
|
327 | 342 |
|
343 |
+### `aliases` |
|
344 |
+def aliases(xml, name, supports_=None, vendors_=[]): |
|
345 |
+ if not vendors_: |
|
346 |
+ vendors_[:] = vendors(xml) |
|
347 |
+ for vendor in vendors_: |
|
348 |
+ if name.endswith(f'_{vendor}'): |
|
349 |
+ return [] |
|
350 |
+ value_ = value(xml, name) |
|
351 |
+ if not value_: |
|
352 |
+ return [] |
|
353 |
+ if not supports_: |
|
354 |
+ supports_ = supports(xml, name, False) |
|
355 |
+ if not supports_: |
|
356 |
+ return [] |
|
357 |
+ aliases = [] |
|
358 |
+ # for vendor in vendors_: |
|
359 |
+ for vendor in VENDORS: |
|
360 |
+ alias = f'{name}_{vendor}' |
|
361 |
+ if supports(xml, alias, False) and value(xml, alias) == value_: |
|
362 |
+ aliases.append(alias) |
|
363 |
+ return sorted(aliases, key=key) |
|
364 |
+ |
|
365 |
+ |
|
328 | 366 |
### `value` |
329 | 367 |
def value(xml, enum): |
330 | 368 |
return xml.xpath(f"{ENUMS}/enum[@name='{enum}']/@value") |
... | ... |
@@ -333,11 +371,11 @@ def value(xml, enum): |
333 | 371 |
### `enum` |
334 | 372 |
def enum(xml, value): |
335 | 373 |
enum = xml.xpath(f"{ENUMS}/enum[@value='{value}']/@name") |
336 |
- return sorted(enum) |
|
374 |
+ return sorted(enum, key=key) |
|
337 | 375 |
|
338 | 376 |
|
339 | 377 |
### `supports` |
340 |
-def supports(xml, name): |
|
378 |
+def supports(xml, name, use_aliases=True): |
|
341 | 379 |
category, attrib = CATEGORY_ATTRIBS['EXTENSION'] |
342 | 380 |
if xml.xpath(f"{category}[@{attrib}='{name}']"): |
343 | 381 |
return ['EXTENSION'] |
... | ... |
@@ -348,6 +386,12 @@ def supports(xml, name): |
348 | 386 |
for support in |
349 | 387 |
xml.xpath(f"{category}/{change}/*[@name='{name}']/../../@{attrib}") |
350 | 388 |
] |
389 |
+ if supports_ and use_aliases: |
|
390 |
+ supports_.extend( |
|
391 |
+ support |
|
392 |
+ for alias in aliases (xml, name, supports_) |
|
393 |
+ for support in supports(xml, alias, False) |
|
394 |
+ ) |
|
351 | 395 |
return sorted(supports_, key=key) |
352 | 396 |
|
353 | 397 |
|
... | ... |
@@ -374,7 +418,7 @@ def names(xml, support=None): |
374 | 418 |
for name in |
375 | 419 |
xml.xpath(f"{category}{attrib}/{REQUIRE}/*/@name") |
376 | 420 |
) |
377 |
- return sorted(names) |
|
421 |
+ return sorted(names, key=key) |
|
378 | 422 |
|
379 | 423 |
|
380 | 424 |
### `groups` |
... | ... |
@@ -405,7 +449,7 @@ def enums(xml, group=None): |
405 | 449 |
for _, enums in enums_(xml, group).items() |
406 | 450 |
for enum in enums |
407 | 451 |
] |
408 |
- return sorted(enums) |
|
452 |
+ return sorted(enums, key=key) |
|
409 | 453 |
|
410 | 454 |
|
411 | 455 |
### `enums_tree` |
... | ... |
@@ -547,7 +591,9 @@ def main(): |
547 | 591 |
if args['exts']: page(exts (xml_())) |
548 | 592 |
if args['exts-download']: page(exts_download(xml_())) |
549 | 593 |
if args['exts-all']: page(exts_all (xml_(), args['<name>'])) |
594 |
+ if args['vendors']: page(vendors (xml_())) |
|
550 | 595 |
if args['type']: page(type (xml_(), args['<type>'])) |
596 |
+ if args['aliases']: page(aliases (xml_(), args['<enum>'])) |
|
551 | 597 |
if args['value']: page(value (xml_(), args['<enum>'])) |
552 | 598 |
if args['enum']: page(enum (xml_(), args['<value>'])) |
553 | 599 |
if args['supports']: page(supports (xml_(), args['<name>'])) |