OLD | NEW |
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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} | 720 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat
eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo
sedToAllScripts' %} |
721 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf
eAttributeConfiguration = { | 721 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf
eAttributeConfiguration = { |
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 {% if not is_array_buffer_or_view %} |
730 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) | 731 v8::Handle<v8::FunctionTemplate> {{v8_class}}::domTemplate(v8::Isolate* isolate) |
731 { | 732 { |
732 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); | 733 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), install{{v8_class}}Template); |
733 } | 734 } |
734 | 735 |
| 736 {% endif %} |
735 {% endblock %} | 737 {% endblock %} |
736 | 738 |
737 | 739 |
738 {##############################################################################} | 740 {##############################################################################} |
739 {% block has_instance %} | 741 {% block has_instance %} |
740 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola
te) | 742 bool {{v8_class}}::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isola
te) |
741 { | 743 { |
| 744 {% if is_array_buffer_or_view %} |
| 745 return v8Value->Is{{interface_name}}(); |
| 746 {% else %} |
742 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | 747 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); |
| 748 {% endif %} |
743 } | 749 } |
744 | 750 |
| 751 {% if not is_array_buffer_or_view %} |
745 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8:
:Value> v8Value, v8::Isolate* isolate) | 752 v8::Handle<v8::Object> {{v8_class}}::findInstanceInPrototypeChain(v8::Handle<v8:
:Value> v8Value, v8::Isolate* isolate) |
746 { | 753 { |
747 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | 754 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); |
748 } | 755 } |
749 | 756 |
| 757 {% endif %} |
750 {% endblock %} | 758 {% endblock %} |
751 | 759 |
752 | 760 |
| 761 {##############################################################################} |
| 762 {% block to_impl %} |
| 763 {% if interface_name == 'ArrayBuffer' %} |
| 764 {{cpp_class}}* V8ArrayBuffer::toImpl(v8::Handle<v8::Object> object) |
| 765 { |
| 766 ASSERT(object->IsArrayBuffer()); |
| 767 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); |
| 768 if (v8buffer->IsExternal()) { |
| 769 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
| 770 RELEASE_ASSERT(wrapperTypeInfo); |
| 771 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
| 772 return blink::toScriptWrappableBase(object)->toImpl<{{cpp_class}}>(); |
| 773 } |
| 774 |
| 775 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); |
| 776 // This special way to create ArrayBuffer via ArrayBufferContents makes the |
| 777 // underlying ArrayBufferContents not call ArrayBufferDeallocationObserver:: |
| 778 // blinkAllocatedMemory. The array buffer created by V8 already called it, |
| 779 // so we shouldn't call it. |
| 780 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, DOMArrayBufferDeallocationObserver::instance()); |
| 781 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); |
| 782 buffer->associateWithWrapper(buffer->wrapperTypeInfo(), object, v8::Isolate:
:GetCurrent()); |
| 783 |
| 784 return blink::toScriptWrappableBase(object)->toImpl<{{cpp_class}}>(); |
| 785 } |
| 786 |
| 787 {% elif interface_name == 'ArrayBufferView' %} |
| 788 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Handle<v8::Object> object) |
| 789 { |
| 790 ASSERT(object->IsArrayBufferView()); |
| 791 ScriptWrappableBase* internalPointer = blink::toScriptWrappableBase(object); |
| 792 if (internalPointer) |
| 793 return internalPointer->toImpl<{{cpp_class}}>(); |
| 794 |
| 795 if (object->IsInt8Array()) |
| 796 return V8Int8Array::toImpl(object); |
| 797 if (object->IsInt16Array()) |
| 798 return V8Int16Array::toImpl(object); |
| 799 if (object->IsInt32Array()) |
| 800 return V8Int32Array::toImpl(object); |
| 801 if (object->IsUint8Array()) |
| 802 return V8Uint8Array::toImpl(object); |
| 803 if (object->IsUint8ClampedArray()) |
| 804 return V8Uint8ClampedArray::toImpl(object); |
| 805 if (object->IsUint16Array()) |
| 806 return V8Uint16Array::toImpl(object); |
| 807 if (object->IsUint32Array()) |
| 808 return V8Uint32Array::toImpl(object); |
| 809 if (object->IsFloat32Array()) |
| 810 return V8Float32Array::toImpl(object); |
| 811 if (object->IsFloat64Array()) |
| 812 return V8Float64Array::toImpl(object); |
| 813 if (object->IsDataView()) |
| 814 return V8DataView::toImpl(object); |
| 815 |
| 816 ASSERT_NOT_REACHED(); |
| 817 return 0; |
| 818 } |
| 819 |
| 820 {% elif is_array_buffer_or_view %} |
| 821 {{cpp_class}}* {{v8_class}}::toImpl(v8::Handle<v8::Object> object) |
| 822 { |
| 823 ASSERT(object->Is{{interface_name}}()); |
| 824 ScriptWrappableBase* internalPointer = blink::toScriptWrappableBase(object); |
| 825 if (internalPointer) |
| 826 return internalPointer->toImpl<{{cpp_class}}>(); |
| 827 |
| 828 v8::Handle<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}
>(); |
| 829 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat
aView' %}Byte{% endif %}Length()); |
| 830 typedArray->associateWithWrapper(typedArray->wrapperTypeInfo(), object, v8::
Isolate::GetCurrent()); |
| 831 |
| 832 return typedArray->toImpl<{{cpp_class}}>(); |
| 833 } |
| 834 |
| 835 {% endif %} |
| 836 {% endblock %} |
| 837 |
| 838 |
753 {##############################################################################} | 839 {##############################################################################} |
754 {% block to_impl_with_type_check %} | 840 {% block to_impl_with_type_check %} |
755 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl
e<v8::Value> value) | 841 {{cpp_class}}* {{v8_class}}::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handl
e<v8::Value> value) |
756 { | 842 { |
| 843 {% if is_array_buffer_or_view %} |
| 844 return hasInstance(value, isolate) ? toImpl(v8::Handle<v8::Object>::Cast(val
ue)) : 0; |
| 845 {% else %} |
757 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; | 846 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<{{cpp_class}}>() : 0; |
| 847 {% endif %} |
758 } | 848 } |
759 | 849 |
760 {% endblock %} | 850 {% endblock %} |
761 | 851 |
762 | 852 |
763 {##############################################################################} | 853 {##############################################################################} |
764 {% block to_active_dom_object %} | 854 {% block to_active_dom_object %} |
765 {% if is_active_dom_object %} | 855 {% if is_active_dom_object %} |
766 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) | 856 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Handle<v8::Object> wrapper) |
767 { | 857 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate); | 938 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl, &wrapperTypeInf
o, wrapper, isolate); |
849 return wrapper; | 939 return wrapper; |
850 } | 940 } |
851 | 941 |
852 {% endif %} | 942 {% endif %} |
853 {% endblock %} | 943 {% endblock %} |
854 | 944 |
855 | 945 |
856 {##############################################################################} | 946 {##############################################################################} |
857 {% block deref_object_and_to_v8_no_inline %} | 947 {% block deref_object_and_to_v8_no_inline %} |
858 | |
859 void {{v8_class}}::refObject(ScriptWrappableBase* internalPointer) | 948 void {{v8_class}}::refObject(ScriptWrappableBase* internalPointer) |
860 { | 949 { |
861 {% if gc_type == 'WillBeGarbageCollectedObject' %} | 950 {% if gc_type == 'WillBeGarbageCollectedObject' %} |
862 #if !ENABLE(OILPAN) | 951 #if !ENABLE(OILPAN) |
863 internalPointer->toImpl<{{cpp_class}}>()->ref(); | 952 internalPointer->toImpl<{{cpp_class}}>()->ref(); |
864 #endif | 953 #endif |
865 {% elif gc_type == 'RefCountedObject' %} | 954 {% elif gc_type == 'RefCountedObject' %} |
866 internalPointer->toImpl<{{cpp_class}}>()->ref(); | 955 internalPointer->toImpl<{{cpp_class}}>()->ref(); |
867 {% endif %} | 956 {% endif %} |
868 } | 957 } |
869 | 958 |
870 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) | 959 void {{v8_class}}::derefObject(ScriptWrappableBase* internalPointer) |
871 { | 960 { |
872 {% if gc_type == 'WillBeGarbageCollectedObject' %} | 961 {% if gc_type == 'WillBeGarbageCollectedObject' %} |
873 #if !ENABLE(OILPAN) | 962 #if !ENABLE(OILPAN) |
874 internalPointer->toImpl<{{cpp_class}}>()->deref(); | 963 internalPointer->toImpl<{{cpp_class}}>()->deref(); |
875 #endif | 964 #endif |
876 {% elif gc_type == 'RefCountedObject' %} | 965 {% elif gc_type == 'RefCountedObject' %} |
877 internalPointer->toImpl<{{cpp_class}}>()->deref(); | 966 internalPointer->toImpl<{{cpp_class}}>()->deref(); |
878 {% endif %} | 967 {% endif %} |
879 } | 968 } |
880 | 969 |
881 template<> | 970 template<> |
882 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | 971 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) |
883 { | 972 { |
884 return toV8(impl, creationContext, isolate); | 973 return toV8(impl, creationContext, isolate); |
885 } | 974 } |
886 | 975 |
887 {% endblock %} | 976 {% endblock %} |
OLD | NEW |