Chromium Code Reviews| Index: Source/bindings/templates/methods.cpp |
| diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp |
| index 763d6d7b2bf2a5741a6dd411f80df681e09b5751..39e0e21022a1a7494800006c98325ee76be51328 100644 |
| --- a/Source/bindings/templates/methods.cpp |
| +++ b/Source/bindings/templates/methods.cpp |
| @@ -9,9 +9,7 @@ static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const |
| {% endif %} |
| {% if method.number_of_required_arguments %} |
| if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
| - {{throw_type_error(method, |
| - 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| - method.number_of_required_arguments) | indent(8)}} |
| + {{throw_arity_type_error(method, method.number_of_required_arguments) | indent(8)}} |
|
Nils Barth (inactive)
2014/04/02 06:47:37
The 'indent' is not necessary, as this is one line
fs
2014/04/02 07:13:46
Done and done.
|
| return; |
| } |
| {% endif %} |
| @@ -258,6 +256,18 @@ throwTypeError(ExceptionMessages::failedToExecute("{{method.name}}", "{{interfac |
| {% endmacro %} |
| +{######################################} |
| +{% macro throw_arity_type_error(method, minimum_number_of_required_arguments) %} |
|
Nils Barth (inactive)
2014/04/02 06:47:37
Naming-wise, I'd prefer 'number_of_required_argume
fs
2014/04/02 07:13:46
Done.
|
| +{% if method.has_exception_state %} |
| +throwArityTypeError(exceptionState, {{minimum_number_of_required_arguments}}, info.Length()); |
| +{%- elif method.is_constructor %} |
| +throwArityTypeErrorForConstructor("{{interface_name}}", {{minimum_number_of_required_arguments}}, info.Length(), info.GetIsolate()); |
| +{%- else %} |
| +throwArityTypeErrorForMethod("{{method.name}}", "{{interface_name}}", {{minimum_number_of_required_arguments}}, info.Length(), info.GetIsolate()); |
| +{%- endif %} |
| +{% endmacro %} |
| + |
| + |
| {##############################################################################} |
| {% macro overload_resolution_method(overloads, world_suffix) %} |
| static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
| @@ -271,9 +281,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI |
| {% if overloads.minimum_number_of_required_arguments %} |
| ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{overloads.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| if (UNLIKELY(info.Length() < {{overloads.minimum_number_of_required_arguments}})) { |
| - {{throw_type_error(overloads, |
| - 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| - overloads.minimum_number_of_required_arguments) | indent(8)}} |
| + {{throw_arity_type_error(overloads, overloads.minimum_number_of_required_arguments) | indent(8)}} |
| return; |
| } |
| {% endif %} |
| @@ -371,9 +379,7 @@ static void constructor{{constructor.overload_index}}(const v8::FunctionCallback |
| {% if interface_length and not constructor.overload_index %} |
| {# FIXME: remove UNLIKELY: constructors are expensive, so no difference. #} |
| if (UNLIKELY(info.Length() < {{interface_length}})) { |
| - {{throw_type_error(constructor, |
| - 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| - interface_length) | indent(8)}} |
| + {{throw_arity_type_error(constructor, interface_length) | indent(8)}} |
| return; |
| } |
| {% endif %} |
| @@ -429,9 +435,7 @@ static void {{v8_class}}ConstructorCallback(const v8::FunctionCallbackInfo<v8::V |
| {% endif %} |
| {% if constructor.number_of_required_arguments %} |
| if (UNLIKELY(info.Length() < {{constructor.number_of_required_arguments}})) { |
| - {{throw_type_error(constructor, |
| - 'ExceptionMessages::notEnoughArguments(%s, info.Length())' % |
| - constructor.number_of_required_arguments) | indent(8)}} |
| + {{throw_arity_type_error(constructor, constructor.number_of_required_arguments) | indent(8)}} |
| return; |
| } |
| {% endif %} |