Skip to content
This repository has been archived by the owner on Jul 18, 2018. It is now read-only.

Commit

Permalink
bindings: Remove support for exception interfaces.
Browse files Browse the repository at this point in the history
They were removed from the WebIDL spec in 2014 ("Removed IDL exceptions,
baked in DOMException, and added Error and DOMException as types"):
whatwg/webidl@50e172e

Support for exception interfaces was implemented by treating them like
WebIDL interfaces and setting |is_exception| in IdlException (which
inherited from IdlInterface). Since DOMException was the only exception
interface we had in the tree, we can just turn it into a proper interface,
check for its name when we need to set |is_exception| and remove all the
lexer/parser/bindings scaffolding we had.

V8DOMException.{cpp,h} generated after the new DOMException.idl have been
verified to be identical to their previous version.

There is work upstream to make DOMException a proper interface (see
whatwg/webidl#378). This change can go in regardless
of the upstream pull request upstream takes, as exception interfaces have
been dead and gone for years.

Bug: 617899, 737497
Change-Id: Iea16c7da733180cd61b14471d0758d5dd68158dc
Reviewed-on: https://chromium-review.googlesource.com/558088
Reviewed-by: Kenichi Ishibashi <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Commit-Queue: Raphael Kubo da Costa (rakuco) <[email protected]>
Cr-Commit-Position: refs/heads/master@{#483921}
  • Loading branch information
Raphael Kubo da Costa authored and Commit Bot committed Jul 2, 2017
1 parent 829f2e0 commit 0680af0
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 552 deletions.
70 changes: 2 additions & 68 deletions third_party/WebKit/Source/bindings/scripts/idl_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
IdlIterable < IdlIterableOrMaplikeOrSetlike
IdlMaplike < IdlIterableOrMaplikeOrSetlike
IdlSetlike < IdlIterableOrMaplikeOrSetlike
IdlException < IdlInterface
(same contents as IdlInterface)
TypedObject :: Object with one or more attributes that is a type.
Expand Down Expand Up @@ -115,10 +113,6 @@ def __init__(self, node):
if child_class == 'Interface':
interface = IdlInterface(child)
self.interfaces[interface.name] = interface
elif child_class == 'Exception':
exception = IdlException(child)
# For simplicity, treat exceptions as interfaces
self.interfaces[exception.name] = exception
elif child_class == 'Typedef':
typedef = IdlTypedef(child)
self.typedefs[typedef.name] = typedef
Expand Down Expand Up @@ -287,11 +281,11 @@ def accept(self, visitor):


################################################################################
# Interfaces and Exceptions
# Interfaces
################################################################################

class IdlInterface(object):
def __init__(self, node=None):
def __init__(self, node):
self.attributes = []
self.constants = []
self.constructors = []
Expand All @@ -307,11 +301,8 @@ def __init__(self, node=None):
self.setlike = None
self.original_interface = None
self.partial_interfaces = []
if not node: # Early exit for IdlException.__init__
return

self.is_callback = bool(node.GetProperty('CALLBACK'))
self.is_exception = False
# FIXME: uppercase 'Partial' => 'PARTIAL' in base IDL parser
self.is_partial = bool(node.GetProperty('Partial'))
self.name = node.GetName()
Expand Down Expand Up @@ -420,42 +411,6 @@ def merge(self, other):
self.stringifier = other.stringifier


class IdlException(IdlInterface):
# Properly exceptions and interfaces are distinct, and thus should inherit a
# common base class (say, "IdlExceptionOrInterface").
# However, there is only one exception (DOMException), and new exceptions
# are not expected. Thus it is easier to implement exceptions as a
# restricted subclass of interfaces.
# http://www.w3.org/TR/WebIDL/#idl-exceptions
def __init__(self, node):
# Exceptions are similar to Interfaces, but simpler
IdlInterface.__init__(self)
self.is_callback = False
self.is_exception = True
self.is_partial = False
self.name = node.GetName()
self.idl_type = IdlType(self.name)

children = node.GetChildren()
for child in children:
child_class = child.GetClass()
if child_class == 'Attribute':
attribute = IdlAttribute(child)
self.attributes.append(attribute)
elif child_class == 'Const':
self.constants.append(IdlConstant(child))
elif child_class == 'ExtAttributes':
extended_attributes = ext_attributes_node_to_extended_attributes(child)
self.constructors, self.custom_constructors = (
extended_attributes_to_constructors(extended_attributes))
clear_constructor_attributes(extended_attributes)
self.extended_attributes = extended_attributes
elif child_class == 'ExceptionOperation':
self.operations.append(IdlOperation.from_exception_operation_node(child))
else:
raise ValueError('Unrecognized node class: %s' % child_class)


################################################################################
# Attributes
################################################################################
Expand Down Expand Up @@ -616,27 +571,6 @@ def __init__(self, node=None):
else:
raise ValueError('Unrecognized node class: %s' % child_class)

@classmethod
def from_exception_operation_node(cls, node):
# Needed to handle one case in DOMException.idl:
# // Override in a Mozilla compatible format
# [NotEnumerable] DOMString toString();
# FIXME: can we remove this? replace with a stringifier?
operation = cls()
operation.name = node.GetName()
children = node.GetChildren()
if len(children) < 1 or len(children) > 2:
raise ValueError('ExceptionOperation node with %s children, expected 1 or 2' % len(children))

type_node = children[0]
operation.idl_type = type_node_to_type(type_node)

if len(children) > 1:
ext_attributes_node = children[1]
operation.extended_attributes = ext_attributes_node_to_extended_attributes(ext_attributes_node)

return operation

@classmethod
def constructor_from_arguments_node(cls, name, arguments_node):
constructor = cls()
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/Source/bindings/scripts/idl_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def validate_blink_idl_definitions(idl_filename, idl_file_basename,
"""Validate file contents with filename convention.
The Blink IDL conventions are:
- If an IDL file defines an interface, a dictionary, or an exception,
- If an IDL file defines an interface or a dictionary,
the IDL file must contain exactly one definition. The definition
name must agree with the file's basename, unless it is a partial
definition. (e.g., 'partial interface Foo' can be in FooBar.idl).
Expand Down
4 changes: 2 additions & 2 deletions third_party/WebKit/Source/bindings/scripts/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def should_generate_impl_file_from_idl(file_contents):
"""True when a given IDL file contents could generate .h/.cpp files."""
# FIXME: This would be error-prone and we should use AST rather than
# improving the regexp pattern.
match = re.search(r'(interface|dictionary|exception)\s+\w+', file_contents)
match = re.search(r'(interface|dictionary)\s+\w+', file_contents)
return bool(match)


Expand All @@ -370,7 +370,7 @@ def match_interface_extended_attributes_from_idl(file_contents):

match = re.search(
r'\[([^[]*)\]\s*'
r'(interface|callback\s+interface|partial\s+interface|exception)\s+'
r'(interface|callback\s+interface|partial\s+interface)\s+'
r'\w+\s*'
r'(:\s*\w+\s*)?'
r'{',
Expand Down
8 changes: 7 additions & 1 deletion third_party/WebKit/Source/bindings/scripts/v8_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ def interface_context(interface, interfaces):
# as in the WebIDL spec?
is_immutable_prototype = is_global or 'ImmutablePrototype' in extended_attributes

# DOMException is defined in WebIDL and is the only object that resembles
# the concept of an "exception interface" (which was removed from the spec
# in 2014). |is_exception == true| is mostly used to make the prototype
# object inherit from %ErrorPrototype% in V8PerContextData.
is_exception = interface.name == 'DOMException'

wrapper_class_id = ('kNodeClassId' if inherits_interface(interface.name, 'Node') else 'kObjectClassId')

# [ActiveScriptWrappable] must be accompanied with [DependentLifetime].
Expand Down Expand Up @@ -274,7 +280,7 @@ def interface_context(interface, interfaces):
'is_array_buffer_or_view': is_array_buffer_or_view,
'is_check_security': is_check_security,
'is_event_target': is_event_target,
'is_exception': interface.is_exception,
'is_exception': is_exception,
'is_global': is_global,
'is_immutable_prototype': is_immutable_prototype,
'is_node': inherits_interface(interface.name, 'Node'),
Expand Down

This file was deleted.

Loading

0 comments on commit 0680af0

Please sign in to comment.