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

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

Issue 618373003: [bindings] partial interfaces should not violate componentization (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); 420 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter");
421 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info); 421 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, v8Value, info);
422 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 422 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
423 } 423 }
424 424
425 {% endif %} 425 {% endif %}
426 {% endblock %} 426 {% endblock %}
427 427
428 428
429 {##############################################################################} 429 {##############################################################################}
430 {% block named_constructor %}
430 {% from 'methods.cpp' import generate_constructor with context %} 431 {% from 'methods.cpp' import generate_constructor with context %}
431 {% block named_constructor %}
432 {% if named_constructor %} 432 {% if named_constructor %}
433 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class 433 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class
434 if is_active_dom_object else '0' %} 434 if is_active_dom_object else '0' %}
435 {% set to_event_target = '%s::toEventTarget' % v8_class 435 {% set to_event_target = '%s::toEventTarget' % v8_class
436 if is_event_target else '0' %} 436 if is_event_target else '0' %}
437 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}} , {{to_event_target}}, 0, {{v8_class}}::installConditionallyEnabledMethods, {{v8 _class}}::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperType ObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifet ime}}, WrapperTypeInfo::{{gc_type}} }; 437 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::createPersistentHandle, {{to_active_dom_object}} , {{to_event_target}}, 0, {{v8_class}}::installConditionallyEnabledMethods, {{v8 _class}}::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperType ObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{lifet ime}}, WrapperTypeInfo::{{gc_type}} };
438 438
439 {{generate_constructor(named_constructor)}} 439 {{generate_constructor(named_constructor)}}
440 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate) 440 v8::Handle<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolat e* isolate)
441 { 441 {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 594 }
595 {% endif %} 595 {% endif %}
596 setObjectGroup(internalPointer, wrapper, isolate); 596 setObjectGroup(internalPointer, wrapper, isolate);
597 } 597 }
598 598
599 {% endif %} 599 {% endif %}
600 {% endblock %} 600 {% endblock %}
601 601
602 602
603 {##############################################################################} 603 {##############################################################################}
604 {% block shadow_attributes %}
604 {% from 'attributes.cpp' import attribute_configuration with context %} 605 {% from 'attributes.cpp' import attribute_configuration with context %}
605 {% block shadow_attributes %}
606 {% if interface_name == 'Window' %} 606 {% if interface_name == 'Window' %}
607 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { 607 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = {
608 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho uld_be_exposed_to_script %} 608 {% for attribute in attributes if attribute.is_unforgeable and attribute.sho uld_be_exposed_to_script %}
609 {{attribute_configuration(attribute)}}, 609 {{attribute_configuration(attribute)}},
610 {% endfor %} 610 {% endfor %}
611 }; 611 };
612 612
613 {% endif %} 613 {% endif %}
614 {% endblock %} 614 {% endblock %}
615 615
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, {{only_exposed_to_private_scr ipt}}, V8DOMConfiguration::OnInstance, 722 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, {{only_exposed_to_private_scr ipt}}, V8DOMConfiguration::OnInstance,
723 }; 723 };
724 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); 724 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate);
725 {%- endmacro %} 725 {%- endmacro %}
726 726
727 727
728 {##############################################################################} 728 {##############################################################################}
729 {% block get_dom_template %} 729 {% block get_dom_template %}
730 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) 730 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate)
731 { 731 {
732 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); 732 {% if has_partial_interface %}
733 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class , v8_class) %}
734 ASSERT({{installTemplateFunction}} != {{v8_class}}::install{{v8_class}}Templ ate);
735 {% else %}
736 {% set installTemplateFunction = 'install%sTemplate' % v8_class %}
737 {% endif %}
738 {% set installTemplateFunction = '%s::install%sTemplateFunction' % (v8_class, v8 _class) if has_partial_interface else 'install%sTemplate' % v8_class %}
739 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), {{installTemplateFunction}});
733 } 740 }
734 741
735 {% endblock %} 742 {% endblock %}
736 743
737 744
738 {##############################################################################} 745 {##############################################################################}
739 {% block has_instance %} 746 {% block has_instance %}
740 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te) 747 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola te)
741 { 748 {
742 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); 749 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
(...skipping 11 matching lines...) Expand all
754 {% block to_impl_with_type_check %} 761 {% block to_impl_with_type_check %}
755 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value) 762 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl e<v8::Value> value)
756 { 763 {
757 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; 764 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle <v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0;
758 } 765 }
759 766
760 {% endblock %} 767 {% endblock %}
761 768
762 769
763 {##############################################################################} 770 {##############################################################################}
771 {% block install_conditional_attributes %}
772 {% from 'attributes.cpp' import attribute_configuration with context %}
773 {% if has_conditional_attributes %}
774 void {{v8_class}}::installConditionallyEnabledProperties(v8::Handle<v8::Object> instanceObject, v8::Isolate* isolate)
775 {
776 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance Object->GetPrototype());
777 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont ext());
778
779 {% for attribute in attributes if attribute.per_context_enabled_function or attribute.exposed_test %}
780 {% filter per_context_enabled(attribute.per_context_enabled_function) %}
781 {% filter exposed(attribute.exposed_test) %}
782 static const V8DOMConfiguration::AttributeConfiguration attributeConfigurati on =\
783 {{attribute_configuration(attribute)}};
784 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, attrib uteConfiguration, isolate);
785 {% endfilter %}
786 {% endfilter %}
787 {% endfor %}
788 }
789
790 {% endif %}
791 {% endblock %}
792
793
794 {##############################################################################}
764 {% block to_active_dom_object %} 795 {% block to_active_dom_object %}
765 {% if is_active_dom_object %} 796 {% if is_active_dom_object %}
766 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 797 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper)
767 { 798 {
768 return toImpl(wrapper); 799 return toImpl(wrapper);
769 } 800 }
770 801
771 {% endif %} 802 {% endif %}
772 {% endblock %} 803 {% endblock %}
773 804
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 {% endif %} 926 {% endif %}
896 } 927 }
897 928
898 template<> 929 template<>
899 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 930 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
900 { 931 {
901 return toV8(impl, creationContext, isolate); 932 return toV8(impl, creationContext, isolate);
902 } 933 }
903 934
904 {% endblock %} 935 {% endblock %}
936
937 {##############################################################################}
938 {% block partial_interface %}
939 {% if has_partial_interface %}
940 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template;
941
942 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, InstallConditionallyEnabledMethodsFunction installConditionallyEnabled MethodsFunction)
943 {
944 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction;
945 if (installConditionallyEnabledMethodsFunction)
946 {{v8_class}}::wrapperTypeInfo.installConditionallyEnabledMethodsFunction = installConditionallyEnabledMethodsFunction;
947 }
948
949 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
950 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
951 {
952 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
953 }
954 {% endfor %}
955 {% endif %}
956 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698