Commit f1e3b640 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Implement mutable and immutable CodeGeneratorInfo

Implements CodeGeneratorInfo{,Mutable} as immutable and mutable
information for bindings generators respectively.

Bug: 839389
Change-Id: Ia872b2f5aa5fd2b80a122f006ced06dae0b596c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768480
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690294}
parent 65f87ce1
...@@ -9,6 +9,7 @@ web_idl/ast_group.py ...@@ -9,6 +9,7 @@ web_idl/ast_group.py
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/code_generator_info.py
web_idl/composition_parts.py web_idl/composition_parts.py
web_idl/constant.py web_idl/constant.py
web_idl/database.py web_idl/database.py
......
...@@ -19,6 +19,7 @@ web_idl/ast_group.py ...@@ -19,6 +19,7 @@ web_idl/ast_group.py
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/code_generator_info.py
web_idl/composition_parts.py web_idl/composition_parts.py
web_idl/constant.py web_idl/constant.py
web_idl/database.py web_idl/database.py
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -52,7 +53,8 @@ class Attribute(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -52,7 +53,8 @@ class Attribute(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo,
ir = make_copy(ir) ir = make_copy(ir)
WithIdentifier.__init__(self, ir.identifier) WithIdentifier.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithOwner.__init__(self, owner) WithOwner.__init__(self, owner)
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -47,7 +48,8 @@ class CallbackFunction(UserDefinedType, FunctionLike, WithExtendedAttributes, ...@@ -47,7 +48,8 @@ class CallbackFunction(UserDefinedType, FunctionLike, WithExtendedAttributes,
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
FunctionLike.__init__(self, ir) FunctionLike.__init__(self, ir)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import exceptions import exceptions
from .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -40,7 +41,8 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes, ...@@ -40,7 +41,8 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
ir = make_copy(ir) ir = make_copy(ir)
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# The list of attributes that CodeGeneratorInfo supports. CodeGeneratorInfo's
# attributes are auto-generated from this list because they're boilerplated.
_CODE_GENERATOR_INFO_ATTRIBUTES = (
'property_implemented_as',
'receiver_implemented_as',
)
_CGI_ATTRS = tuple([
# attribute name (_foo of self._foo), getter name, setter name
('_{}'.format(attr), '{}'.format(attr), 'set_{}'.format(attr))
for attr in _CODE_GENERATOR_INFO_ATTRIBUTES
])
class CodeGeneratorInfo(object):
"""A bag of properties to be used by bindings code generators."""
def __init__(self, other=None):
"""
Initializes a new object.
If |other| is not None, initializes the new object as a copy of |other|.
If |other| is None, initializes the new object as empty.
"""
assert other is None or isinstance(other, CodeGeneratorInfo)
if other is None:
for attr_name, _, _ in _CGI_ATTRS:
setattr(self, attr_name, None)
else:
for attr_name, _, _ in _CGI_ATTRS:
setattr(self, attr_name, getattr(other, attr_name))
@staticmethod
def make_getter(attr_name):
@property
def getter(self):
return getattr(self, attr_name)
return getter
class CodeGeneratorInfoMutable(CodeGeneratorInfo):
"""Another version of CodeGeneratorInfo that supports setters."""
@staticmethod
def make_setter(attr_name):
def setter(self, value):
setattr(self, attr_name, value)
return setter
def __getstate__(self):
assert False, "CodeGeneratorInfoMutable must not be pickled."
def __setstate__(self, state):
assert False, "CodeGeneratorInfoMutable must not be pickled."
for attr_name, getter_name, setter_name in _CGI_ATTRS:
setattr(CodeGeneratorInfo, getter_name,
CodeGeneratorInfo.make_getter(attr_name))
setattr(CodeGeneratorInfoMutable, setter_name,
CodeGeneratorInfoMutable.make_setter(attr_name))
CodeGeneratorInfo.make_getter = None
CodeGeneratorInfoMutable.make_setter = None
...@@ -2,8 +2,10 @@ ...@@ -2,8 +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 .extended_attribute import ExtendedAttributes from .code_generator_info import CodeGeneratorInfo
from .code_generator_info import CodeGeneratorInfoMutable
from .exposure import Exposure from .exposure import Exposure
from .extended_attribute import ExtendedAttributes
class Identifier(str): class Identifier(str):
...@@ -35,17 +37,14 @@ class WithExtendedAttributes(object): ...@@ -35,17 +37,14 @@ class WithExtendedAttributes(object):
return self._extended_attributes return self._extended_attributes
class CodeGeneratorInfo(dict):
"""A bag of properties to be used by bindings code generators"""
class WithCodeGeneratorInfo(object): class WithCodeGeneratorInfo(object):
"""Implements |code_generator_info| as a readonly attribute.""" """Implements |code_generator_info| as a readonly attribute."""
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
or isinstance(code_generator_info, CodeGeneratorInfo)) or isinstance(code_generator_info, CodeGeneratorInfo))
self._code_generator_info = code_generator_info or CodeGeneratorInfo() self._code_generator_info = (code_generator_info
or CodeGeneratorInfoMutable())
@property @property
def code_generator_info(self): def code_generator_info(self):
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -47,7 +48,8 @@ class Constant(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -47,7 +48,8 @@ class Constant(WithIdentifier, WithExtendedAttributes, WithCodeGeneratorInfo,
ir = make_copy(ir) ir = make_copy(ir)
WithIdentifier.__init__(self, ir.identifier) WithIdentifier.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithOwner.__init__(self, owner) WithOwner.__init__(self, owner)
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -58,7 +59,8 @@ class Dictionary(UserDefinedType, WithExtendedAttributes, ...@@ -58,7 +59,8 @@ class Dictionary(UserDefinedType, WithExtendedAttributes,
ir = make_copy(ir) ir = make_copy(ir)
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
...@@ -141,7 +143,8 @@ class DictionaryMember(WithIdentifier, WithExtendedAttributes, ...@@ -141,7 +143,8 @@ class DictionaryMember(WithIdentifier, WithExtendedAttributes,
ir = make_copy(ir) ir = make_copy(ir)
WithIdentifier.__init__(self, ir.identifier) WithIdentifier.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithOwner.__init__(self, owner) WithOwner.__init__(self, owner)
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -42,7 +43,8 @@ class Enumeration(UserDefinedType, WithExtendedAttributes, ...@@ -42,7 +43,8 @@ class Enumeration(UserDefinedType, WithExtendedAttributes,
ir = make_copy(ir) ir = make_copy(ir)
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -7,7 +7,6 @@ import functools ...@@ -7,7 +7,6 @@ import functools
from blinkbuild.name_style_converter import NameStyleConverter from blinkbuild.name_style_converter import NameStyleConverter
from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
from .composition_parts import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .composition_parts import WithIdentifier from .composition_parts import WithIdentifier
...@@ -110,7 +109,7 @@ class IdlTypeFactory(object): ...@@ -110,7 +109,7 @@ class IdlTypeFactory(object):
return idl_type return idl_type
class IdlType(WithExtendedAttributes, WithCodeGeneratorInfo, WithDebugInfo): class IdlType(WithExtendedAttributes, WithDebugInfo):
""" """
Represents a 'type' in Web IDL. Represents a 'type' in Web IDL.
...@@ -130,13 +129,11 @@ class IdlType(WithExtendedAttributes, WithCodeGeneratorInfo, WithDebugInfo): ...@@ -130,13 +129,11 @@ class IdlType(WithExtendedAttributes, WithCodeGeneratorInfo, WithDebugInfo):
def __init__(self, def __init__(self,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(is_optional, bool) assert isinstance(is_optional, bool)
assert pass_key is _IDL_TYPE_PASS_KEY assert pass_key is _IDL_TYPE_PASS_KEY
WithExtendedAttributes.__init__(self, extended_attributes) WithExtendedAttributes.__init__(self, extended_attributes)
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithDebugInfo.__init__(self, debug_info) WithDebugInfo.__init__(self, debug_info)
self._is_optional = is_optional self._is_optional = is_optional
...@@ -428,7 +425,6 @@ class SimpleType(IdlType): ...@@ -428,7 +425,6 @@ class SimpleType(IdlType):
name, name,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert name in SimpleType._VALID_TYPES, ( assert name in SimpleType._VALID_TYPES, (
...@@ -437,7 +433,6 @@ class SimpleType(IdlType): ...@@ -437,7 +433,6 @@ class SimpleType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._name = name self._name = name
...@@ -507,14 +502,12 @@ class ReferenceType(IdlType, WithIdentifier, Proxy): ...@@ -507,14 +502,12 @@ class ReferenceType(IdlType, WithIdentifier, Proxy):
_attrs_to_be_proxied = set(Proxy.get_all_attributes(IdlType)).difference( _attrs_to_be_proxied = set(Proxy.get_all_attributes(IdlType)).difference(
# attributes not to be proxied # attributes not to be proxied
set(('code_generator_info', 'debug_info', 'extended_attributes', set(('debug_info', 'extended_attributes', 'is_optional')))
'is_optional')))
def __init__(self, def __init__(self,
ref_to_idl_type, ref_to_idl_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(ref_to_idl_type, RefById) assert isinstance(ref_to_idl_type, RefById)
...@@ -522,7 +515,6 @@ class ReferenceType(IdlType, WithIdentifier, Proxy): ...@@ -522,7 +515,6 @@ class ReferenceType(IdlType, WithIdentifier, Proxy):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
WithIdentifier.__init__(self, ref_to_idl_type.identifier) WithIdentifier.__init__(self, ref_to_idl_type.identifier)
...@@ -550,13 +542,11 @@ class DefinitionType(IdlType, WithIdentifier): ...@@ -550,13 +542,11 @@ class DefinitionType(IdlType, WithIdentifier):
def __init__(self, def __init__(self,
user_defined_type, user_defined_type,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(user_defined_type, UserDefinedType) assert isinstance(user_defined_type, UserDefinedType)
IdlType.__init__( IdlType.__init__(
self, self,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
WithIdentifier.__init__(self, user_defined_type.identifier) WithIdentifier.__init__(self, user_defined_type.identifier)
...@@ -620,13 +610,11 @@ class TypedefType(IdlType, WithIdentifier): ...@@ -620,13 +610,11 @@ class TypedefType(IdlType, WithIdentifier):
def __init__(self, def __init__(self,
typedef, typedef,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(typedef, Typedef) assert isinstance(typedef, Typedef)
IdlType.__init__( IdlType.__init__(
self, self,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
WithIdentifier.__init__(self, typedef.identifier) WithIdentifier.__init__(self, typedef.identifier)
...@@ -674,7 +662,6 @@ class _ArrayLikeType(IdlType): ...@@ -674,7 +662,6 @@ class _ArrayLikeType(IdlType):
element_type, element_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(element_type, IdlType) assert isinstance(element_type, IdlType)
...@@ -682,7 +669,6 @@ class _ArrayLikeType(IdlType): ...@@ -682,7 +669,6 @@ class _ArrayLikeType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._element_type = element_type self._element_type = element_type
...@@ -711,7 +697,6 @@ class SequenceType(_ArrayLikeType): ...@@ -711,7 +697,6 @@ class SequenceType(_ArrayLikeType):
element_type, element_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
_ArrayLikeType.__init__( _ArrayLikeType.__init__(
...@@ -719,7 +704,6 @@ class SequenceType(_ArrayLikeType): ...@@ -719,7 +704,6 @@ class SequenceType(_ArrayLikeType):
element_type, element_type,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
...@@ -746,7 +730,6 @@ class FrozenArrayType(_ArrayLikeType): ...@@ -746,7 +730,6 @@ class FrozenArrayType(_ArrayLikeType):
element_type, element_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
_ArrayLikeType.__init__( _ArrayLikeType.__init__(
...@@ -754,7 +737,6 @@ class FrozenArrayType(_ArrayLikeType): ...@@ -754,7 +737,6 @@ class FrozenArrayType(_ArrayLikeType):
element_type, element_type,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
...@@ -779,13 +761,11 @@ class VariadicType(_ArrayLikeType): ...@@ -779,13 +761,11 @@ class VariadicType(_ArrayLikeType):
def __init__(self, def __init__(self,
element_type, element_type,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
_ArrayLikeType.__init__( _ArrayLikeType.__init__(
self, self,
element_type, element_type,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
...@@ -816,7 +796,6 @@ class RecordType(IdlType): ...@@ -816,7 +796,6 @@ class RecordType(IdlType):
value_type, value_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(key_type, IdlType) assert isinstance(key_type, IdlType)
...@@ -825,7 +804,6 @@ class RecordType(IdlType): ...@@ -825,7 +804,6 @@ class RecordType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._key_type = key_type self._key_type = key_type
...@@ -874,7 +852,6 @@ class PromiseType(IdlType): ...@@ -874,7 +852,6 @@ class PromiseType(IdlType):
result_type, result_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(result_type, IdlType) assert isinstance(result_type, IdlType)
...@@ -882,7 +859,6 @@ class PromiseType(IdlType): ...@@ -882,7 +859,6 @@ class PromiseType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._result_type = result_type self._result_type = result_type
...@@ -929,7 +905,6 @@ class UnionType(IdlType): ...@@ -929,7 +905,6 @@ class UnionType(IdlType):
member_types, member_types,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(member_types, (list, tuple)) assert isinstance(member_types, (list, tuple))
...@@ -938,7 +913,6 @@ class UnionType(IdlType): ...@@ -938,7 +913,6 @@ class UnionType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._member_types = tuple(member_types) self._member_types = tuple(member_types)
...@@ -1016,7 +990,6 @@ class NullableType(IdlType): ...@@ -1016,7 +990,6 @@ class NullableType(IdlType):
inner_type, inner_type,
is_optional=False, is_optional=False,
extended_attributes=None, extended_attributes=None,
code_generator_info=None,
debug_info=None, debug_info=None,
pass_key=None): pass_key=None):
assert isinstance(inner_type, IdlType) assert isinstance(inner_type, IdlType)
...@@ -1024,7 +997,6 @@ class NullableType(IdlType): ...@@ -1024,7 +997,6 @@ class NullableType(IdlType):
self, self,
is_optional=is_optional, is_optional=is_optional,
extended_attributes=extended_attributes, extended_attributes=extended_attributes,
code_generator_info=code_generator_info,
debug_info=debug_info, debug_info=debug_info,
pass_key=pass_key) pass_key=pass_key)
self._inner_type = inner_type self._inner_type = inner_type
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
from .attribute import Attribute from .attribute import Attribute
from .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -95,7 +96,8 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -95,7 +96,8 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
ir = make_copy(ir) ir = make_copy(ir)
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir.extended_attributes) WithExtendedAttributes.__init__(self, ir.extended_attributes)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
...@@ -213,13 +215,12 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -213,13 +215,12 @@ class Interface(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
return True return True
class Iterable(WithCodeGeneratorInfo, WithDebugInfo): class Iterable(WithDebugInfo):
"""https://heycam.github.io/webidl/#idl-iterable""" """https://heycam.github.io/webidl/#idl-iterable"""
def __init__(self, def __init__(self,
key_type=None, key_type=None,
value_type=None, value_type=None,
code_generator_info=None,
debug_info=None): debug_info=None):
assert key_type is None or isinstance(key_type, IdlType) assert key_type is None or isinstance(key_type, IdlType)
# iterable is declared in either form of # iterable is declared in either form of
...@@ -229,7 +230,6 @@ class Iterable(WithCodeGeneratorInfo, WithDebugInfo): ...@@ -229,7 +230,6 @@ class Iterable(WithCodeGeneratorInfo, WithDebugInfo):
# to be consistent with the format of IDL. # to be consistent with the format of IDL.
assert isinstance(value_type, IdlType), "value_type must be specified" assert isinstance(value_type, IdlType), "value_type must be specified"
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithDebugInfo.__init__(self, debug_info) WithDebugInfo.__init__(self, debug_info)
self._key_type = key_type self._key_type = key_type
...@@ -246,20 +246,18 @@ class Iterable(WithCodeGeneratorInfo, WithDebugInfo): ...@@ -246,20 +246,18 @@ class Iterable(WithCodeGeneratorInfo, WithDebugInfo):
return self._value_type return self._value_type
class Maplike(WithCodeGeneratorInfo, WithDebugInfo): class Maplike(WithDebugInfo):
"""https://heycam.github.io/webidl/#idl-maplike""" """https://heycam.github.io/webidl/#idl-maplike"""
def __init__(self, def __init__(self,
key_type, key_type,
value_type, value_type,
is_readonly=False, is_readonly=False,
code_generator_info=None,
debug_info=None): debug_info=None):
assert isinstance(key_type, IdlType) assert isinstance(key_type, IdlType)
assert isinstance(value_type, IdlType) assert isinstance(value_type, IdlType)
assert isinstance(is_readonly, bool) assert isinstance(is_readonly, bool)
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithDebugInfo.__init__(self, debug_info) WithDebugInfo.__init__(self, debug_info)
self._key_type = key_type self._key_type = key_type
...@@ -291,18 +289,16 @@ class Maplike(WithCodeGeneratorInfo, WithDebugInfo): ...@@ -291,18 +289,16 @@ class Maplike(WithCodeGeneratorInfo, WithDebugInfo):
return self._is_readonly return self._is_readonly
class Setlike(WithCodeGeneratorInfo, WithDebugInfo): class Setlike(WithDebugInfo):
"""https://heycam.github.io/webidl/#idl-setlike""" """https://heycam.github.io/webidl/#idl-setlike"""
def __init__(self, def __init__(self,
value_type, value_type,
is_readonly=False, is_readonly=False,
code_generator_info=None,
debug_info=None): debug_info=None):
assert isinstance(value_type, IdlType) assert isinstance(value_type, IdlType)
assert isinstance(is_readonly, bool) assert isinstance(is_readonly, bool)
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithDebugInfo.__init__(self, debug_info) WithDebugInfo.__init__(self, debug_info)
self._value_type = value_type self._value_type = value_type
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +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 .code_generator_info import CodeGeneratorInfo
from .composition_parts import WithCodeGeneratorInfo from .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
...@@ -34,7 +35,8 @@ class Typedef(WithIdentifier, WithCodeGeneratorInfo, WithComponent, ...@@ -34,7 +35,8 @@ class Typedef(WithIdentifier, WithCodeGeneratorInfo, WithComponent,
ir = make_copy(ir) ir = make_copy(ir)
WithIdentifier.__init__(self, ir.identifier) WithIdentifier.__init__(self, ir.identifier)
WithCodeGeneratorInfo.__init__(self, ir.code_generator_info) WithCodeGeneratorInfo.__init__(
self, CodeGeneratorInfo(ir.code_generator_info))
WithComponent.__init__(self, components=ir.components) WithComponent.__init__(self, components=ir.components)
WithDebugInfo.__init__(self, ir.debug_info) WithDebugInfo.__init__(self, ir.debug_info)
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# 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 .composition_parts import WithCodeGeneratorInfo
from .composition_parts import WithComponent from .composition_parts import WithComponent
from .composition_parts import WithDebugInfo from .composition_parts import WithDebugInfo
from .composition_parts import WithIdentifier from .composition_parts import WithIdentifier
...@@ -10,8 +9,7 @@ from .idl_type import IdlType ...@@ -10,8 +9,7 @@ from .idl_type import IdlType
from .typedef import Typedef from .typedef import Typedef
class Union(WithIdentifier, WithCodeGeneratorInfo, WithComponent, class Union(WithIdentifier, WithComponent, WithDebugInfo):
WithDebugInfo):
""" """
Union class makes a group of union types with the same flattened member Union class makes a group of union types with the same flattened member
types and the same result whether it includes a nullable type or not. types and the same result whether it includes a nullable type or not.
...@@ -79,7 +77,6 @@ class Union(WithIdentifier, WithCodeGeneratorInfo, WithComponent, ...@@ -79,7 +77,6 @@ class Union(WithIdentifier, WithCodeGeneratorInfo, WithComponent,
idl_type.apply_to_all_composing_elements(collect_components) idl_type.apply_to_all_composing_elements(collect_components)
WithIdentifier.__init__(self, identifier) WithIdentifier.__init__(self, identifier)
WithCodeGeneratorInfo.__init__(self)
WithComponent.__init__(self, components=sorted(components)) WithComponent.__init__(self, components=sorted(components))
WithDebugInfo.__init__(self) WithDebugInfo.__init__(self)
......
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