... | ... |
@@ -100,7 +100,7 @@ Commands: |
100 | 100 |
value <enum> |
101 | 101 |
Print the value of <enum>. |
102 | 102 |
enum <value> |
103 |
- Print the enum(s) that has the given <value>, using exact string matching. |
|
103 |
+ Print the enum(s) that has the given <value>. |
|
104 | 104 |
supports <name> |
105 | 105 |
Print the OpenGL version or extension required to use <name>. |
106 | 106 |
names [<support>] |
... | ... |
@@ -57,7 +57,7 @@ Commands: |
57 | 57 |
value <enum> |
58 | 58 |
Print the value of <enum>. |
59 | 59 |
enum <value> |
60 |
- Print the enum(s) that has the given <value>, using exact string matching. |
|
60 |
+ Print the enum(s) that has the given <value>. |
|
61 | 61 |
supports <name> |
62 | 62 |
Print the OpenGL version or extension required to use <name>. |
63 | 63 |
names [<support>] |
... | ... |
@@ -411,7 +411,14 @@ def value(xml, enum): |
411 | 411 |
|
412 | 412 |
### `enum` |
413 | 413 |
def enum(xml, value): |
414 |
- enum = xml.xpath(f"{ENUMS}/enum[@value='{value}']/@name") |
|
414 |
+ def conv(s): |
|
415 |
+ return int(s, 16 if s.startswith('0x') else 10) |
|
416 |
+ value = conv(value) |
|
417 |
+ enum = ( |
|
418 |
+ enum.get('name') |
|
419 |
+ for enum in xml.xpath(f"{ENUMS}/enum") |
|
420 |
+ if conv(enum.get('value')) == value |
|
421 |
+ ) |
|
415 | 422 |
return sorted(enum, key=key) |
416 | 423 |
|
417 | 424 |
|