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

Method newArrayWithValues

valdi/src/valdi/v8/V8JavaScriptContext.cpp:401–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399}
400
401JSValueRef V8JavaScriptContext::newArrayWithValues(const JSValue* values,
402 size_t size,
403 JSExceptionTracker& exceptionTracker) {
404 v8::HandleScope handleScope(_isolate);
405
406 auto* valuesUnpacked = static_cast<v8::Local<v8::Value>*>(alloca(sizeof(v8::Local<v8::Value>) * size));
407
408 for (size_t i = 0; i < size; i++) {
409 auto val = fromValdiJSValue(_isolate, values[i], exceptionTracker);
410 if (!exceptionTracker) {
411 return JSValueRef();
412 }
413 valuesUnpacked[i] = val;
414 }
415
416 auto val = v8::Array::New(_isolate, valuesUnpacked, size);
417 return toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, val));
418}
419
420JSValueRef V8JavaScriptContext::newArrayBuffer(const BytesView& buffer, JSExceptionTracker& exceptionTracker) {
421 v8::HandleScope handleScope(_isolate);

Callers 1

TEST_PFunction · 0.45

Calls 2

fromValdiJSValueFunction · 0.70
NewFunction · 0.50

Tested by 1

TEST_PFunction · 0.36