MCPcopy Create free account
hub / github.com/Tencent/puerts / GetArrayBufferFromResult

Function GetArrayBufferFromResult

unity/native_src/Src/Puerts.cpp:748–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748V8_EXPORT const char *GetArrayBufferFromResult(FResultInfo *ResultInfo, int *Length)
749{
750 v8::Isolate* Isolate = ResultInfo->Isolate;
751 v8::Isolate::Scope IsolateScope(Isolate);
752 v8::HandleScope HandleScope(Isolate);
753 v8::Local<v8::Context> Context = ResultInfo->Context.Get(Isolate);
754 v8::Context::Scope ContextScope(Context);
755
756 auto Value = ResultInfo->Result.Get(Isolate);
757 if (Value->IsArrayBufferView())
758 {
759 v8::Local<v8::ArrayBufferView> BuffView = Value.As<v8::ArrayBufferView>();
760 *Length = static_cast<int>(BuffView->ByteLength());
761 auto ABC = BuffView->Buffer()->GetContents();
762 return static_cast<char*>(ABC.Data()) + BuffView->ByteOffset();
763 }
764 else if (Value->IsArrayBuffer())
765 {
766 auto Ab = v8::Local <v8::ArrayBuffer>::Cast(Value);
767 auto ABC = Ab->GetContents();
768 *Length = static_cast<int>(ABC.ByteLength());
769 return static_cast<char*>(ABC.Data());
770 }
771 else
772 {
773 return nullptr;
774 }
775}
776
777V8_EXPORT void *GetObjectFromResult(FResultInfo *ResultInfo)
778{

Callers

nothing calls this directly

Calls 9

CastFunction · 0.85
IsArrayBufferViewMethod · 0.80
ByteLengthMethod · 0.80
GetContentsMethod · 0.80
BufferMethod · 0.80
ByteOffsetMethod · 0.80
IsArrayBufferMethod · 0.80
GetMethod · 0.45
DataMethod · 0.45

Tested by

no test coverage detected