Index: Source/bindings/scripts/v8_methods.py |
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py |
index 76be0ed41c5617d14a7038f32bb86ca8e65b3a98..a112beeb9d5d41cd3d7fe3d445eb8e0e0e2f35dc 100644 |
--- a/Source/bindings/scripts/v8_methods.py |
+++ b/Source/bindings/scripts/v8_methods.py |
@@ -89,7 +89,7 @@ def method_context(interface, method): |
name = method.name |
idl_type.add_includes_for_type() |
- this_cpp_value = cpp_value(interface, method, len(arguments)) |
+ this_cpp_value = cpp_value(interface, method) |
def function_template(): |
if is_static: |
@@ -205,11 +205,14 @@ def method_context(interface, method): |
def argument_context(interface, method, argument, index): |
extended_attributes = argument.extended_attributes |
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) |
+ is_explicit_optional = argument.is_optional and not argument.default_value |
+ if is_explicit_optional: |
+ includes.add('bindings/core/v8/Optional.h') |
+ |
if ('ImplementedInPrivateScript' in extended_attributes and |
not idl_type.is_wrapper_type and |
not idl_type.is_basic_type): |
@@ -219,13 +222,11 @@ def argument_context(interface, method, argument, index): |
'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attributes, |
raw_type=True, |
used_as_variadic_argument=argument.is_variadic), |
- 'cpp_value': this_cpp_value, |
+ 'cpp_type_initializer': idl_type.cpp_type_initializer, |
# FIXME: check that the default value's type is compatible with the argument's |
'default_value': argument.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_type_checking_interface': |
(has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or |
has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and |
@@ -240,6 +241,7 @@ def argument_context(interface, method, argument, index): |
'index': index, |
'is_clamp': 'Clamp' in extended_attributes, |
'is_callback_interface': idl_type.is_callback_interface, |
+ 'is_explicit_optional': is_explicit_optional, |
'is_nullable': idl_type.is_nullable, |
'is_optional': argument.is_optional, |
'is_variadic_wrapper_type': is_variadic_wrapper_type, |
@@ -248,8 +250,6 @@ def argument_context(interface, method, argument, index): |
'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
argument.name, isolate='scriptState->isolate()', |
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), |
'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type), |
} |
@@ -269,9 +269,18 @@ def argument_declarations_for_private_script(interface, method): |
# Value handling |
################################################################################ |
-def cpp_value(interface, method, number_of_arguments): |
+def cpp_value(interface, method): |
def cpp_argument(argument): |
idl_type = argument.idl_type |
+ if argument.is_optional and not argument.default_value: |
+ cpp_type_optional = v8_types.cpp_template_type( |
+ 'Optional', idl_type.cpp_type_args( |
+ extended_attributes=argument.extended_attributes, |
+ raw_type=idl_type.preprocessed_type.is_string_type, |
+ used_in_cpp_sequence=True)) |
+ return '{cpp_type_optional}({name}, {name}Missing)'.format( |
+ cpp_type_optional=cpp_type_optional, |
+ name=argument.name) |
if idl_type.name == 'EventListener': |
return argument.name |
if (idl_type.is_callback_interface or |
@@ -281,8 +290,6 @@ def cpp_value(interface, method, number_of_arguments): |
return '%s.release()' % argument.name |
return argument.name |
- # Truncate omitted optional arguments |
- arguments = method.arguments[:number_of_arguments] |
cpp_arguments = [] |
if 'ImplementedInPrivateScript' in method.extended_attributes: |
cpp_arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') |
@@ -301,7 +308,7 @@ def cpp_value(interface, method, number_of_arguments): |
not 'ImplementedInPrivateScript' in method.extended_attributes and |
not method.is_static): |
cpp_arguments.append('*impl') |
- cpp_arguments.extend(cpp_argument(argument) for argument in arguments) |
+ cpp_arguments.extend(cpp_argument(argument) for argument in method.arguments) |
this_union_arguments = method.idl_type and method.idl_type.union_arguments |
if this_union_arguments: |