dawn_json_generator: Assert that enum values are unique.
This will be useful when we add all texture formats because there are more than 50 of them and we want to make sure no two enum values collide. BUG=dawn:128 Change-Id: I928d3311ee3f6422ea503a3fa90c5e377fe5e03d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8360 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
ebcf0d31c0
commit
7ac0815347
|
@ -67,6 +67,13 @@ class EnumType(Type):
|
||||||
Type.__init__(self, name, json_data)
|
Type.__init__(self, name, json_data)
|
||||||
self.values = [EnumValue(Name(m['name']), m['value']) for m in self.json_data['values']]
|
self.values = [EnumValue(Name(m['name']), m['value']) for m in self.json_data['values']]
|
||||||
|
|
||||||
|
# Assert that all values are unique in enums
|
||||||
|
all_values = set()
|
||||||
|
for value in self.values:
|
||||||
|
if value.value in all_values:
|
||||||
|
raise Exception("Duplicate value {} in enum {}".format(value.value, name))
|
||||||
|
all_values.add(value.value)
|
||||||
|
|
||||||
BitmaskValue = namedtuple('BitmaskValue', ['name', 'value'])
|
BitmaskValue = namedtuple('BitmaskValue', ['name', 'value'])
|
||||||
class BitmaskType(Type):
|
class BitmaskType(Type):
|
||||||
def __init__(self, name, json_data):
|
def __init__(self, name, json_data):
|
||||||
|
|
Loading…
Reference in New Issue