Commit 32463903 authored by jl@opera.com's avatar jl@opera.com

Move IdlType.may_raise_exception_on_conversion to v8_types.py

Also rename it v8_conversion_needs_exception_state, which is exactly what
it means.  The old name is somewhat misleading, since other conversions
can typically also raise exceptions in practice; the difference is whether
the conversion function does so via (and thus expects) an ExceptionState
argument.

Defining it in v8_types.py makes sense since this is a property of the
V8 bindings layer's conversion API for the type, not of the type itself.

Review URL: https://codereview.chromium.org/556893002

git-svn-id: svn://svn.chromium.org/blink/trunk@181669 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2a21ec67
...@@ -196,11 +196,6 @@ class IdlType(IdlTypeBase): ...@@ -196,11 +196,6 @@ class IdlType(IdlTypeBase):
def is_string_type(self): def is_string_type(self):
return self.name in STRING_TYPES return self.name in STRING_TYPES
@property
def may_raise_exception_on_conversion(self):
return (self.is_integer_type or
self.name in ('ByteString', 'ScalarValueString'))
@property @property
def is_union_type(self): def is_union_type(self):
return isinstance(self, IdlUnionType) return isinstance(self, IdlUnionType)
......
...@@ -327,7 +327,7 @@ def setter_context(interface, attribute, context): ...@@ -327,7 +327,7 @@ def setter_context(interface, attribute, context):
'has_setter_exception_state': 'has_setter_exception_state':
is_setter_raises_exception or has_type_checking_interface or is_setter_raises_exception or has_type_checking_interface or
context['has_type_checking_unrestricted'] or context['has_type_checking_unrestricted'] or
idl_type.may_raise_exception_on_conversion, idl_type.v8_conversion_needs_exception_state,
'has_type_checking_interface': has_type_checking_interface, 'has_type_checking_interface': has_type_checking_interface,
'is_setter_call_with_execution_context': v8_utilities.has_extended_attribute_value( 'is_setter_call_with_execution_context': v8_utilities.has_extended_attribute_value(
attribute, 'SetterCallWith', 'ExecutionContext'), attribute, 'SetterCallWith', 'ExecutionContext'),
......
...@@ -911,7 +911,7 @@ def constructor_context(interface, constructor): ...@@ -911,7 +911,7 @@ def constructor_context(interface, constructor):
is_constructor_raises_exception or is_constructor_raises_exception or
any(argument for argument in constructor.arguments any(argument for argument in constructor.arguments
if argument.idl_type.name == 'SerializedScriptValue' or if argument.idl_type.name == 'SerializedScriptValue' or
argument.idl_type.may_raise_exception_on_conversion), argument.idl_type.v8_conversion_needs_exception_state),
'is_call_with_document': 'is_call_with_document':
# [ConstructorCallWith=Document] # [ConstructorCallWith=Document]
has_extended_attribute_value(interface, has_extended_attribute_value(interface,
......
...@@ -164,7 +164,7 @@ def method_context(interface, method): ...@@ -164,7 +164,7 @@ def method_context(interface, method):
is_check_security_for_window or is_check_security_for_window or
any(argument for argument in arguments any(argument for argument in arguments
if argument.idl_type.name == 'SerializedScriptValue' or if argument.idl_type.name == 'SerializedScriptValue' or
argument.idl_type.may_raise_exception_on_conversion), argument.idl_type.v8_conversion_needs_exception_state),
'idl_type': idl_type.base_type, 'idl_type': idl_type.base_type,
'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'), 'is_call_with_execution_context': has_extended_attribute_value(method, 'CallWith', 'ExecutionContext'),
'is_call_with_script_arguments': is_call_with_script_arguments, 'is_call_with_script_arguments': is_call_with_script_arguments,
......
...@@ -473,6 +473,13 @@ V8_VALUE_TO_CPP_VALUE = { ...@@ -473,6 +473,13 @@ V8_VALUE_TO_CPP_VALUE = {
} }
def v8_conversion_needs_exception_state(idl_type):
return (idl_type.is_integer_type or
idl_type.name in ('ByteString', 'ScalarValueString'))
IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_exception_state)
def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate): def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate):
if idl_type.name == 'void': if idl_type.name == 'void':
return '' return ''
...@@ -489,7 +496,7 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat ...@@ -489,7 +496,7 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat
if 'EnforceRange' in extended_attributes: if 'EnforceRange' in extended_attributes:
arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
elif idl_type.may_raise_exception_on_conversion: elif idl_type.v8_conversion_needs_exception_state:
arguments = ', '.join([v8_value, 'exceptionState']) arguments = ', '.join([v8_value, 'exceptionState'])
else: else:
arguments = v8_value arguments = v8_value
...@@ -544,7 +551,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl ...@@ -544,7 +551,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
args = [variable_name, cpp_value] args = [variable_name, cpp_value]
if idl_type.base_type == 'DOMString': if idl_type.base_type == 'DOMString':
macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID' macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID'
elif idl_type.may_raise_exception_on_conversion: elif idl_type.v8_conversion_needs_exception_state:
macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE' macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE'
args.append('exceptionState') args.append('exceptionState')
else: else:
......
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