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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 if (v8buffer->IsExternal()) { | 718 if (v8buffer->IsExternal()) { |
719 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); | 719 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
720 RELEASE_ASSERT(wrapperTypeInfo); | 720 RELEASE_ASSERT(wrapperTypeInfo); |
721 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); | 721 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
722 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); | 722 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); |
723 } | 723 } |
724 | 724 |
725 // Transfer the ownership of the allocated memory to an ArrayBuffer without | 725 // Transfer the ownership of the allocated memory to an ArrayBuffer without |
726 // copying. | 726 // copying. |
727 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); | 727 v8::ArrayBuffer::Contents v8Contents = v8buffer->Externalize(); |
728 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, 0); | 728 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, false, 0); |
729 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); | 729 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); |
730 // Since this transfer doesn't allocate new memory, do not call | 730 // Since this transfer doesn't allocate new memory, do not call |
731 // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory. | 731 // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory. |
| 732 buffer->buffer()->setDeallocationObserverWithoutAllocationNotification( |
| 733 DOMArrayBufferDeallocationObserver::instance()); |
| 734 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI
nfo(), object); |
| 735 |
| 736 return buffer.get(); |
| 737 } |
| 738 |
| 739 {% elif interface_name == 'SharedArrayBuffer' %} |
| 740 {{cpp_class}}* V8SharedArrayBuffer::toImpl(v8::Local<v8::Object> object) |
| 741 { |
| 742 ASSERT(object->IsSharedArrayBuffer()); |
| 743 v8::Local<v8::SharedArrayBuffer> v8buffer = object.As<v8::SharedArrayBuffer>
(); |
| 744 if (v8buffer->IsExternal()) { |
| 745 const WrapperTypeInfo* wrapperTypeInfo = toWrapperTypeInfo(object); |
| 746 RELEASE_ASSERT(wrapperTypeInfo); |
| 747 RELEASE_ASSERT(wrapperTypeInfo->ginEmbedder == gin::kEmbedderBlink); |
| 748 return toScriptWrappable(object)->toImpl<{{cpp_class}}>(); |
| 749 } |
| 750 |
| 751 // Transfer the ownership of the allocated memory to a SharedArrayBuffer |
| 752 // without copying. |
| 753 v8::SharedArrayBuffer::Contents v8Contents = v8buffer->Externalize(); |
| 754 WTF::ArrayBufferContents contents(v8Contents.Data(), v8Contents.ByteLength()
, true, 0); |
| 755 RefPtr<{{cpp_class}}> buffer = {{cpp_class}}::create(contents); |
| 756 // Since this transfer doesn't allocate new memory, do not call |
| 757 // DOMArrayBufferDeallocationObserver::blinkAllocatedMemory. |
732 buffer->buffer()->setDeallocationObserverWithoutAllocationNotification( | 758 buffer->buffer()->setDeallocationObserverWithoutAllocationNotification( |
733 DOMArrayBufferDeallocationObserver::instance()); | 759 DOMArrayBufferDeallocationObserver::instance()); |
734 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI
nfo(), object); | 760 buffer->associateWithWrapper(v8::Isolate::GetCurrent(), buffer->wrapperTypeI
nfo(), object); |
735 | 761 |
736 return buffer.get(); | 762 return buffer.get(); |
737 } | 763 } |
738 | 764 |
739 {% elif interface_name == 'ArrayBufferView' %} | 765 {% elif interface_name == 'ArrayBufferView' %} |
740 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) | 766 {{cpp_class}}* V8ArrayBufferView::toImpl(v8::Local<v8::Object> object) |
741 { | 767 { |
(...skipping 29 matching lines...) Expand all Loading... |
771 | 797 |
772 {% elif is_array_buffer_or_view %} | 798 {% elif is_array_buffer_or_view %} |
773 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) | 799 {{cpp_class}}* {{v8_class}}::toImpl(v8::Local<v8::Object> object) |
774 { | 800 { |
775 ASSERT(object->Is{{interface_name}}()); | 801 ASSERT(object->Is{{interface_name}}()); |
776 ScriptWrappable* scriptWrappable = toScriptWrappable(object); | 802 ScriptWrappable* scriptWrappable = toScriptWrappable(object); |
777 if (scriptWrappable) | 803 if (scriptWrappable) |
778 return scriptWrappable->toImpl<{{cpp_class}}>(); | 804 return scriptWrappable->toImpl<{{cpp_class}}>(); |
779 | 805 |
780 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); | 806 v8::Local<v8::{{interface_name}}> v8View = object.As<v8::{{interface_name}}>
(); |
781 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->{% if interface_name == 'Dat
aView' %}Byte{% endif %}Length()); | 807 {% if interface_name == 'DataView' %} |
| 808 RefPtr<{{cpp_class}}> typedArray = {{cpp_class}}::create(V8ArrayBuffer::toIm
pl(v8View->Buffer()), v8View->ByteOffset(), v8View->ByteLength()); |
| 809 {% else %} |
| 810 v8::Local<v8::Object> arrayBuffer = v8View->Buffer(); |
| 811 RefPtr<{{cpp_class}}> typedArray; |
| 812 if (arrayBuffer->IsArrayBuffer()) { |
| 813 typedArray = {{cpp_class}}::create(V8ArrayBuffer::toImpl(arrayBuffer), v
8View->ByteOffset(), v8View->Length()); |
| 814 } else if (arrayBuffer->IsSharedArrayBuffer()) { |
| 815 typedArray = {{cpp_class}}::create(V8SharedArrayBuffer::toImpl(arrayBuff
er), v8View->ByteOffset(), v8View->Length()); |
| 816 } else { |
| 817 ASSERT_NOT_REACHED(); |
| 818 } |
| 819 {% endif %} |
782 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap
perTypeInfo(), object); | 820 typedArray->associateWithWrapper(v8::Isolate::GetCurrent(), typedArray->wrap
perTypeInfo(), object); |
783 | 821 |
784 return typedArray->toImpl<{{cpp_class}}>(); | 822 return typedArray->toImpl<{{cpp_class}}>(); |
785 } | 823 } |
786 | 824 |
787 {% endif %} | 825 {% endif %} |
788 {% endblock %} | 826 {% endblock %} |
789 | 827 |
790 | 828 |
791 {##############################################################################} | 829 {##############################################################################} |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 } | 981 } |
944 | 982 |
945 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 983 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
946 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 984 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
947 { | 985 { |
948 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 986 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
949 } | 987 } |
950 {% endfor %} | 988 {% endfor %} |
951 {% endif %} | 989 {% endif %} |
952 {% endblock %} | 990 {% endblock %} |
OLD | NEW |