OLD | NEW |
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} | 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t
o_local_cpp_value %} |
2 | 2 |
3 {##############################################################################} | 3 {##############################################################################} |
4 {% macro generate_method(method, world_suffix) %} | 4 {% macro generate_method(method, world_suffix) %} |
5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) | 5 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const
v8::FunctionCallbackInfo<v8::Value>& info) |
6 {% filter format_remove_duplicates([ | 6 {% filter format_remove_duplicates([ |
7 'ExceptionState exceptionState', | 7 'ExceptionState exceptionState', |
8 'ScriptState* scriptState = ']) %} | 8 'ScriptState* scriptState = ']) %} |
9 { | 9 { |
10 {% set define_exception_state -%} | 10 {% set define_exception_state -%} |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 {##############################################################################} | 439 {##############################################################################} |
440 {% macro generate_post_message_impl(method) %} | 440 {% macro generate_post_message_impl(method) %} |
441 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) | 441 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance,
const v8::FunctionCallbackInfo<v8::Value>& info) |
442 { | 442 { |
443 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo
ntext, interfaceName, "postMessage"); | 443 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo
ntext, interfaceName, "postMessage"); |
444 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { | 444 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { |
445 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{me
thod.number_of_required_arguments}}, info.Length())); | 445 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{me
thod.number_of_required_arguments}}, info.Length())); |
446 return; | 446 return; |
447 } | 447 } |
| 448 |
448 Transferables transferables; | 449 Transferables transferables; |
449 if (info.Length() > 1) { | 450 if (info.Length() > 1) { |
450 const int transferablesArgIndex = 1; | 451 const int transferablesArgIndex = 1; |
451 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ | 452 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info
[transferablesArgIndex], transferablesArgIndex, transferables, exceptionState))
{ |
452 return; | 453 return; |
453 } | 454 } |
454 } | 455 } |
455 RefPtr<SerializedScriptValue> message = SerializedScriptValue::serialize(inf
o.GetIsolate(), info[0], &transferables, nullptr, exceptionState); | 456 |
456 if (exceptionState.hadException()) | 457 RefPtr<SerializedScriptValue> message; |
457 return; | 458 if (instance->canTransferArrayBuffer()) { |
| 459 // This instance supports sending array buffers by move semantics. |
| 460 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &
transferables, nullptr, exceptionState); |
| 461 if (exceptionState.hadException()) |
| 462 return; |
| 463 } else { |
| 464 // This instance doesn't support sending array buffers by move |
| 465 // semantics. Emulate it by copy-and-neuter semantics that sends array |
| 466 // buffers by copy semantics and then neuters the original array |
| 467 // buffers. |
| 468 |
| 469 // Clear transferable array buffers so that the serializer can handle |
| 470 // them by copy semantics. |
| 471 ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers; |
| 472 transferables.arrayBuffers.clear(); |
| 473 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &
transferables, nullptr, exceptionState); |
| 474 if (exceptionState.hadException()) |
| 475 return; |
| 476 |
| 477 // Neuter the original array buffers on the sender context. |
| 478 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), tr
ansferableArrayBuffers, exceptionState); |
| 479 if (exceptionState.hadException()) |
| 480 return; |
| 481 } |
| 482 |
458 // FIXME: Only pass context/exceptionState if instance really requires it. | 483 // FIXME: Only pass context/exceptionState if instance really requires it. |
459 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); | 484 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); |
460 instance->postMessage(context, message.release(), transferables.messagePorts
, exceptionState); | 485 instance->postMessage(context, message.release(), transferables.messagePorts
, exceptionState); |
461 } | 486 } |
462 {% endmacro %} | 487 {% endmacro %} |
463 | 488 |
464 | 489 |
465 {##############################################################################} | 490 {##############################################################################} |
466 {% macro method_callback(method, world_suffix) %} | 491 {% macro method_callback(method, world_suffix) %} |
467 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) | 492 static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCall
backInfo<v8::Value>& info) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 if method.overloads else | 687 if method.overloads else |
663 method.runtime_enabled_function) %} | 688 method.runtime_enabled_function) %} |
664 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; | 689 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration
= {{method_configuration(method)}}; |
665 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); | 690 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto
typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); |
666 {% endfilter %}{# runtime_enabled() #} | 691 {% endfilter %}{# runtime_enabled() #} |
667 {% endfilter %}{# exposed() #} | 692 {% endfilter %}{# exposed() #} |
668 {% endfilter %}{# secure_context() #} | 693 {% endfilter %}{# secure_context() #} |
669 {% endfor %} | 694 {% endfor %} |
670 {% endif %} | 695 {% endif %} |
671 {%- endmacro %} | 696 {%- endmacro %} |
OLD | NEW |