MCPcopy Create free account
hub / github.com/cocos/cocos-engine / getArrayBufferData

Method getArrayBufferData

native/cocos/bindings/jswrapper/v8/Object.cpp:704–724  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702}
703
704bool 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
726void Object::setPrivateObject(PrivateObjectBase *data) {
727 CC_ASSERT_NULL(_privateObject);

Callers 15

ArrayBufferMethod · 0.45
setJSArrayBufferMethod · 0.45
resetMethod · 0.45
XMLHttpRequest_sendFunction · 0.45
sevalue_to_nativeFunction · 0.45

Calls 4

ByteLengthMethod · 0.80
handleMethod · 0.65
DataClass · 0.50
DataMethod · 0.45

Tested by 1

sevalue_to_nativeFunction · 0.36