Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1326)

Unified Diff: bindings/scripts/v8_methods.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « bindings/scripts/v8_interface.py ('k') | bindings/scripts/v8_types.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bindings/scripts/v8_methods.py
diff --git a/bindings/scripts/v8_methods.py b/bindings/scripts/v8_methods.py
index 16fceaafa9c009baaa9cc01511fbbdd59be2ccba..d33071209161db46bf6a9494447b587eaeb2a8c8 100644
--- a/bindings/scripts/v8_methods.py
+++ b/bindings/scripts/v8_methods.py
@@ -34,7 +34,7 @@ Extends IdlTypeBase and IdlUnionType with property |union_arguments|.
Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
"""
-from idl_definitions import IdlArgument
+from idl_definitions import IdlArgument, IdlOperation
from idl_types import IdlTypeBase, IdlUnionType, inherits_interface
from v8_globals import includes
import v8_types
@@ -52,23 +52,6 @@ CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = frozenset([
])
-def argument_needs_try_catch(argument, return_promise):
- idl_type = argument.idl_type
- base_type = idl_type.base_type
-
- return not (
- # These cases are handled by separate code paths in the
- # generate_argument() macro in Source/bindings/templates/methods.cpp.
- idl_type.is_callback_interface or
- base_type == 'SerializedScriptValue' or
- (argument.is_variadic and idl_type.is_wrapper_type) or
- # String and enumeration arguments converted using one of the
- # TOSTRING_* macros except for _PROMISE variants in
- # Source/bindings/core/v8/V8BindingMacros.h don't use a v8::TryCatch.
- (base_type == 'DOMString' and not argument.is_variadic and
- not return_promise))
-
-
def use_local_result(method):
extended_attributes = method.extended_attributes
idl_type = method.idl_type
@@ -85,7 +68,6 @@ def method_context(interface, method):
idl_type = method.idl_type
is_static = method.is_static
name = method.name
- return_promise = idl_type.name == 'Promise'
idl_type.add_includes_for_type()
this_cpp_value = cpp_value(interface, method, len(arguments))
@@ -118,16 +100,19 @@ def method_context(interface, method):
includes.add('bindings/common/BindingSecurity.h')
is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attributes
if is_custom_element_callbacks:
- includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
+ includes.add('core/dom/custom/CustomElementProcessingStack.h')
+
+ is_do_not_check_security = 'DoNotCheckSecurity' in extended_attributes
is_check_security_for_frame = (
- 'CheckSecurity' in interface.extended_attributes and
- 'DoNotCheckSecurity' not in extended_attributes)
- is_raises_exception = 'RaisesException' in extended_attributes
+ has_extended_attribute_value(interface, 'CheckSecurity', 'Frame') and
+ not is_do_not_check_security)
- arguments_need_try_catch = (
- any(argument_needs_try_catch(argument, return_promise)
- for argument in arguments))
+ is_check_security_for_window = (
+ has_extended_attribute_value(interface, 'CheckSecurity', 'Window') and
+ not is_do_not_check_security)
+
+ is_raises_exception = 'RaisesException' in extended_attributes
return {
'activity_logging_world_list': v8_utilities.activity_logging_world_list(method), # [ActivityLogging]
@@ -135,7 +120,6 @@ def method_context(interface, method):
for index, argument in enumerate(arguments)],
'argument_declarations_for_private_script':
argument_declarations_for_private_script(interface, method),
- 'arguments_need_try_catch': arguments_need_try_catch,
'conditional_string': v8_utilities.conditional_string(method),
'cpp_type': (v8_types.cpp_template_type('Nullable', idl_type.cpp_type)
if idl_type.is_explicit_nullable else idl_type.cpp_type),
@@ -153,19 +137,20 @@ def method_context(interface, method):
'has_exception_state':
is_raises_exception or
is_check_security_for_frame or
- interface.name == 'EventTarget' or # FIXME: merge with is_check_security_for_frame http://crbug.com/383699
+ is_check_security_for_window or
any(argument for argument in arguments
- if argument.idl_type.name == 'SerializedScriptValue' or
- argument.idl_type.may_raise_exception_on_conversion),
+ if (argument.idl_type.name == 'SerializedScriptValue' or
+ argument_conversion_needs_exception_state(method, argument))),
'idl_type': idl_type.base_type,
'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_state': is_call_with_script_state,
'is_check_security_for_frame': is_check_security_for_frame,
'is_check_security_for_node': is_check_security_for_node,
+ 'is_check_security_for_window': is_check_security_for_window,
'is_custom': 'Custom' in extended_attributes,
'is_custom_element_callbacks': is_custom_element_callbacks,
- 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
+ 'is_do_not_check_security': is_do_not_check_security,
'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attributes,
'is_explicit_nullable': idl_type.is_explicit_nullable,
'is_implemented_in_private_script': is_implemented_in_private_script,
@@ -206,26 +191,24 @@ def argument_context(interface, method, argument, index):
idl_type = argument.idl_type
this_cpp_value = cpp_value(interface, method, index)
is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
- return_promise = (method.idl_type.name == 'Promise' if method.idl_type
- else False)
if ('ImplementedInPrivateScript' in extended_attributes and
not idl_type.is_wrapper_type and
not idl_type.is_basic_type):
raise Exception('Private scripts supports only primitive types and DOM wrappers.')
+ default_cpp_value = argument.default_cpp_value
return {
'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attributes,
raw_type=True,
used_as_variadic_argument=argument.is_variadic),
- 'cpp_type_initializer': idl_type.cpp_type_initializer,
'cpp_value': this_cpp_value,
# FIXME: check that the default value's type is compatible with the argument's
- 'default_value': argument.default_cpp_value,
+ 'default_value': default_cpp_value,
'enum_validation_expression': idl_type.enum_validation_expression,
'handle': '%sHandle' % argument.name,
# FIXME: remove once [Default] removed and just use argument.default_value
- 'has_default': 'Default' in extended_attributes or argument.default_value,
+ 'has_default': 'Default' in extended_attributes or default_cpp_value,
'has_type_checking_interface':
(has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
@@ -238,8 +221,9 @@ def argument_context(interface, method, argument, index):
'idl_type': idl_type.base_type,
'idl_type_object': idl_type,
'index': index,
- 'is_clamp': 'Clamp' in extended_attributes,
'is_callback_interface': idl_type.is_callback_interface,
+ # FIXME: Remove generic 'Dictionary' special-casing
+ 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictionary',
'is_nullable': idl_type.is_nullable,
'is_optional': argument.is_optional,
'is_variadic_wrapper_type': is_variadic_wrapper_type,
@@ -250,7 +234,7 @@ def argument_context(interface, method, argument, index):
creation_context='scriptState->context()->Global()'),
'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value),
'v8_set_return_value_for_main_world': v8_set_return_value(interface.name, method, this_cpp_value, for_main_world=True),
- 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index, return_promise=return_promise),
+ 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, index, return_promise=method.returns_promise),
'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type),
}
@@ -274,8 +258,9 @@ def cpp_value(interface, method, number_of_arguments):
idl_type = argument.idl_type
if idl_type.name == 'EventListener':
return argument.name
- if (idl_type.is_callback_interface or
- idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
+ if idl_type.is_dictionary:
+ return '*%s' % argument.name
+ if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
'XPathNSResolver', 'XPathNSResolverOrNull']):
# FIXME: remove this special case
return '%s.release()' % argument.name
@@ -361,15 +346,16 @@ def v8_value_to_local_cpp_variadic_value(argument, index, return_promise):
suffix = ''
- macro = 'TONATIVE_VOID'
+ macro = 'TONATIVE_VOID_EXCEPTIONSTATE'
macro_args = [
- argument.name,
- 'toNativeArguments<%s>(info, %s)' % (idl_type.cpp_type, index),
+ argument.name,
+ 'toImplArguments<%s>(info, %s, exceptionState)' % (idl_type.cpp_type, index),
+ 'exceptionState',
]
if return_promise:
suffix += '_PROMISE'
- macro_args.append('info')
+ macro_args.extend(['info', 'V8ScriptState::current(info.GetIsolate())'])
suffix += '_INTERNAL'
@@ -407,10 +393,12 @@ def union_member_argument_context(idl_type, index):
"""Returns a context of union member for argument."""
this_cpp_value = 'result%d' % index
this_cpp_type = idl_type.cpp_type
+ this_cpp_type_initializer = idl_type.cpp_type_initializer
cpp_return_value = this_cpp_value
if not idl_type.cpp_type_has_null_value:
this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type)
+ this_cpp_type_initializer = ''
cpp_return_value = '%s.get()' % this_cpp_value
if idl_type.is_string_type:
@@ -420,6 +408,7 @@ def union_member_argument_context(idl_type, index):
return {
'cpp_type': this_cpp_type,
+ 'cpp_type_initializer': this_cpp_type_initializer,
'cpp_value': this_cpp_value,
'null_check_value': null_check_value,
'v8_set_return_value': idl_type.v8_set_return_value(
@@ -435,6 +424,9 @@ def union_arguments(idl_type):
def argument_default_cpp_value(argument):
+ if argument.idl_type.is_dictionary:
+ # We always create impl objects for IDL dictionaries.
+ return '%s::create()' % argument.idl_type.base_type
if not argument.default_value:
return None
return argument.idl_type.literal_cpp_value(argument.default_value)
@@ -442,3 +434,17 @@ def argument_default_cpp_value(argument):
IdlTypeBase.union_arguments = None
IdlUnionType.union_arguments = property(union_arguments)
IdlArgument.default_cpp_value = property(argument_default_cpp_value)
+
+
+def method_returns_promise(method):
+ return method.idl_type and method.idl_type.name == 'Promise'
+
+IdlOperation.returns_promise = property(method_returns_promise)
+
+
+def argument_conversion_needs_exception_state(method, argument):
+ idl_type = argument.idl_type
+ return (idl_type.v8_conversion_needs_exception_state or
+ argument.is_variadic or
+ (method.returns_promise and (idl_type.is_string_type or
+ idl_type.is_enum)))
« no previous file with comments | « bindings/scripts/v8_interface.py ('k') | bindings/scripts/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698