MCPcopy Create free account
hub / github.com/Snapchat/Valdi / newWrappedObject

Method newWrappedObject

valdi/src/valdi/v8/V8JavaScriptContext.cpp:491–508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489 }
490
491 auto val = v8::Array::New(_isolate, valuesUnpacked, size);
492 return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, val));
493}
494
495JSValueRef V8JavaScriptContext::newArrayBuffer(const BytesView& buffer, JSExceptionTracker& exceptionTracker) {
496 v8::HandleScope handleScope(_isolate);
497 v8::Local<v8::ArrayBuffer> val;
498 if (buffer.empty()) {
499 // NOTE(rjaber): Should we cache the object like qjs ?
500 val = v8::ArrayBuffer::New(_isolate, 0);
501 } else {
502 // NOTE(rjaber): There has to be an API for creating a shared backing store QQ
503 auto backingStore = v8::ArrayBuffer::NewBackingStore(const_cast<Byte*>(buffer.data()),
504 buffer.size(),
505 &freeArrayBuffer,
506 unsafeBridgeRetain(buffer.getSource().get()));
507 val = v8::ArrayBuffer::New(_isolate, std::move(backingStore));
508 }
509
510 return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, val));
511};

Callers 5

makeOpaqueFunction · 0.45
makeWrappedObjectFunction · 0.45
runtimeCreateWorkerMethod · 0.45

Calls 6

unsafeBridgeRetainFunction · 0.85
ToLocalMethod · 0.80
onErrorMethod · 0.65
getMethod · 0.65
NewFunction · 0.50
GetMethod · 0.45

Tested by

no test coverage detected