OLD | NEW |
---|---|
1 {##############################################################################} | 1 {##############################################################################} |
2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
5 { | 5 { |
6 {# Local variables #} | 6 {# Local variables #} |
7 {% if method.has_exception_state %} | 7 {% if method.has_exception_state %} |
8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
9 {% endif %} | 9 {% endif %} |
10 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 {% endif %} | 371 {% endif %} |
372 {# First resolve by length #} | 372 {# First resolve by length #} |
373 {# 2. Initialize argcount to be min(maxarg, n). #} | 373 {# 2. Initialize argcount to be min(maxarg, n). #} |
374 switch (std::min({{overloads.maxarg}}, info.Length())) { | 374 switch (std::min({{overloads.maxarg}}, info.Length())) { |
375 {# 3. Remove from S all entries whose type list is not of length argcount. # } | 375 {# 3. Remove from S all entries whose type list is not of length argcount. # } |
376 {% for length, tests_methods in overloads.length_tests_methods %} | 376 {% for length, tests_methods in overloads.length_tests_methods %} |
377 {# 10. If i = d, then: #} | 377 {# 10. If i = d, then: #} |
378 case {{length}}: | 378 case {{length}}: |
379 {# Then resolve by testing argument #} | 379 {# Then resolve by testing argument #} |
380 {% for test, method in tests_methods %} | 380 {% for test, method in tests_methods %} |
381 {% if method.visible %} | |
381 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and | 382 {% filter runtime_enabled(not overloads.runtime_enabled_function_all and |
382 method.runtime_enabled_function) %} | 383 method.runtime_enabled_function) %} |
383 if ({{test}}) { | 384 if ({{test}}) { |
384 {% if method.measure_as and not overloads.measure_all_as %} | 385 {% if method.measure_as and not overloads.measure_all_as %} |
385 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCou nter::{{method.measure_as}}); | 386 UseCounter::count(callingExecutionContext(info.GetIsolate()), UseCou nter::{{method.measure_as}}); |
386 {% endif %} | 387 {% endif %} |
387 {% if method.deprecate_as and not overloads.deprecate_all_as %} | 388 {% if method.deprecate_as and not overloads.deprecate_all_as %} |
388 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate ()), UseCounter::{{method.deprecate_as}}); | 389 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate ()), UseCounter::{{method.deprecate_as}}); |
389 {% endif %} | 390 {% endif %} |
390 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info) ; | 391 {{method.name}}{{method.overload_index}}Method{{world_suffix}}(info) ; |
391 return; | 392 return; |
392 } | 393 } |
393 {% endfilter %} | 394 {% endfilter %} |
395 {% endif %} | |
394 {% endfor %} | 396 {% endfor %} |
395 break; | 397 break; |
396 {% endfor %} | 398 {% endfor %} |
397 default: | 399 default: |
400 {# #} | |
haraken
2014/10/09 04:24:01
Add a comment.
tasak
2014/10/10 07:52:23
Done.
| |
401 {% if not is_partial and overloads.partial_overloads %} | |
402 if ({{overloads.name}}MethodForPartialInterface) { | |
403 ({{overloads.name}}MethodForPartialInterface)(info); | |
404 return; | |
405 } | |
406 {% endif %} | |
398 {# Invalid arity, throw error #} | 407 {# Invalid arity, throw error #} |
399 {# Report full list of valid arities if gaps and above minimum #} | 408 {# Report full list of valid arities if gaps and above minimum #} |
400 {% if overloads.valid_arities %} | 409 {% if overloads.valid_arities %} |
401 if (info.Length() >= {{overloads.minarg}}) { | 410 if (info.Length() >= {{overloads.minarg}}) { |
402 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf o.Length()); | 411 setArityTypeError(exceptionState, "{{overloads.valid_arities}}", inf o.Length()); |
403 exceptionState.throwIfNeeded(); | 412 exceptionState.throwIfNeeded(); |
404 return; | 413 return; |
405 } | 414 } |
406 {% endif %} | 415 {% endif %} |
407 {# Otherwise just report "not enough arguments" #} | 416 {# Otherwise just report "not enough arguments" #} |
408 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov erloads.minarg}}, info.Length())); | 417 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{ov erloads.minarg}}, info.Length())); |
409 exceptionState.throwIfNeeded(); | 418 exceptionState.throwIfNeeded(); |
410 return; | 419 return; |
411 } | 420 } |
421 {% if not is_partial and overloads.partial_overloads %} | |
422 if ({{overloads.name}}MethodForPartialInterface) { | |
423 ({{overloads.name}}MethodForPartialInterface)(info); | |
424 return; | |
425 } | |
426 {% endif %} | |
412 {# No match, throw error #} | 427 {# No match, throw error #} |
413 exceptionState.throwTypeError("No function was found that matched the signat ure provided."); | 428 exceptionState.throwTypeError("No function was found that matched the signat ure provided."); |
414 exceptionState.throwIfNeeded(); | 429 exceptionState.throwIfNeeded(); |
415 } | 430 } |
416 {% endmacro %} | 431 {% endmacro %} |
417 | 432 |
418 | 433 |
419 {##############################################################################} | 434 {##############################################################################} |
420 {% macro method_callback(method, world_suffix) %} | 435 {% macro method_callback(method, world_suffix) %} |
421 {% filter conditional(method.conditional_string) %} | 436 {% filter conditional(method.conditional_string) %} |
(...skipping 17 matching lines...) Expand all Loading... | |
439 if (contextData && contextData->activityLogger()) { | 454 if (contextData && contextData->activityLogger()) { |
440 {% endif %} | 455 {% endif %} |
441 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 456 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
442 Vector<v8::Handle<v8::Value> > loggerArgs = toImplArguments<v8::Handle<v 8::Value> >(info, 0, exceptionState); | 457 Vector<v8::Handle<v8::Value> > loggerArgs = toImplArguments<v8::Handle<v 8::Value> >(info, 0, exceptionState); |
443 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na me}}", info.Length(), loggerArgs.data()); | 458 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na me}}", info.Length(), loggerArgs.data()); |
444 } | 459 } |
445 {% endif %} | 460 {% endif %} |
446 {% if method.is_custom %} | 461 {% if method.is_custom %} |
447 {{v8_class}}::{{method.name}}MethodCustom(info); | 462 {{v8_class}}::{{method.name}}MethodCustom(info); |
448 {% else %} | 463 {% else %} |
464 {% if is_partial %} | |
465 {{cpp_class}}PartialV8Internal::{{method.name}}Method{{world_suffix}}(info); | |
466 {% else %} | |
449 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); | 467 {{cpp_class}}V8Internal::{{method.name}}Method{{world_suffix}}(info); |
450 {% endif %} | 468 {% endif %} |
469 {% endif %} | |
451 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 470 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
452 } | 471 } |
453 {% endfilter %} | 472 {% endfilter %} |
454 {% endmacro %} | 473 {% endmacro %} |
455 | 474 |
456 | 475 |
457 {##############################################################################} | 476 {##############################################################################} |
458 {% macro origin_safe_method_getter(method, world_suffix) %} | 477 {% macro origin_safe_method_getter(method, world_suffix) %} |
459 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) | 478 static void {{method.name}}OriginSafeMethodGetter{{world_suffix}}(const v8::Prop ertyCallbackInfo<v8::Value>& info) |
460 { | 479 { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate()); | 612 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr uctor_class}}::wrapperTypeInfo, wrapper, info.GetIsolate()); |
594 {% endif %} | 613 {% endif %} |
595 {% endif %} | 614 {% endif %} |
596 v8SetReturnValue(info, wrapper); | 615 v8SetReturnValue(info, wrapper); |
597 {% endmacro %} | 616 {% endmacro %} |
598 | 617 |
599 | 618 |
600 {##############################################################################} | 619 {##############################################################################} |
601 {% macro method_configuration(method) %} | 620 {% macro method_configuration(method) %} |
602 {% set method_callback = | 621 {% set method_callback = |
603 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} | 622 '%s%sV8Internal::%sMethodCallback' % (cpp_class, 'Partial' if is_partial else '', method.name) %} |
haraken
2014/10/09 04:24:01
We're creating the namespace name repeatedly in te
tasak
2014/10/10 07:52:23
Done.
Added actual_cpp_class and actual_v8_class f
| |
604 {% set method_callback_for_main_world = | 623 {% set method_callback_for_main_world = |
605 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) | 624 '%s%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, 'Partial' if is_ parital else '', method.name) |
606 if method.is_per_world_bindings else '0' %} | 625 if method.is_per_world_bindings else '0' %} |
607 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} | 626 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} |
608 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}} | 627 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}} |
609 {%- endmacro %} | 628 {%- endmacro %} |
610 | 629 |
611 | 630 |
612 {######################################} | 631 {######################################} |
613 {% macro install_custom_signature(method) %} | 632 {% macro install_custom_signature(method) %} |
614 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.n ame) %} | 633 {% set method_callback = '%s%sV8Internal::%sMethodCallback' % (cpp_class, 'Parti al' if is_partial else '', method.name) %} |
615 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback | 634 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback |
616 if method.is_per_world_bindings else '0' %} | 635 if method.is_per_world_bindings else '0' %} |
617 {% set property_attribute = | 636 {% set property_attribute = |
618 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) | 637 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) |
619 if method.property_attributes else 'v8::None' %} | 638 if method.property_attributes else 'v8::None' %} |
620 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} | 639 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} |
621 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { | 640 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { |
622 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}}, | 641 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, {{only_exposed_to_private_script}}, |
623 }; | 642 }; |
624 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 643 V8DOMConfiguration::installMethod({{method.function_template}}, {{method.signatu re}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
625 {%- endmacro %} | 644 {%- endmacro %} |
OLD | NEW |