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

Unified Diff: Source/bindings/scripts/interface_dependency_resolver.py

Issue 1257613003: bindings: Supports inheritance of [Unforgeable] attributes as accessor-type properties. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Made inherit_unforgeable_attributes more robust. Created 5 years, 5 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 | « Source/bindings/scripts/compute_interfaces_info_overall.py ('k') | Source/bindings/scripts/utilities.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/interface_dependency_resolver.py
diff --git a/Source/bindings/scripts/interface_dependency_resolver.py b/Source/bindings/scripts/interface_dependency_resolver.py
index 79b28ea133445b94448cf0229d84f171bfa38196..830bc148eb832c0418e053603459e075b51e7a6b 100644
--- a/Source/bindings/scripts/interface_dependency_resolver.py
+++ b/Source/bindings/scripts/interface_dependency_resolver.py
@@ -37,7 +37,7 @@ Design doc: http://www.chromium.org/developers/design-documents/idl-compiler#TOC
"""
import os.path
-from utilities import idl_filename_to_component, is_valid_component_dependency
+from utilities import idl_filename_to_component, is_valid_component_dependency, merge_dict_recursively
# The following extended attributes can be applied to a dependency interface,
# and are then applied to the individual members when merging.
@@ -119,6 +119,8 @@ class InterfaceDependencyResolver(object):
interface_info['dependencies_other_component_full_paths'],
self.reader)
+ inherit_unforgeable_attributes(resolved_definitions, self.interfaces_info)
+
for referenced_interface_name in interface_info['referenced_interfaces']:
referenced_definitions = self.reader.read_idl_definitions(
self.interfaces_info[referenced_interface_name]['full_path'])
@@ -305,3 +307,42 @@ def transfer_extended_attributes(dependency_interface, dependency_interface_base
update_attributes(constant.extended_attributes, merged_extended_attributes)
for operation in dependency_interface.operations:
update_attributes(operation.extended_attributes, merged_extended_attributes)
+
+
+def inherit_unforgeable_attributes(resolved_definitions, interfaces_info):
+ """Inherits [Unforgeable] attributes and updates the arguments accordingly.
+
+ For each interface in |resolved_definitions|, collects all [Unforgeable]
+ attributes in ancestor interfaces in the same component and adds them to
+ the interface. 'referenced_interfaces' and 'cpp_includes' in
+ |interfaces_info| are updated accordingly.
+ """
+ def collect_unforgeable_attributes_in_ancestors(interface_name, component):
+ if not interface_name:
+ # unforgeable_attributes, referenced_interfaces, cpp_includes
+ return [], [], set()
+ interface = interfaces_info[interface_name]
+ unforgeable_attributes, referenced_interfaces, cpp_includes = collect_unforgeable_attributes_in_ancestors(interface.get('parent'), component)
+ this_unforgeable = interface.get('unforgeable_attributes', {}).get(component, [])
+ unforgeable_attributes.extend(this_unforgeable)
+ this_referenced = [attr.idl_type.base_type for attr in this_unforgeable
+ if attr.idl_type.base_type in
+ interface.get('referenced_interfaces', [])]
+ referenced_interfaces.extend(this_referenced)
+ cpp_includes.update(interface.get('cpp_includes', {}).get(component, {}))
+ return unforgeable_attributes, referenced_interfaces, cpp_includes
+
+ for component, definitions in resolved_definitions.iteritems():
+ for interface_name, interface in definitions.interfaces.iteritems():
+ interface_info = interfaces_info[interface_name]
+ inherited_unforgeable_attributes, referenced_interfaces, cpp_includes = collect_unforgeable_attributes_in_ancestors(interface_info.get('parent'), component)
+ # This loop may process the same interface many times, so it's
+ # possible that we're adding the same attributes twice or more.
+ # So check if there is a duplicate.
+ for attr in inherited_unforgeable_attributes:
+ if attr not in interface.attributes:
+ interface.attributes.append(attr)
+ referenced_interfaces.extend(interface_info.get('referenced_interfaces', []))
+ interface_info['referenced_interfaces'] = sorted(set(referenced_interfaces))
tasak 2015/07/29 12:56:45 Just my perfornal preference. I would like to avoi
Yuki 2015/08/03 02:02:13 Very good point. It seems we may need redesign of
+ merge_dict_recursively(interface_info,
+ {'cpp_includes': {component: cpp_includes}})
« no previous file with comments | « Source/bindings/scripts/compute_interfaces_info_overall.py ('k') | Source/bindings/scripts/utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698