Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/methods.cpp.tmpl

Issue 2611823003: ABANDONED CL: Changes to compile and pass tests after Big Blink Rename (excluding functions). (Closed)
Patch Set: Inducing merge conflicts to force human review and changes after rename. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {% set define_exception_state -%} 9 {% set define_exception_state -%}
10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{method.name}}"); 10 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, "{{interface_name}}", "{{method.name}}");
11 {%- endset %} 11 {%- endset %}
12 12
13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %} 13 {% set function_call = func_call_with_prep_of_args(method, world_suffix) %}
14 14
15 {% if 'exceptionState' in function_call or 15 {% if 'exceptionState' in function_call or
16 (method.returns_promise and not method.is_static) %} 16 (method.returns_promise and not method.is_static) %}
17 {{define_exception_state}} 17 {{define_exception_state}}
18 {% if method.returns_promise %} 18 {% if method.returns_promise %}
19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); 19 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
20 {% endif %} 20 {% endif %}
21 {% endif %} 21 {% endif %}
22 22
23 {% if not method.is_static %} 23 {% if not method.is_static %}
24 {% if method.returns_promise %} 24 {% if method.returns_promise %}
25 // V8DOMConfiguration::DoNotCheckHolder 25 // V8DOMConfiguration::kDoNotCheckHolder
26 // Make sure that info.Holder() really points to an instance of the type. 26 // Make sure that info.Holder() really points to an instance of the type.
27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) { 27 if (!{{v8_class}}::hasInstance(info.Holder(), info.GetIsolate())) {
28 {{throw_type_error(method, '"Illegal invocation"')}} 28 {{throw_type_error(method, '"Illegal invocation"')}}
29 return; 29 return;
30 } 30 }
31 {% endif %} 31 {% endif %}
32 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 32 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
33 {% endif %} 33 {% endif %}
34 34
35 {# Security checks #} 35 {# Security checks #}
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 {% else %} 144 {% else %}
145 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent(2)}} 145 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent(2)}}
146 {% endif %} 146 {% endif %}
147 return; 147 return;
148 } 148 }
149 {% endif %} 149 {% endif %}
150 {% if argument.is_callback_interface %} 150 {% if argument.is_callback_interface %}
151 {# FIXME: remove EventListener special case #} 151 {# FIXME: remove EventListener special case #}
152 {% if argument.idl_type == 'EventListener' %} 152 {% if argument.idl_type == 'EventListener' %}
153 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %} 153 {% if method.name == 'removeEventListener' or method.name == 'removeListener' %}
154 {{argument.name}} = V8EventListenerHelper::getEventListener(ScriptState::current (info.GetIsolate()), info[{{argument.index}}], false, ListenerFindOnly); 154 {{argument.name}} = V8EventListenerHelper::getEventListener(ScriptState::current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOnly);
155 {% else %}{# method.name == 'addEventListener' #} 155 {% else %}{# method.name == 'addEventListener' #}
156 {{argument.name}} = V8EventListenerHelper::getEventListener(ScriptState::current (info.GetIsolate()), info[{{argument.index}}], false, ListenerFindOrCreate); 156 {{argument.name}} = V8EventListenerHelper::getEventListener(ScriptState::current (info.GetIsolate()), info[{{argument.index}}], false, kListenerFindOrCreate);
157 {% endif %}{# method.name #} 157 {% endif %}{# method.name #}
158 {% else %}{# argument.idl_type == 'EventListener' #} 158 {% else %}{# argument.idl_type == 'EventListener' #}
159 {# Callback functions must be functions: 159 {# Callback functions must be functions:
160 http://www.w3.org/TR/WebIDL/#es-callback-function #} 160 http://www.w3.org/TR/WebIDL/#es-callback-function #}
161 {% if argument.is_optional %} 161 {% if argument.is_optional %}
162 if (!isUndefinedOrNull(info[{{argument.index}}])) { 162 if (!isUndefinedOrNull(info[{{argument.index}}])) {
163 if (!info[{{argument.index}}]->IsFunction()) { 163 if (!info[{{argument.index}}]->IsFunction()) {
164 {{throw_argument_error(method, argument, "The callback provided as parameter %(index)d is not a function.")}} 164 {{throw_argument_error(method, argument, "The callback provided as parameter %(index)d is not a function.")}}
165 return; 165 return;
166 } 166 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 {% endmacro %} 343 {% endmacro %}
344 344
345 345
346 {##############################################################################} 346 {##############################################################################}
347 {% macro overload_resolution_method(overloads, world_suffix) %} 347 {% macro overload_resolution_method(overloads, world_suffix) %}
348 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI nfo<v8::Value>& info) { 348 static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI nfo<v8::Value>& info) {
349 {% set fall_through_to_partial_overloads = not is_partial and overloads.has_pa rtial_overloads %} 349 {% set fall_through_to_partial_overloads = not is_partial and overloads.has_pa rtial_overloads %}
350 350
351 {% if overloads.measure_all_as %} 351 {% if overloads.measure_all_as %}
352 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{ov erloads.measure_all_as}}); 352 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::k{{o verloads.measure_all_as}});
353 {% endif %} 353 {% endif %}
354 {% if overloads.deprecate_all_as %} 354 {% if overloads.deprecate_all_as %}
355 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC ounter::{{overloads.deprecate_all_as}}); 355 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC ounter::k{{overloads.deprecate_all_as}});
356 {% endif %} 356 {% endif %}
357 357
358 {# First resolve by length #} 358 {# First resolve by length #}
359 {% if not fall_through_to_partial_overloads %} 359 {% if not fall_through_to_partial_overloads %}
360 bool isArityError = false; 360 bool isArityError = false;
361 {% endif %} 361 {% endif %}
362 {# 2. Initialize argcount to be min(maxarg, n). #} 362 {# 2. Initialize argcount to be min(maxarg, n). #}
363 switch (std::min({{overloads.maxarg}}, info.Length())) { 363 switch (std::min({{overloads.maxarg}}, info.Length())) {
364 {# 3. Remove from S all entries whose type list is not of length argcount. # } 364 {# 3. Remove from S all entries whose type list is not of length argcount. # }
365 {% for length, tests_methods in overloads.length_tests_methods %} 365 {% for length, tests_methods in overloads.length_tests_methods %}
366 {# 10. If i = d, then: #} 366 {# 10. If i = d, then: #}
367 case {{length}}: 367 case {{length}}:
368 {# Then resolve by testing argument #} 368 {# Then resolve by testing argument #}
369 {% for test, method in tests_methods %} 369 {% for test, method in tests_methods %}
370 {% if method.visible %} 370 {% if method.visible %}
371 {% filter runtime_enabled(not overloads.runtime_enabled_all and method.run time_enabled_feature_name) %} 371 {% filter runtime_enabled(not overloads.runtime_enabled_all and method.run time_enabled_feature_name) %}
372 if ({{test}}) { 372 if ({{test}}) {
373 {% if method.measure_as and not overloads.measure_all_as %} 373 {% if method.measure_as and not overloads.measure_all_as %}
374 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter ::{{method.measure_as('Method')}}); 374 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter ::k{{method.measure_as('Method')}});
375 {% endif %} 375 {% endif %}
376 {% if method.deprecate_as and not overloads.deprecate_all_as %} 376 {% if method.deprecate_as and not overloads.deprecate_all_as %}
377 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()) , UseCounter::{{method.deprecate_as}}); 377 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()) , UseCounter::k{{method.deprecate_as}});
378 {% endif %} 378 {% endif %}
379 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info); 379 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info);
380 return; 380 return;
381 } 381 }
382 {% endfilter %} 382 {% endfilter %}
383 {% endif %} 383 {% endif %}
384 {% endfor %} 384 {% endfor %}
385 break; 385 break;
386 {% endfor %}{# length, tests_methods #} 386 {% endfor %}{# length, tests_methods #}
387 {% if not fall_through_to_partial_overloads %} 387 {% if not fall_through_to_partial_overloads %}
388 default: 388 default:
389 {# 4. If S is empty, then throw a TypeError. #} 389 {# 4. If S is empty, then throw a TypeError. #}
390 isArityError = true; 390 isArityError = true;
391 {% endif %} 391 {% endif %}
392 } 392 }
393 393
394 {% if fall_through_to_partial_overloads %} 394 {% if fall_through_to_partial_overloads %}
395 395
396 DCHECK({{overloads.name}}MethodForPartialInterface); 396 DCHECK({{overloads.name}}MethodForPartialInterface);
397 ({{overloads.name}}MethodForPartialInterface)(info); 397 ({{overloads.name}}MethodForPartialInterface)(info);
398 398
399 {% else %}{# fall_through_to_partial_overloads #} 399 {% else %}{# fall_through_to_partial_overloads #}
400 400
401 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, "{{interface_name}}", "{{overloads.name}}"); 401 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, "{{interface_name}}", "{{overloads.name}}");
402 {% if overloads.returns_promise_all %} 402 {% if overloads.returns_promise_all %}
403 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState); 403 ExceptionToRejectPromiseScope rejectPromiseScope(info, exceptionState);
404 {% endif %} 404 {% endif %}
405 405
406 if (isArityError) { 406 if (isArityError) {
407 {% if overloads.length != 0 %} 407 {% if overloads.length != 0 %}
408 if (info.Length() < {{overloads.length}}) { 408 if (info.Length() < {{overloads.length}}) {
409 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{over loads.length}}, info.Length())); 409 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{over loads.length}}, info.Length()));
410 return; 410 return;
411 } 411 }
412 {% endif %} 412 {% endif %}
413 {% if overloads.valid_arities %} 413 {% if overloads.valid_arities %}
414 if (info.Length() >= {{overloads.length}}) { 414 if (info.Length() >= {{overloads.length}}) {
415 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{overloads .valid_arities}}", info.Length())); 415 exceptionState.throwTypeError(ExceptionMessages::invalidArity("{{overloads .valid_arities}}", info.Length()));
416 return; 416 return;
417 } 417 }
418 {% endif %} 418 {% endif %}
419 } 419 }
420 exceptionState.throwTypeError("No function was found that matched the signatur e provided."); 420 exceptionState.throwTypeError("No function was found that matched the signatur e provided.");
421 421
422 {% endif %}{# fall_through_to_partial_overloads #} 422 {% endif %}{# fall_through_to_partial_overloads #}
423 } 423 }
424 {% endmacro %} 424 {% endmacro %}
425 425
426 426
427 {##############################################################################} 427 {##############################################################################}
428 {% macro generate_post_message_impl(method) %} 428 {% macro generate_post_message_impl(method) %}
429 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v8::FunctionCallbackInfo<v8::Value>& info) { 429 static void postMessageImpl(const char* interfaceName, {{cpp_class}}* instance, const v8::FunctionCallbackInfo<v8::Value>& info) {
430 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCont ext, interfaceName, "postMessage"); 430 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionCon text, interfaceName, "postMessage");
431 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) { 431 if (UNLIKELY(info.Length() < {{method.number_of_required_arguments}})) {
432 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{method .number_of_required_arguments}}, info.Length())); 432 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{method .number_of_required_arguments}}, info.Length()));
433 return; 433 return;
434 } 434 }
435 435
436 Transferables transferables; 436 Transferables transferables;
437 if (info.Length() > 1) { 437 if (info.Length() > 1) {
438 const int transferablesArgIndex = 1; 438 const int transferablesArgIndex = 1;
439 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[tra nsferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) { 439 if (!SerializedScriptValue::extractTransferables(info.GetIsolate(), info[tra nsferablesArgIndex], transferablesArgIndex, transferables, exceptionState)) {
440 return; 440 return;
441 } 441 }
442 } 442 }
443 443
444 RefPtr<SerializedScriptValue> message; 444 RefPtr<SerializedScriptValue> message;
445 if (instance->canTransferArrayBuffersAndImageBitmaps()) { 445 if (instance->canTransferArrayBuffersAndImageBitmaps()) {
446 // This instance supports sending array buffers by move semantics. 446 // This instance supports sending array buffers by move semantics.
447 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState); 447 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState);
448 if (exceptionState.hadException()) 448 if (exceptionState.hadException())
449 return; 449 return;
450 } else { 450 } else {
451 // This instance doesn't support sending array buffers and image bitmaps 451 // This instance doesn't support sending array buffers and image bitmaps
452 // by move semantics. Emulate it by copy-and-neuter semantics that sends 452 // by move semantics. Emulate it by copy-and-neuter semantics that sends
453 // array buffers and image bitmaps via structured clone and then neuters 453 // array buffers and image bitmaps via structured clone and then neuters
454 // the original objects 454 // the original objects
455 455
456 // Clear references to array buffers and image bitmaps from transferables 456 // Clear references to array buffers and image bitmaps from transferables
457 // so that the serializer can consider the array buffers as 457 // so that the serializer can consider the array buffers as
458 // non-transferable and serialize them into the message. 458 // non-transferable and serialize them into the message.
459 ArrayBufferArray transferableArrayBuffers = transferables.arrayBuffers; 459 ArrayBufferArray transferableArrayBuffers = transferables.array_buffers;
460 transferables.arrayBuffers.clear(); 460 transferables.array_buffers.clear();
461 ImageBitmapArray transferableImageBitmaps = transferables.imageBitmaps; 461 ImageBitmapArray transferableImageBitmaps = transferables.image_bitmaps;
462 transferables.imageBitmaps.clear(); 462 transferables.image_bitmaps.clear();
463 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState); 463 message = SerializedScriptValue::serialize(info.GetIsolate(), info[0], &tran sferables, nullptr, exceptionState);
464 if (exceptionState.hadException()) 464 if (exceptionState.hadException())
465 return; 465 return;
466 466
467 // Neuter the original array buffers on the sender context. 467 // Neuter the original array buffers on the sender context.
468 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState); 468 SerializedScriptValue::transferArrayBufferContents(info.GetIsolate(), transf erableArrayBuffers, exceptionState);
469 if (exceptionState.hadException()) 469 if (exceptionState.hadException())
470 return; 470 return;
471 // Neuter the original image bitmaps on the sender context. 471 // Neuter the original image bitmaps on the sender context.
472 SerializedScriptValue::transferImageBitmapContents(info.GetIsolate(), transf erableImageBitmaps, exceptionState); 472 SerializedScriptValue::transferImageBitmapContents(info.GetIsolate(), transf erableImageBitmaps, exceptionState);
473 if (exceptionState.hadException()) 473 if (exceptionState.hadException())
474 return; 474 return;
475 } 475 }
476 476
477 // FIXME: Only pass context/exceptionState if instance really requires it. 477 // FIXME: Only pass context/exceptionState if instance really requires it.
478 ExecutionContext* context = currentExecutionContext(info.GetIsolate()); 478 ExecutionContext* context = currentExecutionContext(info.GetIsolate());
479 instance->postMessage(context, message.release(), transferables.messagePorts, exceptionState); 479 instance->postMessage(context, message.release(), transferables.message_ports, exceptionState);
480 } 480 }
481 {% endmacro %} 481 {% endmacro %}
482 482
483 483
484 {##############################################################################} 484 {##############################################################################}
485 {% macro method_callback(method, world_suffix) %} 485 {% macro method_callback(method, world_suffix) %}
486 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf o<v8::Value>& info) { 486 void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInf o<v8::Value>& info) {
487 {% if not method.overloads %}{# Overloaded methods are measured in overload_re solution_method() #} 487 {% if not method.overloads %}{# Overloaded methods are measured in overload_re solution_method() #}
488 {% if method.measure_as %} 488 {% if method.measure_as %}
489 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::{{me thod.measure_as('Method')}}); 489 UseCounter::count(currentExecutionContext(info.GetIsolate()), UseCounter::k{{m ethod.measure_as('Method')}});
490 {% endif %} 490 {% endif %}
491 {% if method.deprecate_as %} 491 {% if method.deprecate_as %}
492 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC ounter::{{method.deprecate_as}}); 492 Deprecation::countDeprecation(currentExecutionContext(info.GetIsolate()), UseC ounter::k{{method.deprecate_as}});
493 {% endif %} 493 {% endif %}
494 {% endif %}{# not method.overloads #} 494 {% endif %}{# not method.overloads #}
495 {% if world_suffix in method.activity_logging_world_list %} 495 {% if world_suffix in method.activity_logging_world_list %}
496 {% if method.is_static %} 496 {% if method.is_static %}
497 ScriptState* scriptState = ScriptState::forFunctionObject(info); 497 ScriptState* scriptState = ScriptState::forFunctionObject(info);
498 {% else %} 498 {% else %}
499 ScriptState* scriptState = ScriptState::forReceiverObject(info); 499 ScriptState* scriptState = ScriptState::forReceiverObject(info);
500 {% endif %} 500 {% endif %}
501 V8PerContextData* contextData = scriptState->perContextData(); 501 V8PerContextData* contextData = scriptState->perContextData();
502 if (contextData && contextData->activityLogger()) { 502 if (contextData && contextData->activityLogger()) {
503 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ExecutionCo ntext, "{{interface_name}}", "{{method.name}}"); 503 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kExecutionC ontext, "{{interface_name}}", "{{method.name}}");
504 Vector<v8::Local<v8::Value>> loggerArgs = toImplArguments<Vector<v8::Local<v 8::Value>>>(info, 0, exceptionState); 504 Vector<v8::Local<v8::Value>> loggerArgs = toImplArguments<Vector<v8::Local<v 8::Value>>>(info, 0, exceptionState);
505 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.name}} ", info.Length(), loggerArgs.data()); 505 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.name}} ", info.Length(), loggerArgs.data());
506 } 506 }
507 {% endif %} 507 {% endif %}
508 {% if method.is_ce_reactions %} 508 {% if method.is_ce_reactions %}
509 CEReactionsScope ceReactionsScope; 509 CEReactionsScope ceReactionsScope;
510 {% endif %} 510 {% endif %}
511 {% if method.is_custom %} 511 {% if method.is_custom %}
512 {{v8_class}}::{{method.name}}MethodCustom(info); 512 {{v8_class}}::{{method.name}}MethodCustom(info);
513 {% elif method.is_post_message %} 513 {% elif method.is_post_message %}
(...skipping 15 matching lines...) Expand all
529 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate()); 529 V8PerIsolateData* data = V8PerIsolateData::from(info.GetIsolate());
530 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext()); 530 const DOMWrapperWorld& world = DOMWrapperWorld::world(info.GetIsolate()->GetCu rrentContext());
531 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo); 531 v8::Local<v8::FunctionTemplate> interfaceTemplate = data->findInterfaceTemplat e(world, &{{v8_class}}::wrapperTypeInfo);
532 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate); 532 v8::Local<v8::Signature> signature = v8::Signature::New(info.GetIsolate(), int erfaceTemplate);
533 533
534 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}}); 534 v8::Local<v8::FunctionTemplate> methodTemplate = data->findOrCreateOperationTe mplate(world, &domTemplateKey, {{cpp_class}}V8Internal::{{method.name}}MethodCal lback{{world_suffix}}, v8Undefined(), signature, {{method.length}});
535 // Return the function by default, unless the user script has overwritten it. 535 // Return the function by default, unless the user script has overwritten it.
536 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked()); 536 v8SetReturnValue(info, methodTemplate->GetFunction(info.GetIsolate()->GetCurre ntContext()).ToLocalChecked());
537 537
538 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 538 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
539 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, BindingSecurity::ErrorReportOption::DoNotReport)) { 539 if (!BindingSecurity::shouldAllowAccessTo(currentDOMWindow(info.GetIsolate()), impl, BindingSecurity::ErrorReportOption::kDoNotReport)) {
540 return; 540 return;
541 } 541 }
542 542
543 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState:: current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.Holder()), v8Atomic String(info.GetIsolate(), "{{method.name}}")); 543 v8::Local<v8::Value> hiddenValue = V8HiddenValue::getHiddenValue(ScriptState:: current(info.GetIsolate()), v8::Local<v8::Object>::Cast(info.Holder()), v8Atomic String(info.GetIsolate(), "{{method.name}}"));
544 if (!hiddenValue.IsEmpty()) { 544 if (!hiddenValue.IsEmpty()) {
545 v8SetReturnValue(info, hiddenValue); 545 v8SetReturnValue(info, hiddenValue);
546 } 546 }
547 } 547 }
548 548
549 void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8: :Name>, const v8::PropertyCallbackInfo<v8::Value>& info) { 549 void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8: :Name>, const v8::PropertyCallbackInfo<v8::Value>& info) {
550 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}} (info); 550 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix}} (info);
551 } 551 }
552 {% endmacro %} 552 {% endmacro %}
553 553
554 554
555 {##############################################################################} 555 {##############################################################################}
556 {% macro generate_constructor(constructor) %} 556 {% macro generate_constructor(constructor) %}
557 {% set name = '%sConstructorCallback' % v8_class 557 {% set name = '%sConstructorCallback' % v8_class
558 if constructor.is_named_constructor else 558 if constructor.is_named_constructor else
559 'constructor%s' % (constructor.overload_index or '') %} 559 'constructor%s' % (constructor.overload_index or '') %}
560 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) { 560 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) {
561 {% set function_call = func_call_with_prep_of_args(constructor) %} 561 {% set function_call = func_call_with_prep_of_args(constructor) %}
562 562
563 {% if constructor.is_named_constructor %} 563 {% if constructor.is_named_constructor %}
564 if (!info.IsConstructCall()) { 564 if (!info.IsConstructCall()) {
565 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("{{constructor.name}}")); 565 V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::const ructorNotCallableAsFunction("{{constructor.name}}"));
566 return; 566 return;
567 } 567 }
568 568
569 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExisti ngObject) { 569 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::kWrapExist ingObject) {
570 v8SetReturnValue(info, info.Holder()); 570 v8SetReturnValue(info, info.Holder());
571 return; 571 return;
572 } 572 }
573 {% endif %} 573 {% endif %}
574 574
575 {% if 'exceptionState' in function_call %} 575 {% if 'exceptionState' in function_call %}
576 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC ontext, "{{interface_name}}"); 576 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::kConstruction Context, "{{interface_name}}");
577 {% endif %} 577 {% endif %}
578 {% if 'scriptState' in function_call %} 578 {% if 'scriptState' in function_call %}
579 ScriptState* scriptState = ScriptState::forReceiverObject(info); 579 ScriptState* scriptState = ScriptState::forReceiverObject(info);
580 {% endif %} 580 {% endif %}
581 581
582 {{function_call | indent(2)}} 582 {{function_call | indent(2)}}
583 } 583 }
584 {% endmacro %} 584 {% endmacro %}
585 585
586 586
(...skipping 12 matching lines...) Expand all
599 {% macro method_configuration(method) %} 599 {% macro method_configuration(method) %}
600 {% from 'utilities.cpp.tmpl' import property_location %} 600 {% from 'utilities.cpp.tmpl' import property_location %}
601 {% set method_callback = 601 {% set method_callback =
602 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} 602 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
603 {% set method_callback_for_main_world = 603 {% set method_callback_for_main_world =
604 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met hod.name) 604 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, met hod.name)
605 if method.is_per_world_bindings else '0' %} 605 if method.is_per_world_bindings else '0' %}
606 {% set property_attribute = 606 {% set property_attribute =
607 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes) 607 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes)
608 if method.property_attributes else 'v8::None' %} 608 if method.property_attributes else 'v8::None' %}
609 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 609 {% set holder_check = 'V8DOMConfiguration::kDoNotCheckHolder'
610 if method.returns_promise else 'V8DOMConfiguration::CheckHolder' %} 610 if method.returns_promise else 'V8DOMConfiguration::kCheckHolder' %}
611 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{property_attribute}}, {{property_location(method)}}, {{holder_ check}}} 611 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{property_attribute}}, {{property_location(method)}}, {{holder_ check}}}
612 {%- endmacro %} 612 {%- endmacro %}
613 613
614 614
615 {######################################} 615 {######################################}
616 {% macro install_custom_signature(method, instance_template, prototype_template, interface_template, signature) %} 616 {% macro install_custom_signature(method, instance_template, prototype_template, interface_template, signature) %}
617 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 617 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
618 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon figuration); 618 V8DOMConfiguration::installMethod(isolate, world, {{instance_template}}, {{proto type_template}}, {{interface_template}}, {{signature}}, {{method.name}}MethodCon figuration);
619 {%- endmacro %} 619 {%- endmacro %}
620 620
(...skipping 16 matching lines...) Expand all
637 if method.overloads else 637 if method.overloads else
638 method.runtime_enabled_feature_name) %} 638 method.runtime_enabled_feature_name) %}
639 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}}; 639 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
640 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration); 640 V8DOMConfiguration::installMethod(isolate, world, v8::Local<v8::Object>(), proto typeObject, interfaceObject, signature, {{method.name}}MethodConfiguration);
641 {% endfilter %}{# runtime_enabled() #} 641 {% endfilter %}{# runtime_enabled() #}
642 {% endfilter %}{# exposed() #} 642 {% endfilter %}{# exposed() #}
643 {% endfilter %}{# secure_context() #} 643 {% endfilter %}{# secure_context() #}
644 {% endfor %} 644 {% endfor %}
645 {% endif %} 645 {% endif %}
646 {%- endmacro %} 646 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698