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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 { | 717 { |
718 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | 718 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); |
719 } | 719 } |
720 | 720 |
721 {% endif %} | 721 {% endif %} |
722 {% endblock %} | 722 {% endblock %} |
723 | 723 |
724 | 724 |
725 {##############################################################################} | 725 {##############################################################################} |
726 {% block to_impl %} | 726 {% block to_impl %} |
727 {% if interface_name == 'ArrayBuffer' %} | 727 {% if interface_name == 'ArrayBuffer' or interface_name == 'SharedArrayBuffer' %
} |
728 {{cpp_class}}* V8ArrayBuffer::toImpl(v8::Local<v8::Object> object) | 728 {{cpp_class}}* V8{{interface_name}}::toImpl(v8::Local<v8::Object> object) |
729 { | 729 { |
730 ASSERT(object->IsArrayBuffer()); | 730 ASSERT(object->Is{{interface_name}}()); |
731 v8::Local<v8::ArrayBuffer> v8buffer = object.As<v8::ArrayBuffer>(); | 731 v8::Local<v8::{{interface_name}}> v8buffer = object.As<v8::{{interface_name}
}>(); |
732 if (v8buffer->IsExternal()) { | 732 if (v8buffer->IsExternal()) { |
733 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); | 733 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
734 RELEASE_ASSERT(wrapperTypeInfo); | 734 RELEASE_ASSERT(wrapperTypeInfo); |
735 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); | 735 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
736 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); | 736 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); |
737 } | 737 } |
738 | 738 |
739 // Transfer the ownership of the allocated memory to an ArrayBuffer without | 739 // Transfer the ownership of the allocated memory to an {{interface_name}} w
ithout |
740 // copying. | 740 // copying. |
741 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); | 741 v8::{{interface_name}}::Contents v8Contents = v8buffer->Externalize(); |
742 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, WTF::ArrayBufferContents::NotShared); | 742 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, WTF::ArrayBufferContents::{% if interface_name == 'ArrayBuffer' %}Not{% endif
%}Shared); |
743 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); | 743 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); |
744 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::I
solate::GetCurrent(), buffer->wrapperTypeInfo(), object); | 744 v8::Local<v8::Object> associatedWrapper = buffer->associateWithWrapper(v8::I
solate::GetCurrent(), buffer->wrapperTypeInfo(), object); |
745 ASSERT_UNUSED(associatedWrapper, associatedWrapper == object); | 745 ASSERT_UNUSED(associatedWrapper, associatedWrapper == object); |
746 | 746 |
747 return buffer.get(); | 747 return buffer.get(); |
748 } | 748 } |
749 | 749 |
750 {% elif interface_name == 'ArrayBufferView' %} | 750 {% elif interface_name == 'ArrayBufferView' %} |
751 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) | 751 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) |
752 { | 752 { |
(...skipping 29 matching lines...) Expand all Loading... |
782 | 782 |
783 {% elif is_array_buffer_or_view %} | 783 {% elif is_array_buffer_or_view %} |
784 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) | 784 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) |
785 { | 785 { |
786 ASSERT(object->Is{{interface_name}}()); | 786 ASSERT(object->Is{{interface_name}}()); |
787 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 787 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
788 if (scriptWrappable) | 788 if (scriptWrappable) |
789 return scriptWrappable->toImpl<{{cpp_class}}>(); | 789 return scriptWrappable->toImpl<{{cpp_class}}>(); |
790 | 790 |
791 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); | 791 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); |
792 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat
aView' %}Byte{% endif %}Length()); | 792 v8::Local<v8::Object> arrayBuffer = v8View->Buffer(); |
| 793 RefPtr<{{cpp_class}}> typedArray; |
| 794 if (arrayBuffer->IsArrayBuffer()) { |
| 795 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v
8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% endif %
}Length()); |
| 796 } else if (arrayBuffer->IsSharedArrayBuffer()) { |
| 797 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuff
er), v8View->ByteOffset(), v8View->{% if interface_name == 'DataView' %}Byte{% e
ndif %}Length()); |
| 798 } else { |
| 799 ASSERT_NOT_REACHED(); |
| 800 } |
793 v8::Local<v8::Object> associatedWrapper = typedArray->associateWithWrapper(v
8::Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object); | 801 v8::Local<v8::Object> associatedWrapper = typedArray->associateWithWrapper(v
8::Isolate::GetCurrent(), typedArray->wrapperTypeInfo(), object); |
794 ASSERT_UNUSED(associatedWrapper, associatedWrapper == object); | 802 ASSERT_UNUSED(associatedWrapper, associatedWrapper == object); |
795 | 803 |
796 return typedArray->toImpl<{{cpp_class}}>(); | 804 return typedArray->toImpl<{{cpp_class}}>(); |
797 } | 805 } |
798 | 806 |
799 {% endif %} | 807 {% endif %} |
800 {% endblock %} | 808 {% endblock %} |
801 | 809 |
802 | 810 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 967 } |
960 | 968 |
961 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 969 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
962 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 970 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
963 { | 971 { |
964 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 972 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
965 } | 973 } |
966 {% endfor %} | 974 {% endfor %} |
967 {% endif %} | 975 {% endif %} |
968 {% endblock %} | 976 {% endblock %} |
OLD | NEW |