Chromium Code Reviews| Index: Source/bindings/scripts/compute_interfaces_info_individual.py |
| diff --git a/Source/bindings/scripts/compute_interfaces_info_individual.py b/Source/bindings/scripts/compute_interfaces_info_individual.py |
| index b052e14c162dae0010d6865a4e4441e7d8e3d2fa..b9f55daa88b0c8ac35b3a6624563497f9febccf5 100755 |
| --- a/Source/bindings/scripts/compute_interfaces_info_individual.py |
| +++ b/Source/bindings/scripts/compute_interfaces_info_individual.py |
| @@ -130,6 +130,12 @@ def get_put_forward_interfaces_from_definition(definition): |
| if 'PutForwards' in attribute.extended_attributes)) |
| +def get_unforgeable_attributes_from_definition(definition): |
| + return sorted(set(attribute for attribute in definition.attributes |
|
bashi
2015/07/28 00:38:47
nit: I slightly prefer:
if 'Unforgeable' in defin
Yuki
2015/07/29 08:16:24
Done.
|
| + if 'Unforgeable' in attribute.extended_attributes or |
| + 'Unforgeable' in definition.extended_attributes)) |
| + |
| + |
| def collect_union_types_from_definitions(definitions): |
| """Traverse definitions and collect all union types.""" |
| class UnionTypeCollector(Visitor): |
| @@ -208,6 +214,33 @@ class InterfaceInfoCollector(object): |
| else: |
| return |
| + if definition.name not in self.interfaces_info: |
| + self.interfaces_info[definition.name] = {} |
|
bashi
2015/07/28 00:38:46
Why do you need this? Can't we just use |interface
Yuki
2015/07/29 08:16:24
Before my change, we didn't update interfaces_info
bashi
2015/07/29 09:24:33
Got it.
|
| + |
| + # Collects [Unforgeable] attributes so that we can define them on |
| + # sub-interfaces. The resulting structure is as follows. |
| + # interfaces_info[interface_name] = { |
|
bashi
2015/07/28 00:38:46
(BTW, I'm not a big fun of {'core': ..., 'modules'
Yuki
2015/07/29 08:16:24
Acknowledged.
|
| + # 'unforgeable_attributes': { |
| + # 'core': [IdlAttribute, ...], |
| + # 'modules': [IdlAttribute, ...], |
| + # }, |
| + # ... |
| + # } |
|
bashi
2015/07/28 00:38:47
Can we factor out this block as a method?
Yuki
2015/07/29 08:16:24
Done.
|
| + component = idl_filename_to_component(idl_filename) |
| + if definitions.interfaces: |
| + unforgeable_attributes = get_unforgeable_attributes_from_definition(definition) |
| + if definition.is_partial: |
| + interface_basename, _ = os.path.splitext(os.path.basename(idl_filename)) |
|
bashi
2015/07/28 00:38:46
idl_filename_to_interface_name(idl_filename)
Yuki
2015/07/29 08:16:24
Done.
|
| + for attr in unforgeable_attributes: |
| + attr.extended_attributes['PartialInterfaceImplementedAs'] = definition.extended_attributes.get('ImplementedAs', interface_basename) |
|
bashi
2015/07/28 00:38:46
We have similar logic in transfer_extended_attribu
Yuki
2015/07/29 08:16:24
Done.
|
| + if unforgeable_attributes: |
| + info = self.interfaces_info[definition.name] |
| + if 'unforgeable_attributes' not in info: |
| + info['unforgeable_attributes'] = {} |
| + if component not in info['unforgeable_attributes']: |
| + info['unforgeable_attributes'][component] = [] |
| + info['unforgeable_attributes'][component].extend(unforgeable_attributes) |
| + |
| extended_attributes = definition.extended_attributes |
| implemented_as = extended_attributes.get('ImplementedAs') |
| full_path = os.path.realpath(idl_filename) |
| @@ -219,10 +252,25 @@ class InterfaceInfoCollector(object): |
| if this_include_path: |
| partial_include_paths.append(this_include_path) |
| if this_union_types: |
| - component = idl_filename_to_component(idl_filename) |
| partial_include_paths.append( |
| 'bindings/%s/v8/UnionTypes%s.h' % (component, component.capitalize())) |
| self.add_paths_to_partials_dict(definition.name, full_path, partial_include_paths) |
| + # Collects C++ header paths which should be included from generated |
| + # .cpp files. The resulting structure is as follows. |
| + # interfaces_info[interface_name] = { |
| + # 'cpp_includes': { |
| + # 'core': set(['core/foo/Foo.h', ...]), |
| + # 'modules': set(['modules/bar/Bar.h', ...]), |
| + # }, |
| + # ... |
| + # } |
| + if this_include_path: |
| + info = self.interfaces_info[definition.name] |
| + if 'cpp_includes' not in info: |
| + info['cpp_includes'] = {} |
| + if component not in info['cpp_includes']: |
| + info['cpp_includes'][component] = set() |
| + info['cpp_includes'][component].add(this_include_path) |
| return |
| # 'implements' statements can be included in either the file for the |
| @@ -246,7 +294,7 @@ class InterfaceInfoCollector(object): |
| 'parent': definition.parent, |
| 'relative_dir': relative_dir_posix(idl_filename), |
| }) |
| - self.interfaces_info[definition.name] = interface_info |
| + self.interfaces_info[definition.name].update(interface_info) |
| def get_info_as_dict(self): |
| """Returns info packaged as a dict.""" |