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

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

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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
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 7bf3b05c0598a715152d0b5e5ce6038479a9afae..82d645557c836a187407825aa15b9422ec48027a 100644
--- a/Source/bindings/scripts/interface_dependency_resolver.py
+++ b/Source/bindings/scripts/interface_dependency_resolver.py
@@ -37,6 +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
# The following extended attributes can be applied to a dependency interface,
# and are then applied to the individual members when merging.
@@ -110,56 +111,120 @@ class InterfaceDependencyResolver(object):
target_interface.extended_attributes.update(
interface_info['inherited_extended_attributes'])
+ # FIXME: new method for partial interface dependencies full paths?
resolved_definitions = merge_interface_dependencies(
definitions,
component,
target_interface,
- interface_info['dependencies_full_paths'],
+ interface_info['dependencies_full_paths'] +
+ interface_info['partial_interface_dependencies_full_paths'],
self.reader)
for referenced_interface_name in interface_info['referenced_interfaces']:
referenced_definitions = self.reader.read_idl_definitions(
self.interfaces_info[referenced_interface_name]['full_path'])
- if component not in referenced_definitions:
- raise Exception('This definitions: %s is defined in %s '
- 'but reference interface:%s is not defined '
- 'in %s' % (definitions.idl_name,
- component,
- referenced_interface_name,
- component))
+ for referenced_component in referenced_definitions:
haraken 2014/10/16 04:24:08 I'd rename all "referenced" to "dependent", but yo
tasak 2014/10/17 07:38:17 I will do this in a follow-up.
+ if not is_valid_component_dependency(component, referenced_component):
+ raise Exception('This definitions: %s is defined in %s '
+ 'but reference interface:%s is defined '
+ 'in %s' % (definitions.idl_name,
+ component,
+ referenced_interface_name,
+ referenced_component))
+
+ resolved_definitions[component].update(referenced_definitions[component])
- resolved_definitions[component].update(referenced_definitions[component])
return resolved_definitions
def merge_interface_dependencies(definitions, component, target_interface, dependency_idl_filenames, reader):
"""Merge dependencies ('partial interface' and 'implements') in dependency_idl_filenames into target_interface.
- No return: modifies target_interface in place.
+ Args:
+ definitions: IdlDefinitions object, modified in place
+ component:
+ string, describing where the above definitions are defined,
+ 'core' or 'modules'. See KNOWN_COMPONENTS in utilities.py
+ target_interface: IdlInterface object, modified in place
+ dependency_idl_filenames:
+ Idl filenames which depend on the above definitions.
+ reader: IdlReader object.
+ Returns:
+ A dictionary whose key is component and value is IdlDefinitions
+ object whose dependency is resolved.
"""
+ resolved_definitions = {component: definitions}
# Sort so order consistent, so can compare output from run to run.
for dependency_idl_filename in sorted(dependency_idl_filenames):
dependency_definitions = reader.read_idl_file(dependency_idl_filename)
- # FIXME(crbug.com/358074): should not merge core definitions with
- # modules definitions.
+ dependency_component = idl_filename_to_component(dependency_idl_filename)
+
dependency_interface = next(dependency_definitions.interfaces.itervalues())
dependency_interface_basename, _ = os.path.splitext(os.path.basename(dependency_idl_filename))
transfer_extended_attributes(dependency_interface,
dependency_interface_basename)
- definitions.update(dependency_definitions) # merges partial interfaces
- if not dependency_interface.is_partial:
+
+ # We need to use different checkdeps here for partial interface and
+ # inheritance.
+ if dependency_interface.is_partial:
+ # Case: dependency_interface is a partial interface of
+ # target_interface.
+ # So,
+ # - A partial interface defined in modules can update
+ # the original interface defined in core.
+ # However,
+ # - A partial interface defined in core cannot update
+ # the original interface defined in modules.
+ if not is_valid_component_dependency(dependency_component, component):
+ raise Exception('The partial interface:%s in %s cannot update '
+ 'the original interface:%s in %s' % (dependency_interface.name,
+ dependency_component,
+ target_interface.name,
+ component))
+
+ if dependency_component in resolved_definitions:
+ resolved_definitions[dependency_component].update(dependency_definitions)
+ continue
+
+ dependency_interface.extended_attributes.update(target_interface.extended_attributes)
+ assert target_interface == definitions.interfaces[dependency_interface.name]
+ dependency_interface.original_interface = target_interface
+ target_interface.partial_interfaces.append(dependency_interface)
+ resolved_definitions[dependency_component] = dependency_definitions
+ else:
+ # Case: target_interface implements dependency_interface.
+ # So,
+ # - An interface defined in modules can implement some interface
+ # defined in core.
+ # In this case, we need "NoInterfaceObject" extended attribute.
+ # However,
+ # - An interface defined in core cannot implement any interface
+ # defined in modules.
+ if not is_valid_component_dependency(component, dependency_component):
+ raise Exception('The interface:%s in %s cannot implement '
+ 'the interface:%s in %s.' % (dependency_interface.name,
+ dependency_component,
+ target_interface.name,
+ component))
+
+ if component != dependency_component:
+ if 'NoInterfaceObject' not in dependency_interface.extended_attributes:
haraken 2014/10/16 04:24:08 You can merge the two if branches.
tasak 2014/10/17 07:38:17 Done.
+ raise Exception('The interface:%s in %s cannot implement '
+ 'the interface:%s in %s because of '
+ 'missing NoInterfaceObject.' % (dependency_interface.name,
+ dependency_component,
+ target_interface.name,
+ component))
+
+ resolved_definitions[component].update(dependency_definitions) # merges partial interfaces
# Implemented interfaces (non-partial dependencies) are also merged
# into the target interface, so Code Generator can just iterate
# over one list (and not need to handle 'implements' itself).
target_interface.merge(dependency_interface)
- # FIXME: Currently, this function just returns one IdlDefinitions
- # instance. However, for partial interface modularization, we need to
- # make this function return multiple definitions, i.e.
- # { 'core': ..., 'modules': ... }.
- return {component: definitions}
+ return resolved_definitions
def transfer_extended_attributes(dependency_interface, dependency_interface_basename):

Powered by Google App Engine
This is Rietveld 408576698