Commit 851b93f9 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

bind-gen: Expose NodeFilter to Window in the new bindings generator

NodeFilter is only the callback interface that needs to be exposed
on a global object (Window).

Bug: 839389
Change-Id: If3498ebda9b98fb2e35349a9bc6322631afe8ff8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135678Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756589}
parent 88c15bf3
...@@ -39,7 +39,9 @@ def v8_bridge_class_name(idl_definition): ...@@ -39,7 +39,9 @@ def v8_bridge_class_name(idl_definition):
""" """
Returns the name of V8-from/to-Blink bridge class. Returns the name of V8-from/to-Blink bridge class.
""" """
assert isinstance(idl_definition, (web_idl.Namespace, web_idl.Interface)) assert isinstance(
idl_definition,
(web_idl.CallbackInterface, web_idl.Interface, web_idl.Namespace))
assert idl_definition.identifier[0].isupper() assert idl_definition.identifier[0].isupper()
# Do not apply |name_style.class_| due to the same reason as # Do not apply |name_style.class_| due to the same reason as
......
...@@ -6,22 +6,23 @@ from .code_generator_info import CodeGeneratorInfo ...@@ -6,22 +6,23 @@ 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
from .composition_parts import WithExposure
from .composition_parts import WithExtendedAttributes from .composition_parts import WithExtendedAttributes
from .constant import Constant from .constant import Constant
from .operation import Operation
from .operation import OperationGroup
from .ir_map import IRMap from .ir_map import IRMap
from .make_copy import make_copy from .make_copy import make_copy
from .operation import Operation
from .operation import OperationGroup
from .user_defined_type import UserDefinedType from .user_defined_type import UserDefinedType
class CallbackInterface(UserDefinedType, WithExtendedAttributes, class CallbackInterface(UserDefinedType, WithExtendedAttributes,
WithCodeGeneratorInfo, WithComponent, WithDebugInfo): WithCodeGeneratorInfo, WithExposure, WithComponent,
WithDebugInfo):
"""https://heycam.github.io/webidl/#idl-interfaces""" """https://heycam.github.io/webidl/#idl-interfaces"""
class IR(IRMap.IR, WithExtendedAttributes, WithCodeGeneratorInfo, class IR(IRMap.IR, WithExtendedAttributes, WithCodeGeneratorInfo,
WithComponent, WithDebugInfo): WithExposure, WithComponent, WithDebugInfo):
def __init__(self, def __init__(self,
identifier, identifier,
constants=None, constants=None,
...@@ -47,6 +48,7 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes, ...@@ -47,6 +48,7 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
kind=IRMap.IR.Kind.CALLBACK_INTERFACE) kind=IRMap.IR.Kind.CALLBACK_INTERFACE)
WithExtendedAttributes.__init__(self, extended_attributes) WithExtendedAttributes.__init__(self, extended_attributes)
WithCodeGeneratorInfo.__init__(self) WithCodeGeneratorInfo.__init__(self)
WithExposure.__init__(self)
WithComponent.__init__(self, component) WithComponent.__init__(self, component)
WithDebugInfo.__init__(self, debug_info) WithDebugInfo.__init__(self, debug_info)
...@@ -59,6 +61,12 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes, ...@@ -59,6 +61,12 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
self.operations = operations self.operations = operations
self.operation_groups = [] self.operation_groups = []
def iter_all_members(self):
for constant in self.constants:
yield constant
for operation in self.operations:
yield operation
def __init__(self, ir): def __init__(self, ir):
assert isinstance(ir, CallbackInterface.IR) assert isinstance(ir, CallbackInterface.IR)
...@@ -66,6 +74,7 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes, ...@@ -66,6 +74,7 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
UserDefinedType.__init__(self, ir.identifier) UserDefinedType.__init__(self, ir.identifier)
WithExtendedAttributes.__init__(self, ir, readonly=True) WithExtendedAttributes.__init__(self, ir, readonly=True)
WithCodeGeneratorInfo.__init__(self, ir, readonly=True) WithCodeGeneratorInfo.__init__(self, ir, readonly=True)
WithExposure.__init__(self, ir, readonly=True)
WithComponent.__init__(self, ir, readonly=True) WithComponent.__init__(self, ir, readonly=True)
WithDebugInfo.__init__(self, ir) WithDebugInfo.__init__(self, ir)
self._constants = tuple([ self._constants = tuple([
...@@ -83,11 +92,36 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes, ...@@ -83,11 +92,36 @@ class CallbackInterface(UserDefinedType, WithExtendedAttributes,
owner=self) for operation_group_ir in ir.operation_groups owner=self) for operation_group_ir in ir.operation_groups
]) ])
@property
def attributes(self):
"""Returns attributes."""
return ()
@property @property
def constants(self): def constants(self):
"""Returns constants.""" """Returns constants."""
return self._constants return self._constants
@property
def constructors(self):
"""Returns constructors."""
return ()
@property
def constructor_groups(self):
"""Returns groups of constructors."""
return ()
@property
def named_constructors(self):
"""Returns named constructors."""
return ()
@property
def named_constructor_groups(self):
"""Returns groups of overloaded named constructors."""
return ()
@property @property
def operations(self): def operations(self):
"""Returns operations.""" """Returns operations."""
......
...@@ -243,9 +243,10 @@ class IdlCompiler(object): ...@@ -243,9 +243,10 @@ class IdlCompiler(object):
default_value=True) default_value=True)
old_irs = self._ir_map.irs_of_kinds( old_irs = self._ir_map.irs_of_kinds(
IRMap.IR.Kind.DICTIONARY, IRMap.IR.Kind.INTERFACE, IRMap.IR.Kind.CALLBACK_INTERFACE, IRMap.IR.Kind.DICTIONARY,
IRMap.IR.Kind.INTERFACE_MIXIN, IRMap.IR.Kind.NAMESPACE, IRMap.IR.Kind.INTERFACE, IRMap.IR.Kind.INTERFACE_MIXIN,
IRMap.IR.Kind.PARTIAL_DICTIONARY, IRMap.IR.Kind.PARTIAL_INTERFACE, IRMap.IR.Kind.NAMESPACE, IRMap.IR.Kind.PARTIAL_DICTIONARY,
IRMap.IR.Kind.PARTIAL_INTERFACE,
IRMap.IR.Kind.PARTIAL_INTERFACE_MIXIN, IRMap.IR.Kind.PARTIAL_INTERFACE_MIXIN,
IRMap.IR.Kind.PARTIAL_NAMESPACE) IRMap.IR.Kind.PARTIAL_NAMESPACE)
...@@ -489,7 +490,8 @@ class IdlCompiler(object): ...@@ -489,7 +490,8 @@ class IdlCompiler(object):
ExtendedAttribute(key='Affects', values='Nothing')) ExtendedAttribute(key='Affects', values='Nothing'))
def _calculate_group_exposure(self): def _calculate_group_exposure(self):
old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE, old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.CALLBACK_INTERFACE,
IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.NAMESPACE) IRMap.IR.Kind.NAMESPACE)
self._ir_map.move_to_new_phase() self._ir_map.move_to_new_phase()
...@@ -548,6 +550,8 @@ class IdlCompiler(object): ...@@ -548,6 +550,8 @@ class IdlCompiler(object):
group.exposure.set_only_in_secure_contexts(flag_names) group.exposure.set_only_in_secure_contexts(flag_names)
def _fill_exposed_constructs(self): def _fill_exposed_constructs(self):
old_callback_interfaces = self._ir_map.irs_of_kind(
IRMap.IR.Kind.CALLBACK_INTERFACE)
old_interfaces = self._ir_map.irs_of_kind(IRMap.IR.Kind.INTERFACE) old_interfaces = self._ir_map.irs_of_kind(IRMap.IR.Kind.INTERFACE)
old_namespaces = self._ir_map.irs_of_kind(IRMap.IR.Kind.NAMESPACE) old_namespaces = self._ir_map.irs_of_kind(IRMap.IR.Kind.NAMESPACE)
...@@ -578,7 +582,8 @@ class IdlCompiler(object): ...@@ -578,7 +582,8 @@ class IdlCompiler(object):
exposed_map = {} # global name: [construct's identifier...] exposed_map = {} # global name: [construct's identifier...]
legacy_window_aliases = [] legacy_window_aliases = []
for ir in itertools.chain(old_interfaces, old_namespaces): for ir in itertools.chain(old_callback_interfaces, old_interfaces,
old_namespaces):
for pair in ir.exposure.global_names_and_features: for pair in ir.exposure.global_names_and_features:
exposed_map.setdefault(pair.global_name, exposed_map.setdefault(pair.global_name,
[]).append(ir.identifier) []).append(ir.identifier)
......
...@@ -134,6 +134,16 @@ class Namespace(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo, ...@@ -134,6 +134,16 @@ class Namespace(UserDefinedType, WithExtendedAttributes, WithCodeGeneratorInfo,
"""Returns groups of constructors.""" """Returns groups of constructors."""
return () return ()
@property
def named_constructors(self):
"""Returns named constructors."""
return ()
@property
def named_constructor_groups(self):
"""Returns groups of overloaded named constructors."""
return ()
@property @property
def operations(self): def operations(self):
"""Returns operations.""" """Returns operations."""
......
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