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

Function GetArrayBufferFromValue

unity/native_src/Src/Puerts.cpp:324–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

322}
323
324V8_EXPORT const char* GetArrayBufferFromValue(v8::Isolate* Isolate, v8::Value *Value, int *Length, int IsOut)
325{
326 if (IsOut)
327 {
328 auto Context = Isolate->GetCurrentContext();
329 auto Outer = Value->ToObject(Context).ToLocalChecked();
330 auto Realvalue = Outer->Get(Context, FV8Utils::V8String(Isolate, "value")).ToLocalChecked();
331 return GetArrayBufferFromValue(Isolate, *Realvalue, Length, false);
332 }
333 else
334 {
335 if (Value->IsArrayBufferView())
336 {
337 v8::ArrayBufferView * BuffView = v8::ArrayBufferView::Cast(Value);
338 *Length = static_cast<int>(BuffView->ByteLength());
339 auto ABC = BuffView->Buffer()->GetContents();
340 return static_cast<char*>(ABC.Data()) + BuffView->ByteOffset();
341 }
342 else if (Value->IsArrayBuffer())
343 {
344 auto Ab = v8::ArrayBuffer::Cast(Value);
345 auto ABC = Ab->GetContents();
346 *Length = static_cast<int>(ABC.ByteLength());
347 return static_cast<char*>(ABC.Data());
348 }
349 else
350 {
351 return nullptr;
352 }
353 }
354}
355
356V8_EXPORT void SetArrayBufferToOutValue(v8::Isolate* Isolate, v8::Value *Value, unsigned char *Bytes, int Length)
357{

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected