| Index: Source/bindings/templates/methods.cpp
|
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
|
| index dc4c6c056086660b95067762469ad7af99ba2458..d08e90f85a018c776988099720ebec1ea2b69ef2 100644
|
| --- a/Source/bindings/templates/methods.cpp
|
| +++ b/Source/bindings/templates/methods.cpp
|
| @@ -44,9 +44,9 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
|
| }
|
| {% endif %}
|
| {# Call method #}
|
| - {% for argument in method.arguments %}
|
| - {{generate_argument(method, argument, world_suffix) | indent}}
|
| - {% endfor %}
|
| + {% if method.arguments %}
|
| + {{generate_arguments(method, world_suffix) | indent}}
|
| + {% endif %}
|
| {% if world_suffix %}
|
| {{cpp_method_call(method, method.v8_set_return_value_for_main_world, method.cpp_value) | indent}}
|
| {% else %}
|
| @@ -73,6 +73,42 @@ if (listener && !impl->toNode())
|
|
|
|
|
| {######################################}
|
| +{% macro generate_arguments(method, world_suffix) %}
|
| +{% for argument in method.arguments %}
|
| +{{generate_argument_var_declaration(argument)}};
|
| +{% endfor %}
|
| +{
|
| + {% if method.arguments_need_try_catch %}
|
| + v8::TryCatch block;
|
| + {% endif %}
|
| + {% for argument in method.arguments %}
|
| + {{generate_argument(method, argument, world_suffix) | indent}}
|
| + {% endfor %}
|
| +}
|
| +{% endmacro %}
|
| +
|
| +
|
| +{######################################}
|
| +{% macro generate_argument_var_declaration(argument) %}
|
| +{% if argument.is_callback_interface %}
|
| +{# FIXME: remove EventListener special case #}
|
| +{% if argument.idl_type == 'EventListener' %}
|
| +RefPtr<{{argument.idl_type}}> {{argument.name}}
|
| +{%- else %}
|
| +OwnPtr<{{argument.idl_type}}> {{argument.name}}
|
| +{%- endif %}{# argument.idl_type == 'EventListener' #}
|
| +{%- elif argument.is_clamp %}{# argument.is_callback_interface #}
|
| +{# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #}
|
| +{{argument.cpp_type}} {{argument.name}} = 0
|
| +{%- elif argument.is_variadic_wrapper_type %}
|
| +{{argument.vector_type}}<{{argument.cpp_type}} > {{argument.name}}
|
| +{%- else %}
|
| +{{argument.cpp_type}} {{argument.name}}
|
| +{%- endif %}
|
| +{% endmacro %}
|
| +
|
| +
|
| +{######################################}
|
| {% macro generate_argument(method, argument, world_suffix) %}
|
| {% if argument.is_optional and not argument.has_default and
|
| argument.idl_type != 'Dictionary' and
|
| @@ -100,20 +136,19 @@ if (info.Length() > {{argument.index}} && {% if argument.is_nullable %}!isUndefi
|
| (argument.index + 1, argument.idl_type)) | indent}}
|
| return;
|
| }
|
| -{% endif %}
|
| +{% endif %}{# argument.has_type_checking_interface #}
|
| {% if argument.is_callback_interface %}
|
| {# FIXME: remove EventListener special case #}
|
| {% if argument.idl_type == 'EventListener' %}
|
| {% if method.name == 'removeEventListener' %}
|
| -RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOnly);
|
| +{{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOnly);
|
| {% else %}{# method.name == 'addEventListener' #}
|
| -RefPtr<{{argument.idl_type}}> {{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOrCreate);
|
| +{{argument.name}} = V8EventListenerList::getEventListener(info[1], false, ListenerFindOrCreate);
|
| {% endif %}{# method.name #}
|
| -{% else %}
|
| +{% else %}{# argument.idl_type == 'EventListener' #}
|
| {# Callback functions must be functions:
|
| http://www.w3.org/TR/WebIDL/#es-callback-function #}
|
| {% if argument.is_optional %}
|
| -OwnPtr<{{argument.idl_type}}> {{argument.name}};
|
| if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.index}}])) {
|
| if (!info[{{argument.index}}]->IsFunction()) {
|
| {{throw_type_error(method,
|
| @@ -123,30 +158,29 @@ if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind
|
| }
|
| {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate()));
|
| }
|
| -{% else %}
|
| +{% else %}{# argument.is_optional #}
|
| if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %}info[{{argument.index}}]->IsFunction(){% endif %}) {
|
| {{throw_type_error(method,
|
| '"The callback provided as parameter %s is not a function."' %
|
| (argument.index + 1)) | indent }}
|
| return;
|
| }
|
| -OwnPtr<{{argument.idl_type}}> {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNull() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Function>::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate()));
|
| +{{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNull() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Function>::Cast(info[{{argument.index}}]), currentExecutionContext(info.GetIsolate()));
|
| {% endif %}{# argument.is_optional #}
|
| {% endif %}{# argument.idl_type == 'EventListener' #}
|
| {% elif argument.is_clamp %}{# argument.is_callback_interface #}
|
| {# NaN is treated as 0: http://www.w3.org/TR/WebIDL/#es-type-mapping #}
|
| -{{argument.cpp_type}} {{argument.name}} = 0;
|
| -TONATIVE_VOID(double, {{argument.name}}NativeValue, info[{{argument.index}}]->NumberValue());
|
| +double {{argument.name}}NativeValue;
|
| +TONATIVE_VOID_NO_DECL({{argument.name}}NativeValue, info[{{argument.index}}]->NumberValue());
|
| if (!std::isnan({{argument.name}}NativeValue))
|
| {# IDL type is used for clamping, for the right bounds, since different
|
| IDL integer types have same internal C++ type (int or unsigned) #}
|
| {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeValue);
|
| {% elif argument.idl_type == 'SerializedScriptValue' %}
|
| -{{argument.cpp_type}} {{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0, exceptionState, info.GetIsolate());
|
| +{{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0, exceptionState, info.GetIsolate());
|
| if (exceptionState.throwIfNeeded())
|
| return;
|
| {% elif argument.is_variadic_wrapper_type %}
|
| -{{argument.vector_type}}<{{argument.cpp_type}} > {{argument.name}};
|
| for (int i = {{argument.index}}; i < info.Length(); ++i) {
|
| if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) {
|
| {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
|
| @@ -407,9 +441,9 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback
|
| return;
|
| }
|
| {% endif %}
|
| - {% for argument in constructor.arguments %}
|
| - {{generate_argument(constructor, argument) | indent}}
|
| - {% endfor %}
|
| + {% if constructor.arguments %}
|
| + {{generate_arguments(constructor) | indent}}
|
| + {% endif %}
|
| {% if is_constructor_call_with_execution_context %}
|
| ExecutionContext* context = currentExecutionContext(isolate);
|
| {% endif %}
|
| @@ -473,9 +507,9 @@ static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V
|
| return;
|
| }
|
| {% endif %}
|
| - {% for argument in constructor.arguments %}
|
| - {{generate_argument(constructor, argument) | indent}}
|
| - {% endfor %}
|
| + {% if constructor.arguments %}
|
| + {{generate_arguments(constructor) | indent}}
|
| + {% endif %}
|
| {{constructor.cpp_type}} impl = {{cpp_class}}::createForJSConstructor({{constructor.argument_list | join(', ')}});
|
| {% if is_constructor_raises_exception %}
|
| if (exceptionState.throwIfNeeded())
|
|
|