Commit 30b65a70 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Minor refactoring of common.py

- rename common.py to composition_parts.py
- make Identifier and Component own classes
- remove non-informative comments

Bug: 839389
Change-Id: Ia7b5d17810bb6ad39873effa3a7e2fc8ffeda348
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724270Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682138}
parent e6bd26ab
...@@ -55,7 +55,7 @@ group("web_idl_pylib") { ...@@ -55,7 +55,7 @@ group("web_idl_pylib") {
"web_idl/attribute.py", "web_idl/attribute.py",
"web_idl/callback_function.py", "web_idl/callback_function.py",
"web_idl/callback_interface.py", "web_idl/callback_interface.py",
"web_idl/common.py", "web_idl/composition_parts.py",
"web_idl/constant.py", "web_idl/constant.py",
"web_idl/constructor.py", "web_idl/constructor.py",
"web_idl/database.py", "web_idl/database.py",
......
...@@ -47,7 +47,7 @@ def main(): ...@@ -47,7 +47,7 @@ def main():
filepaths = utilities.read_idl_files_list_from_file(options.idl_list_file) filepaths = utilities.read_idl_files_list_from_file(options.idl_list_file)
parser = blink_idl_parser.BlinkIDLParser() parser = blink_idl_parser.BlinkIDLParser()
ast_group = web_idl.AstGroup(options.component) ast_group = web_idl.AstGroup(web_idl.Component(options.component))
for filepath in filepaths: for filepath in filepaths:
ast_group.add_ast_node(blink_idl_parser.parse_file(parser, filepath)) ast_group.add_ast_node(blink_idl_parser.parse_file(parser, filepath))
ast_group.write_to_file(options.output) ast_group.write_to_file(options.output)
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
# found in the LICENSE file. # found in the LICENSE file.
from .ast_group import AstGroup from .ast_group import AstGroup
from .composition_parts import Component
from .database import Database from .database import Database
from .database_builder import build_database from .database_builder import build_database
__all__ = [ __all__ = [
"AstGroup", "AstGroup",
"Component",
"Database", "Database",
"build_database", "build_database",
] ]
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithOwner from .composition_parts import WithOwner
from .idl_type import IdlType from .idl_type import IdlType
from .values import DefaultValue from .values import DefaultValue
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
import pickle import pickle
from .common import Component from .composition_parts import Component
class AstGroup(object): class AstGroup(object):
"""A set of Web IDL ASTs grouped by component.""" """A set of Web IDL ASTs grouped by component."""
def __init__(self, component=None): def __init__(self, component):
assert component is None or isinstance(component, Component) assert isinstance(component, Component)
self._nodes = [] self._nodes = []
self._component = component self._component = component
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithExposure from .composition_parts import WithDebugInfo
from .common import WithExtendedAttributes from .composition_parts import WithExposure
from .common import WithIdentifier from .composition_parts import WithExtendedAttributes
from .composition_parts import WithIdentifier
from .idl_member import IdlMember from .idl_member import IdlMember
from .idl_type import IdlType from .idl_type import IdlType
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithExtendedAttributes from .composition_parts import WithDebugInfo
from .composition_parts import WithExtendedAttributes
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
from .user_defined_type import UserDefinedType from .user_defined_type import UserDefinedType
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithExtendedAttributes from .composition_parts import WithDebugInfo
from .composition_parts import WithExtendedAttributes
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
from .user_defined_type import UserDefinedType from .user_defined_type import UserDefinedType
......
...@@ -8,12 +8,12 @@ from .extended_attribute import ExtendedAttributes ...@@ -8,12 +8,12 @@ from .extended_attribute import ExtendedAttributes
from .exposure import Exposure from .exposure import Exposure
Identifier = str class Identifier(str):
pass
class WithIdentifier(object): class WithIdentifier(object):
"""WithIdentifier class is an interface that indicates the class has an """Implements |identifier| as a readonly attribute."""
identifier."""
def __init__(self, identifier): def __init__(self, identifier):
assert isinstance(identifier, Identifier) assert isinstance(identifier, Identifier)
...@@ -21,17 +21,11 @@ class WithIdentifier(object): ...@@ -21,17 +21,11 @@ class WithIdentifier(object):
@property @property
def identifier(self): def identifier(self):
"""
Returns the identifier.
@return Identifier
"""
return self._identifier return self._identifier
# ExtendedAttribute and ExtendedAttributes are defined in extended_attribute.py
class WithExtendedAttributes(object): class WithExtendedAttributes(object):
"""WithExtendedAttributes class is an interface that indicates the implemented """Implements |extended_attributes| as a readonly attribute."""
class can have extended attributes."""
def __init__(self, extended_attributes=None): def __init__(self, extended_attributes=None):
assert (extended_attributes is None assert (extended_attributes is None
...@@ -40,21 +34,18 @@ class WithExtendedAttributes(object): ...@@ -40,21 +34,18 @@ class WithExtendedAttributes(object):
@property @property
def extended_attributes(self): def extended_attributes(self):
"""
Returns the extended attributes.
@return ExtendedAttributes
"""
return self._extended_attributes return self._extended_attributes
class CodeGeneratorInfo(dict): class CodeGeneratorInfo(dict):
"""A bag of properties to be used by bindings code generators"""
def make_copy(self): def make_copy(self):
return copy.deepcopy(self) return copy.deepcopy(self)
class WithCodeGeneratorInfo(object): class WithCodeGeneratorInfo(object):
"""WithCodeGeneratorInfo class is an interface that its inheritances can """Implements |code_generator_info| as a readonly attribute."""
provide some information for code generators."""
def __init__(self, code_generator_info=None): def __init__(self, code_generator_info=None):
assert (code_generator_info is None assert (code_generator_info is None
...@@ -63,16 +54,11 @@ class WithCodeGeneratorInfo(object): ...@@ -63,16 +54,11 @@ class WithCodeGeneratorInfo(object):
@property @property
def code_generator_info(self): def code_generator_info(self):
"""
Returns information for code generator.
@return CodeGeneratorInfo
"""
return self._code_generator_info return self._code_generator_info
class WithExposure(object): class WithExposure(object):
"""WithExposure class is an interface that its inheritances can have Exposed """Implements |exposures| as a readonly attribute."""
extended attributes."""
def __init__(self, exposures=None): def __init__(self, exposures=None):
assert (exposures is None assert (exposures is None
...@@ -82,21 +68,21 @@ class WithExposure(object): ...@@ -82,21 +68,21 @@ class WithExposure(object):
@property @property
def exposures(self): def exposures(self):
"""
Returns a set of Exposure's that are applicable on an object.
https://heycam.github.io/webidl/#Exposed
@return tuple(Expsure)
"""
return self._exposures return self._exposures
Component = str class Component(str):
"""
Represents a component that is a Blink-specific layering concept, such as
'core' and 'modules'.
"""
pass
class WithComponent(object): class WithComponent(object):
""" """
Implements |components| which is a Blink-specific layering concept of Implements |components| as a readonly attribute.
components, such as 'core' and 'modules'.
A single IDL definition such as 'interface' may consist from multiple IDL A single IDL definition such as 'interface' may consist from multiple IDL
fragments like partial interfaces and mixins, which may exist across fragments like partial interfaces and mixins, which may exist across
...@@ -125,7 +111,6 @@ class WithComponent(object): ...@@ -125,7 +111,6 @@ class WithComponent(object):
def components(self): def components(self):
""" """
Returns a list of components' names where this definition is defined Returns a list of components' names where this definition is defined
@return tuple(Component)
""" """
return tuple(self._components) return tuple(self._components)
...@@ -214,8 +199,7 @@ class DebugInfo(object): ...@@ -214,8 +199,7 @@ class DebugInfo(object):
class WithDebugInfo(object): class WithDebugInfo(object):
"""WithDebugInfo class is an interface that its inheritances can have """Implements |debug_info| as a readonly attribute."""
DebugInfo."""
def __init__(self, debug_info=None): def __init__(self, debug_info=None):
assert debug_info is None or isinstance(debug_info, DebugInfo) assert debug_info is None or isinstance(debug_info, DebugInfo)
...@@ -223,24 +207,16 @@ class WithDebugInfo(object): ...@@ -223,24 +207,16 @@ class WithDebugInfo(object):
@property @property
def debug_info(self): def debug_info(self):
"""Returns DebugInfo."""
return self._debug_info return self._debug_info
class WithOwner(object): class WithOwner(object):
"""WithOwner class provides information about who owns this object. """Implements |owner| as a readonly attribute."""
If this object is a member, it points either of an interface,
a namespace, a dictionary, and so on. If this object is an argument,
it points a function like object."""
def __init__(self, owner): def __init__(self, owner):
assert isinstance(owner, object) # None is okay assert isinstance(owner, object) and owner is not None
self._owner = owner self._owner = owner
@property @property
def owner(self): def owner(self):
"""
Returns the owner of this instance.
@return object
"""
return self._owner return self._owner
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithExposure from .composition_parts import WithExposure
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .idl_member import IdlMember from .idl_member import IdlMember
from .idl_type import IdlType from .idl_type import IdlType
from .values import ConstantValue from .values import ConstantValue
......
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithComponent
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithOwner from .composition_parts import WithDebugInfo
from .composition_parts import WithOwner
from .idl_member import IdlMember from .idl_member import IdlMember
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .common import WithOwner from .composition_parts import WithOwner
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
from .idl_type import IdlType from .idl_type import IdlType
from .reference import RefById from .reference import RefById
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithExtendedAttributes from .composition_parts import WithDebugInfo
from .composition_parts import WithExtendedAttributes
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
from .user_defined_type import UserDefinedType from .user_defined_type import UserDefinedType
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithIdentifier from .composition_parts import Identifier
from .composition_parts import WithIdentifier
class IdentifierIRMap(object): class IdentifierIRMap(object):
...@@ -169,6 +170,7 @@ class IdentifierIRMap(object): ...@@ -169,6 +170,7 @@ class IdentifierIRMap(object):
If |skip_current_phase| is True, skips the current phase when looking If |skip_current_phase| is True, skips the current phase when looking
for the identifier. for the identifier.
""" """
assert isinstance(identifier, Identifier)
start_phase = self._current_phase - (1 if skip_current_phase else 0) start_phase = self._current_phase - (1 if skip_current_phase else 0)
for irs_per_phase in self._single_value_irs[start_phase::-1]: for irs_per_phase in self._single_value_irs[start_phase::-1]:
for irs_per_kind in irs_per_phase.values(): for irs_per_kind in irs_per_phase.values():
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExposure from .composition_parts import WithExposure
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .common import WithOwner from .composition_parts import WithOwner
class IdlMember(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo, class IdlMember(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo,
......
...@@ -6,10 +6,10 @@ import exceptions ...@@ -6,10 +6,10 @@ import exceptions
from blinkbuild.name_style_converter import NameStyleConverter from blinkbuild.name_style_converter import NameStyleConverter
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .reference import Proxy from .reference import Proxy
from .reference import RefById from .reference import RefById
from .typedef import Typedef from .typedef import Typedef
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import Identifier
from .common import WithDebugInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
...@@ -20,6 +22,9 @@ class Includes(WithComponent, WithDebugInfo): ...@@ -20,6 +22,9 @@ class Includes(WithComponent, WithDebugInfo):
code_generator_info=None, code_generator_info=None,
component=None, component=None,
debug_info=None): debug_info=None):
assert isinstance(interface_identifier, Identifier)
assert isinstance(mixin_identifier, Identifier)
# Includes statements are treated similarly to partial # Includes statements are treated similarly to partial
# definitions, and it's convenient for IdlCompiler that # definitions, and it's convenient for IdlCompiler that
# 'includes' are grouped by interface's identifier, i.e. # 'includes' are grouped by interface's identifier, i.e.
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
import exceptions import exceptions
from .attribute import Attribute from .attribute import Attribute
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExposure from .composition_parts import WithExposure
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .constant import Constant from .constant import Constant
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
from .idl_member import IdlMember from .idl_member import IdlMember
......
...@@ -7,8 +7,10 @@ from .ast_group import AstGroup ...@@ -7,8 +7,10 @@ from .ast_group import AstGroup
from .attribute import Attribute from .attribute import Attribute
from .callback_function import CallbackFunction from .callback_function import CallbackFunction
from .callback_interface import CallbackInterface from .callback_interface import CallbackInterface
from .common import DebugInfo from .composition_parts import Component
from .common import Location from .composition_parts import DebugInfo
from .composition_parts import Identifier
from .composition_parts import Location
from .constant import Constant from .constant import Constant
from .dictionary import Dictionary from .dictionary import Dictionary
from .dictionary import DictionaryMember from .dictionary import DictionaryMember
...@@ -48,7 +50,7 @@ def load_and_register_idl_definitions( ...@@ -48,7 +50,7 @@ def load_and_register_idl_definitions(
for filepath in filepaths: for filepath in filepaths:
asts_per_component = AstGroup.read_from_file(filepath) asts_per_component = AstGroup.read_from_file(filepath)
component = asts_per_component.component component = Component(asts_per_component.component)
builder = _IRBuilder( builder = _IRBuilder(
component=component, component=component,
create_ref_to_idl_def=create_ref_to_idl_def, create_ref_to_idl_def=create_ref_to_idl_def,
...@@ -128,7 +130,7 @@ class _IRBuilder(object): ...@@ -128,7 +130,7 @@ class _IRBuilder(object):
# |property_handlers|. # |property_handlers|.
return Interface.IR( return Interface.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
is_partial=bool(node.GetProperty('PARTIAL')), is_partial=bool(node.GetProperty('PARTIAL')),
is_mixin=bool(node.GetProperty('MIXIN')), is_mixin=bool(node.GetProperty('MIXIN')),
inherited=inherited, inherited=inherited,
...@@ -144,7 +146,7 @@ class _IRBuilder(object): ...@@ -144,7 +146,7 @@ class _IRBuilder(object):
def _build_namespace(self, node): def _build_namespace(self, node):
namespace = Namespace.IR( namespace = Namespace.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
is_partial=bool(node.GetProperty('PARTIAL')), is_partial=bool(node.GetProperty('PARTIAL')),
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
...@@ -158,7 +160,7 @@ class _IRBuilder(object): ...@@ -158,7 +160,7 @@ class _IRBuilder(object):
extended_attributes = self._take_extended_attributes(child_nodes) extended_attributes = self._take_extended_attributes(child_nodes)
assert len(child_nodes) == 0 assert len(child_nodes) == 0
return Attribute.IR( return Attribute.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
idl_type=idl_type, idl_type=idl_type,
is_static=bool(node.GetProperty('STATIC')), is_static=bool(node.GetProperty('STATIC')),
is_readonly=bool(node.GetProperty('READONLY')), is_readonly=bool(node.GetProperty('READONLY')),
...@@ -176,7 +178,7 @@ class _IRBuilder(object): ...@@ -176,7 +178,7 @@ class _IRBuilder(object):
# constant, hence we need to skip one level. # constant, hence we need to skip one level.
idl_type = self._build_type_internal(child_nodes) idl_type = self._build_type_internal(child_nodes)
return Constant.IR( return Constant.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
value=value, value=value,
idl_type=idl_type, idl_type=idl_type,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
...@@ -190,7 +192,7 @@ class _IRBuilder(object): ...@@ -190,7 +192,7 @@ class _IRBuilder(object):
extended_attributes = self._take_extended_attributes(child_nodes) extended_attributes = self._take_extended_attributes(child_nodes)
assert len(child_nodes) == 0 assert len(child_nodes) == 0
return Operation.IR( return Operation.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
arguments=arguments, arguments=arguments,
return_type=return_type, return_type=return_type,
is_static=bool(node.GetProperty('STATIC')), is_static=bool(node.GetProperty('STATIC')),
...@@ -212,7 +214,7 @@ class _IRBuilder(object): ...@@ -212,7 +214,7 @@ class _IRBuilder(object):
own_members = map(self._build_dictionary_member, child_nodes) own_members = map(self._build_dictionary_member, child_nodes)
return Dictionary.IR( return Dictionary.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
is_partial=bool(node.GetProperty('PARTIAL')), is_partial=bool(node.GetProperty('PARTIAL')),
inherited=inherited, inherited=inherited,
own_members=own_members, own_members=own_members,
...@@ -231,7 +233,7 @@ class _IRBuilder(object): ...@@ -231,7 +233,7 @@ class _IRBuilder(object):
assert len(child_nodes) == 0 assert len(child_nodes) == 0
return DictionaryMember.IR( return DictionaryMember.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
idl_type=idl_type, idl_type=idl_type,
default_value=default_value, default_value=default_value,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
...@@ -240,7 +242,7 @@ class _IRBuilder(object): ...@@ -240,7 +242,7 @@ class _IRBuilder(object):
def _build_callback_interface(self, node): def _build_callback_interface(self, node):
callback_interface = CallbackInterface.IR( callback_interface = CallbackInterface.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
# TODO(peria): Build members and register them in |callback_interface| # TODO(peria): Build members and register them in |callback_interface|
...@@ -248,7 +250,7 @@ class _IRBuilder(object): ...@@ -248,7 +250,7 @@ class _IRBuilder(object):
def _build_callback_function(self, node): def _build_callback_function(self, node):
callback_function = CallbackFunction.IR( callback_function = CallbackFunction.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
# TODO(peria): Build members and register them in |callback_function| # TODO(peria): Build members and register them in |callback_function|
...@@ -256,7 +258,7 @@ class _IRBuilder(object): ...@@ -256,7 +258,7 @@ class _IRBuilder(object):
def _build_enumeration(self, node): def _build_enumeration(self, node):
enumeration = Enumeration.IR( enumeration = Enumeration.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
values=[child.GetName() for child in node.GetChildren()], values=[child.GetName() for child in node.GetChildren()],
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
...@@ -268,7 +270,7 @@ class _IRBuilder(object): ...@@ -268,7 +270,7 @@ class _IRBuilder(object):
assert len(child_nodes) == 0 assert len(child_nodes) == 0
typedef = Typedef.IR( typedef = Typedef.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
idl_type=idl_type, idl_type=idl_type,
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
...@@ -276,8 +278,8 @@ class _IRBuilder(object): ...@@ -276,8 +278,8 @@ class _IRBuilder(object):
def _build_includes(self, node): def _build_includes(self, node):
includes = Includes.IR( includes = Includes.IR(
interface_identifier=node.GetName(), interface_identifier=Identifier(node.GetName()),
mixin_identifier=node.GetProperty('REFERENCE'), mixin_identifier=Identifier(node.GetProperty('REFERENCE')),
component=self._component, component=self._component,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
return includes return includes
...@@ -296,7 +298,7 @@ class _IRBuilder(object): ...@@ -296,7 +298,7 @@ class _IRBuilder(object):
extended_attributes = self._take_extended_attributes(child_nodes) extended_attributes = self._take_extended_attributes(child_nodes)
assert len(child_nodes) == 0 assert len(child_nodes) == 0
return Argument.IR( return Argument.IR(
identifier=node.GetName(), identifier=Identifier(node.GetName()),
index=index, index=index,
idl_type=idl_type, idl_type=idl_type,
default_value=default_value, default_value=default_value,
...@@ -329,8 +331,8 @@ class _IRBuilder(object): ...@@ -329,8 +331,8 @@ class _IRBuilder(object):
def _build_inheritance(self, node): def _build_inheritance(self, node):
assert node.GetClass() == 'Inherit' assert node.GetClass() == 'Inherit'
return self._create_ref_to_idl_def(node.GetName(), return self._create_ref_to_idl_def(
self._build_debug_info(node)) Identifier(node.GetName()), self._build_debug_info(node))
def _build_is_variadic_argument(self, node): def _build_is_variadic_argument(self, node):
# idl_parser produces the following tree to indicate an argument is # idl_parser produces the following tree to indicate an argument is
...@@ -434,10 +436,9 @@ class _IRBuilder(object): ...@@ -434,10 +436,9 @@ class _IRBuilder(object):
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
def build_reference_type(node, extended_attributes): def build_reference_type(node, extended_attributes):
identifier = node.GetName()
return self._idl_type_factory.reference_type( return self._idl_type_factory.reference_type(
ref_to_idl_type=self._create_ref_to_idl_type( ref_to_idl_type=self._create_ref_to_idl_type(
identifier, self._build_debug_info(node)), Identifier(node.GetName()), self._build_debug_info(node)),
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
debug_info=self._build_debug_info(node)) debug_info=self._build_debug_info(node))
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .common import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithCodeGeneratorInfo
from .common import WithDebugInfo from .composition_parts import WithComponent
from .common import WithExposure from .composition_parts import WithDebugInfo
from .common import WithExtendedAttributes from .composition_parts import WithExposure
from .common import WithIdentifier from .composition_parts import WithExtendedAttributes
from .composition_parts import WithIdentifier
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
......
...@@ -3,14 +3,15 @@ ...@@ -3,14 +3,15 @@
# found in the LICENSE file. # found in the LICENSE file.
import exceptions import exceptions
from .argument import Argument from .argument import Argument
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithExposure from .composition_parts import WithExposure
from .common import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .common import WithOwner from .composition_parts import WithOwner
from .idl_member import IdlMember from .idl_member import IdlMember
from .idl_type import IdlType from .idl_type import IdlType
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import DebugInfo from .composition_parts import DebugInfo
from .common import WithIdentifier from .composition_parts import WithIdentifier
class Proxy(object): class Proxy(object):
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .common import WithComponent from .composition_parts import WithComponent
from .common import WithDebugInfo from .composition_parts import WithDebugInfo
from .common import WithIdentifier from .composition_parts import WithIdentifier
from .identifier_ir_map import IdentifierIRMap from .identifier_ir_map import IdentifierIRMap
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
from .common import WithIdentifier from .composition_parts import WithIdentifier
class UserDefinedType(WithIdentifier): class UserDefinedType(WithIdentifier):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment