Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Unified Diff: third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py

Issue 2887453003: bindings: Allow multiple enum declarations (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py
diff --git a/third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py b/third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py
index 510d438ee27dcd871327f0a77a4b4b719daeee87..82e54b40ba5ffb138298a7b57b97b7c55a1e8428 100755
--- a/third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py
+++ b/third_party/WebKit/Source/bindings/scripts/compute_interfaces_info_individual.py
@@ -172,7 +172,7 @@ class InterfaceInfoCollector(object):
'full_paths': [],
'include_paths': [],
})
- self.enumerations = set()
+ self.enumerations = {}
self.union_types = set()
self.typedefs = {}
self.callback_functions = {}
@@ -183,6 +183,16 @@ class InterfaceInfoCollector(object):
paths_dict['full_paths'].append(full_path)
paths_dict['include_paths'].extend(include_paths)
+ def check_enum_consistency(self, enum):
+ existing_enum = self.enumerations.get(enum.name)
+ if not existing_enum:
+ return True
+ # TODO(bashi): Ideally we should not allow multiple enum declarations
+ # but we allow them to work around core/module separation.
+ if len(existing_enum.values) != len(enum.values):
+ return False
+ return all(value in existing_enum.values for value in enum.values)
+
def collect_info(self, idl_filename):
"""Reads an idl file and collects information which is required by the
binding code generation."""
@@ -222,11 +232,11 @@ class InterfaceInfoCollector(object):
'full_path': os.path.realpath(idl_filename),
}
# Check enum duplication.
- for enum_name in definitions.enumerations.keys():
- for defined_enum in self.enumerations:
- if defined_enum.name == enum_name:
- raise Exception('Enumeration %s has multiple definitions' % enum_name)
- self.enumerations.update(definitions.enumerations.values())
+ for enum in definitions.enumerations.values():
+ if not self.check_enum_consistency(enum):
+ raise Exception('Enumeration "%s" is defined more than once '
+ 'with different valid values' % enum.name)
+ self.enumerations.update(definitions.enumerations)
if definitions.interfaces:
definition = next(definitions.interfaces.itervalues())
@@ -324,7 +334,7 @@ class InterfaceInfoCollector(object):
return {
'callback_functions': self.callback_functions,
'enumerations': dict((enum.name, enum.values)
- for enum in self.enumerations),
+ for enum in self.enumerations.values()),
'typedefs': self.typedefs,
'union_types': self.union_types,
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698