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

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 1322533002: bindings: Supports to change the method location. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed review comments. Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 if constructor.is_named_constructor else 643 if constructor.is_named_constructor else
644 '') %} 644 '') %}
645 v8::Local<v8::Object> wrapper = info.Holder(); 645 v8::Local<v8::Object> wrapper = info.Holder();
646 wrapper = impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}:: wrapperTypeInfo, wrapper); 646 wrapper = impl->associateWithWrapper(info.GetIsolate(), &{{constructor_class}}:: wrapperTypeInfo, wrapper);
647 v8SetReturnValue(info, wrapper); 647 v8SetReturnValue(info, wrapper);
648 {% endmacro %} 648 {% endmacro %}
649 649
650 650
651 {##############################################################################} 651 {##############################################################################}
652 {% macro method_configuration(method) %} 652 {% macro method_configuration(method) %}
653 {% from 'conversions.cpp' import property_location %}
653 {% set method_callback = 654 {% set method_callback =
654 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %} 655 '%sV8Internal::%sMethodCallback' % (cpp_class_or_partial, method.name) %}
655 {% set method_callback_for_main_world = 656 {% set method_callback_for_main_world =
656 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, method. name) 657 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class_or_partial, method. name)
657 if method.is_per_world_bindings else '0' %} 658 if method.is_per_world_bindings else '0' %}
658 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 659 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %}
659 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}} 660 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}, {{property_location(method)} }}
660 {%- endmacro %} 661 {%- endmacro %}
661 662
662 663
663 {######################################} 664 {######################################}
664 {% macro install_custom_signature(method) %} 665 {% macro install_custom_signature(method, instance_template, prototype_template, interface_template, signature) %}
665 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class_or_partia l, method.name) %}
666 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback
667 if method.is_per_world_bindings else '0' %}
668 {% set method_length = method.overloads.length if method.overloads else method.l ength %}
669 {% set property_attribute = 666 {% set property_attribute =
670 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) 667 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_att ributes)
671 if method.property_attributes else 'v8::None' %} 668 if method.property_attributes else 'v8::None' %}
672 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} 669 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = {{method_configuration(method)}};
673 const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfiguration = { 670 V8DOMConfiguration::installMethod(isolate, {{instance_template}}, {{prototype_te mplate}}, {{interface_template}}, {{signature}}, {{property_attribute}}, {{metho d.name}}MethodConfiguration);
674 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method_length}}, {{only_exposed_to_private_script}},
675 };
676 V8DOMConfiguration::installMethod(isolate, {{method.function_template}}, {{metho d.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration);
677 {%- endmacro %} 671 {%- endmacro %}
678 672
679 {######################################} 673 {######################################}
680 {% macro install_conditionally_enabled_methods() %} 674 {% macro install_conditionally_enabled_methods() %}
681 {% if conditionally_enabled_methods %} 675 {% if conditionally_enabled_methods %}
682 {# Define operations with limited exposure #} 676 {# Define operations with limited exposure #}
683 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTempl ate(isolate)); 677 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domTempl ate(isolate));
684 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( )); 678 ExecutionContext* context = toExecutionContext(prototypeObject->CreationContext( ));
685 ASSERT(context); 679 ASSERT(context);
686 {% for method in conditionally_enabled_methods %} 680 {% for method in conditionally_enabled_methods %}
687 {% filter exposed(method.overloads.exposed_test_all 681 {% filter exposed(method.overloads.exposed_test_all
688 if method.overloads else 682 if method.overloads else
689 method.exposed_test) %} 683 method.exposed_test) %}
690 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 684 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
691 if method.overloads else 685 if method.overloads else
692 method.runtime_enabled_function) %} 686 method.runtime_enabled_function) %}
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}}); 687 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}});
694 v8::Local<v8::Function> function = v8CallOrCrash(functionTemplate->GetFunction(i solate->GetCurrentContext())); 688 v8::Local<v8::Function> function = v8CallOrCrash(functionTemplate->GetFunction(i solate->GetCurrentContext()));
695 v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString( isolate, "{{method.name}}"), function)); 689 v8CallOrCrash(prototypeObject->Set(isolate->GetCurrentContext(), v8AtomicString( isolate, "{{method.name}}"), function));
696 {% endfilter %}{# runtime_enabled() #} 690 {% endfilter %}{# runtime_enabled() #}
697 {% endfilter %}{# exposed() #} 691 {% endfilter %}{# exposed() #}
698 {% endfor %} 692 {% endfor %}
699 {% endif %} 693 {% endif %}
700 {%- endmacro %} 694 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface_base.cpp ('k') | Source/bindings/tests/results/core/V8TestException.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698