| 702 | } |
| 703 | |
| 704 | bool Object::getArrayBufferData(uint8_t **ptr, size_t *length) const { |
| 705 | CC_ASSERT(isArrayBuffer()); |
| 706 | #if CC_EDITOR && CC_PLATFORM == CC_PLATFORM_WINDOWS |
| 707 | v8::Local<v8::ArrayBuffer> jsobj = _getJSObject().As<v8::ArrayBuffer>(); |
| 708 | auto obj = v8::Int8Array::New(jsobj, 0, jsobj->ByteLength()); |
| 709 | char *data = node::Buffer::Data(obj.As<v8::Value>()); |
| 710 | *ptr = reinterpret_cast<uint8_t *>(data); |
| 711 | if (length) { |
| 712 | *length = node::Buffer::Length(obj.As<v8::Value>()); |
| 713 | } |
| 714 | #else |
| 715 | v8::Local<v8::Object> obj = const_cast<Object *>(this)->_obj.handle(__isolate); |
| 716 | v8::Local<v8::ArrayBuffer> arrBuf = v8::Local<v8::ArrayBuffer>::Cast(obj); |
| 717 | const auto &backingStore = arrBuf->GetBackingStore(); |
| 718 | *ptr = static_cast<uint8_t *>(backingStore->Data()); |
| 719 | if (length) { |
| 720 | *length = backingStore->ByteLength(); |
| 721 | } |
| 722 | #endif |
| 723 | return true; |
| 724 | } |
| 725 | |
| 726 | void Object::setPrivateObject(PrivateObjectBase *data) { |
| 727 | CC_ASSERT_NULL(_privateObject); |