OLD | NEW |
1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc
al_cpp_value %} | 1 {% from 'utilities.cpp' import declare_enum_validation_variable, v8_value_to_loc
al_cpp_value %} |
2 | 2 |
3 {##############################################################################} | 3 {##############################################################################} |
4 {% macro generate_method(method, world_suffix) %} | 4 {% macro generate_method(method, world_suffix) %} |
5 {% if method.returns_promise and method.has_exception_state %} | 5 {% if method.returns_promise and method.has_exception_state %} |
6 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) | 6 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) |
7 {% else %} | 7 {% else %} |
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
9 {% endif %} | 9 {% endif %} |
10 { | 10 { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 method_or_overloads.returns_promise %} | 316 method_or_overloads.returns_promise %} |
317 v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolat
e())).v8Value()); | 317 v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolat
e())).v8Value()); |
318 {% endif %} | 318 {% endif %} |
319 return; | 319 return; |
320 {%- endmacro %} | 320 {%- endmacro %} |
321 | 321 |
322 | 322 |
323 {######################################} | 323 {######################################} |
324 {% macro throw_minimum_arity_type_error(method, number_of_required_arguments) %} | 324 {% macro throw_minimum_arity_type_error(method, number_of_required_arguments) %} |
325 {% if method.has_exception_state %} | 325 {% if method.has_exception_state %} |
326 setMinimumArityTypeError(exceptionState, {{number_of_required_arguments}}, info.
Length()); | 326 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{method.num
ber_of_required_arguments}}, info.Length())); |
327 {{propagate_error_with_exception_state(method)}} | 327 {{propagate_error_with_exception_state(method)}} |
328 {%- elif method.idl_type == 'Promise' %} | 328 {%- elif method.idl_type == 'Promise' %} |
329 v8SetReturnValue(info, ScriptPromise::rejectRaw(ScriptState::current(info.GetIso
late()), {{create_minimum_arity_type_error_without_exception_state(method, numbe
r_of_required_arguments)}})); | 329 v8SetReturnValue(info, ScriptPromise::rejectRaw(ScriptState::current(info.GetIso
late()), {{create_minimum_arity_type_error_without_exception_state(method, numbe
r_of_required_arguments)}})); |
330 return; | 330 return; |
331 {%- else %} | 331 {%- else %} |
332 V8ThrowException::throwException(info.GetIsolate(), {{create_minimum_arity_type_
error_without_exception_state(method, number_of_required_arguments)}}); | 332 V8ThrowException::throwException(info.GetIsolate(), {{create_minimum_arity_type_
error_without_exception_state(method, number_of_required_arguments)}}); |
333 return; | 333 return; |
334 {%- endif %} | 334 {%- endif %} |
335 {%- endmacro %} | 335 {%- endmacro %} |
336 | 336 |
337 | 337 |
338 {######################################} | 338 {######################################} |
339 {% macro create_minimum_arity_type_error_without_exception_state(method, number_
of_required_arguments) %} | 339 {% macro create_minimum_arity_type_error_without_exception_state(method, number_
of_required_arguments) %} |
340 {% if method.is_constructor %} | 340 {% if method.is_constructor %} |
341 createMinimumArityTypeErrorForConstructor(info.GetIsolate(), "{{interface_name}}
", {{number_of_required_arguments}}, info.Length()) | 341 V8ThrowException::createTypeError(info.GetIsolate(), ExceptionMessages::failedTo
Construct("{{interface_name}}", ExceptionMessages::notEnoughArguments({{number_o
f_required_arguments}}, info.Length()))) |
342 {%- else %} | 342 {%- else %} |
343 createMinimumArityTypeErrorForMethod(info.GetIsolate(), "{{method.name}}", "{{in
terface_name}}", {{number_of_required_arguments}}, info.Length()) | 343 V8ThrowException::createTypeError(info.GetIsolate(), ExceptionMessages::failedTo
Execute("{{method.name}}", "{{interface_name}}", ExceptionMessages::notEnoughArg
uments({{number_of_required_arguments}}, info.Length()))) |
344 {%- endif %} | 344 {%- endif %} |
345 {%- endmacro %} | 345 {%- endmacro %} |
346 | 346 |
347 | 347 |
348 {##############################################################################} | 348 {##############################################################################} |
349 {% macro runtime_determined_length_method(overloads) %} | 349 {% macro runtime_determined_length_method(overloads) %} |
350 static int {{overloads.name}}MethodLength() | 350 static int {{overloads.name}}MethodLength() |
351 { | 351 { |
352 {% for length, runtime_enabled_functions in overloads.runtime_determined_len
gths %} | 352 {% for length, runtime_enabled_functions in overloads.runtime_determined_len
gths %} |
353 {% for runtime_enabled_function in runtime_enabled_functions %} | 353 {% for runtime_enabled_function in runtime_enabled_functions %} |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 {% if is_partial or not overloads.has_partial_overloads %} | 419 {% if is_partial or not overloads.has_partial_overloads %} |
420 default: | 420 default: |
421 {# If methods are overloaded between interface and partial interface #} | 421 {# If methods are overloaded between interface and partial interface #} |
422 {# definitions, need to invoke methods defined in the partial #} | 422 {# definitions, need to invoke methods defined in the partial #} |
423 {# interface. #} | 423 {# interface. #} |
424 {# FIXME: we do not need to always generate this code. #} | 424 {# FIXME: we do not need to always generate this code. #} |
425 {# Invalid arity, throw error #} | 425 {# Invalid arity, throw error #} |
426 {# Report full list of valid arities if gaps and above minimum #} | 426 {# Report full list of valid arities if gaps and above minimum #} |
427 {% if overloads.valid_arities %} | 427 {% if overloads.valid_arities %} |
428 if (info.Length() >= {{overloads.length}}) { | 428 if (info.Length() >= {{overloads.length}}) { |
429 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf
o.Length()); | 429 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{ove
rloads.valid_arities}}", info.Length())); |
430 {{propagate_error_with_exception_state(overloads) | indent(12)}} | 430 {{propagate_error_with_exception_state(overloads) | indent(12)}} |
431 } | 431 } |
432 {% endif %} | 432 {% endif %} |
433 break; | 433 break; |
434 {% endif %} | 434 {% endif %} |
435 } | 435 } |
436 {% if not is_partial and overloads.has_partial_overloads %} | 436 {% if not is_partial and overloads.has_partial_overloads %} |
437 ASSERT({{overloads.name}}MethodForPartialInterface); | 437 ASSERT({{overloads.name}}MethodForPartialInterface); |
438 ({{overloads.name}}MethodForPartialInterface)(info); | 438 ({{overloads.name}}MethodForPartialInterface)(info); |
439 {% else %} | 439 {% else %} |
440 {% if overloads.length != 0 %} | 440 {% if overloads.length != 0 %} |
441 if (info.Length() < {{overloads.length}}) { | 441 if (info.Length() < {{overloads.length}}) { |
442 {# Otherwise just report "not enough arguments" #} | 442 {# Otherwise just report "not enough arguments" #} |
443 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov
erloads.length}}, info.Length())); | 443 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov
erloads.length}}, info.Length())); |
444 {{propagate_error_with_exception_state(overloads) | indent(8)}} | 444 {{propagate_error_with_exception_state(overloads) | indent(8)}} |
445 } | 445 } |
446 {% endif %} | 446 {% endif %} |
447 {# No match, throw error #} | 447 {# No match, throw error #} |
448 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 448 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
449 {{propagate_error_with_exception_state(overloads) | indent}} | 449 {{propagate_error_with_exception_state(overloads) | indent}} |
450 {% endif %} | 450 {% endif %} |
451 } | 451 } |
452 {% endmacro %} | 452 {% endmacro %} |
453 | 453 |
454 | 454 |
455 {##############################################################################} | 455 {##############################################################################} |
456 {% macro generate_post_message_impl() %} | 456 {% macro generate_post_message_impl(method) %} |
457 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) | 457 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) |
458 { | 458 { |
459 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", interfaceName, info.Holder(), info.GetIsolate()); | 459 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo
ntext, interfaceName, "postMessage"); |
460 if (UNLIKELY(info.Length() < 1)) { | 460 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
461 setMinimumArityTypeError(exceptionState, 1, info.Length()); | 461 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{me
thod.number_of_required_arguments}}, info.Length())); |
462 return; | 462 return; |
463 } | 463 } |
464 Transferables transferables; | 464 Transferables transferables; |
465 if (info.Length() > 1) { | 465 if (info.Length() > 1) { |
466 const int transferablesArgIndex = 1; | 466 const int transferablesArgIndex = 1; |
467 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ | 467 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ |
468 return; | 468 return; |
469 } | 469 } |
470 } | 470 } |
471 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf
o.GetIsolate(), info[0], &transferables, nullptr, exceptionState); | 471 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf
o.GetIsolate(), info[0], &transferables, nullptr, exceptionState); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 if method.overloads else | 678 if method.overloads else |
679 method.runtime_enabled_function) %} | 679 method.runtime_enabled_function) %} |
680 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 680 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
681 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 681 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
682 {% endfilter %}{# runtime_enabled() #} | 682 {% endfilter %}{# runtime_enabled() #} |
683 {% endfilter %}{# exposed() #} | 683 {% endfilter %}{# exposed() #} |
684 {% endfilter %}{# secure_context() #} | 684 {% endfilter %}{# secure_context() #} |
685 {% endfor %} | 685 {% endfor %} |
686 {% endif %} | 686 {% endif %} |
687 {%- endmacro %} | 687 {%- endmacro %} |
OLD | NEW |