OLD | NEW |
1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l
ocal_cpp_value %} | 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l
ocal_cpp_value %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% macro generate_method(method, world_suffix) %} | 5 {% macro generate_method(method, world_suffix) %} |
6 {% filter conditional(method.conditional_string) %} | 6 {% filter conditional(method.conditional_string) %} |
7 {% if method.returns_promise and method.has_exception_state %} | 7 {% if method.returns_promise and method.has_exception_state %} |
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) | 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis
e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat
e) |
9 {% else %} | 9 {% else %} |
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 {% endif %} | 437 {% endif %} |
438 {# No match, throw error #} | 438 {# No match, throw error #} |
439 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); | 439 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
440 {{propagate_error_with_exception_state(overloads) | indent}} | 440 {{propagate_error_with_exception_state(overloads) | indent}} |
441 {% endif %} | 441 {% endif %} |
442 } | 442 } |
443 {% endmacro %} | 443 {% endmacro %} |
444 | 444 |
445 | 445 |
446 {##############################################################################} | 446 {##############################################################################} |
| 447 {% macro generate_post_message_impl() %} |
| 448 void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v
8::FunctionCallbackInfo<v8::Value>& info) |
| 449 { |
| 450 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", interfaceName, info.Holder(), info.GetIsolate()); |
| 451 if (UNLIKELY(info.Length() < 1)) { |
| 452 setMinimumArityTypeError(exceptionState, 1, info.Length()); |
| 453 exceptionState.throwIfNeeded(); |
| 454 return; |
| 455 } |
| 456 OwnPtrWillBeRawPtr<MessagePortArray> ports = adoptPtrWillBeNoop(new MessageP
ortArray); |
| 457 ArrayBufferArray arrayBuffers; |
| 458 if (info.Length() > 1) { |
| 459 const int transferablesArgIndex = 1; |
| 460 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, *ports, arrayBuffers, exceptionS
tate)) { |
| 461 exceptionState.throwIfNeeded(); |
| 462 return; |
| 463 } |
| 464 } |
| 465 RefPtr<SerializedScriptValue> message = SerializedScriptValueFactory::instan
ce().create(info.GetIsolate(), info[0], ports.get(), &arrayBuffers, exceptionSta
te); |
| 466 if (exceptionState.throwIfNeeded()) |
| 467 return; |
| 468 // FIXME: Only pass context/exceptionState if instance really requires it. |
| 469 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); |
| 470 instance->postMessage(context, message.release(), ports.get(), exceptionStat
e); |
| 471 exceptionState.throwIfNeeded(); |
| 472 } |
| 473 {% endmacro %} |
| 474 |
| 475 {##############################################################################} |
447 {% macro method_callback(method, world_suffix) %} | 476 {% macro method_callback(method, world_suffix) %} |
448 {% filter conditional(method.conditional_string) %} | 477 {% filter conditional(method.conditional_string) %} |
449 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) | 478 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) |
450 { | 479 { |
451 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); | 480 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
452 {% if not method.overloads %}{# Overloaded methods are measured in overload_
resolution_method() #} | 481 {% if not method.overloads %}{# Overloaded methods are measured in overload_
resolution_method() #} |
453 {% if method.measure_as %} | 482 {% if method.measure_as %} |
454 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); | 483 UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionConte
xt(info.GetIsolate()), UseCounter::{{method.measure_as('Method')}}); |
455 {% endif %} | 484 {% endif %} |
456 {% if method.deprecate_as %} | 485 {% if method.deprecate_as %} |
457 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe
cutionContext(info.GetIsolate()), UseCounter::{{method.deprecate_as}}); | 486 UseCounter::countDeprecationIfNotPrivateScript(info.GetIsolate(), callingExe
cutionContext(info.GetIsolate()), UseCounter::{{method.deprecate_as}}); |
458 {% endif %} | 487 {% endif %} |
459 {% endif %}{# not method.overloads #} | 488 {% endif %}{# not method.overloads #} |
460 {% if world_suffix in method.activity_logging_world_list %} | 489 {% if world_suffix in method.activity_logging_world_list %} |
461 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo
ntext()); | 490 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo
ntext()); |
462 V8PerContextData* contextData = scriptState->perContextData(); | 491 V8PerContextData* contextData = scriptState->perContextData(); |
463 {% if method.activity_logging_world_check %} | 492 {% if method.activity_logging_world_check %} |
464 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac
tivityLogger()) | 493 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac
tivityLogger()) |
465 {% else %} | 494 {% else %} |
466 if (contextData && contextData->activityLogger()) { | 495 if (contextData && contextData->activityLogger()) { |
467 {% endif %} | 496 {% endif %} |
468 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho
d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 497 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho
d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
469 Vector<v8::Local<v8::Value>> loggerArgs = toImplArguments<v8::Local<v8::
Value>>(info, 0, exceptionState); | 498 Vector<v8::Local<v8::Value>> loggerArgs = toImplArguments<v8::Local<v8::
Value>>(info, 0, exceptionState); |
470 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na
me}}", info.Length(), loggerArgs.data()); | 499 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na
me}}", info.Length(), loggerArgs.data()); |
471 } | 500 } |
472 {% endif %} | 501 {% endif %} |
473 {% if method.is_custom %} | 502 {% if method.is_custom %} |
474 {{v8_class}}::{{method.name}}MethodCustom(info); | 503 {{v8_class}}::{{method.name}}MethodCustom(info); |
475 {% elif method.is_post_message %} | 504 {% elif method.is_post_message %} |
476 postMessageMethodCommon("{{interface_name}}", {{v8_class}}::toImpl(info.Hold
er()), info); | 505 postMessageImpl("{{interface_name}}", {{v8_class}}::toImpl(info.Holder()), i
nfo); |
477 {% else %} | 506 {% else %} |
478 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(in
fo); | 507 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(in
fo); |
479 {% endif %} | 508 {% endif %} |
480 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 509 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
481 } | 510 } |
482 {% endfilter %} | 511 {% endfilter %} |
483 {% endmacro %} | 512 {% endmacro %} |
484 | 513 |
485 | 514 |
486 {##############################################################################} | 515 {##############################################################################} |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 if method.overloads else | 691 if method.overloads else |
663 method.runtime_enabled_function) %} | 692 method.runtime_enabled_function) %} |
664 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(iso
late, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCallback, v8Undef
ined(), defaultSignature, {{method.number_of_required_arguments}}); | 693 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate::New(iso
late, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCallback, v8Undef
ined(), defaultSignature, {{method.number_of_required_arguments}}); |
665 v8::Local<v8::Function> function = ->GetFunction(isolate->GetCurrentContext())).
ToLocalChecked(); | 694 v8::Local<v8::Function> function = ->GetFunction(isolate->GetCurrentContext())).
ToLocalChecked(); |
666 v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString(
isolate, "{{method.name}}"), function)); | 695 v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString(
isolate, "{{method.name}}"), function)); |
667 {% endfilter %}{# runtime_enabled() #} | 696 {% endfilter %}{# runtime_enabled() #} |
668 {% endfilter %}{# exposed() #} | 697 {% endfilter %}{# exposed() #} |
669 {% endfor %} | 698 {% endfor %} |
670 {% endif %} | 699 {% endif %} |
671 {%- endmacro %} | 700 {%- endmacro %} |
OLD | NEW |