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

Method valueToTypedArray

valdi/src/valdi/v8/V8JavaScriptContext.cpp:900–913  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898}
899
900JSTypedArray V8JavaScriptContext::valueToTypedArray(const JSValue& value, JSExceptionTracker& exceptionTracker) {
901 v8::HandleScope handleScope(_isolate);
902
903 v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker);
904 if (!val->IsTypedArray()) {
905 exceptionTracker.onError("Value is not TypedArray");
906 return JSTypedArray();
907 }
908 v8::Local<v8::TypedArray> arr = v8::Local<v8::TypedArray>::Cast(val);
909 const auto type = getTypedArrayType(val);
910 void* data = arr->Buffer()->Data();
911 const size_t length = arr->ByteLength();
912 return JSTypedArray(type, data, length, toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, val)));
913}
914
915Ref<JSFunction> V8JavaScriptContext::valueToFunction(const JSValue& value, JSExceptionTracker& exceptionTracker) {
916 v8::HandleScope handleScope(_isolate);

Callers 1

marshallMethod · 0.45

Calls 7

JSTypedArrayClass · 0.85
BufferMethod · 0.80
fromValdiJSValueFunction · 0.70
getTypedArrayTypeFunction · 0.70
onErrorMethod · 0.65
CastFunction · 0.50
DataMethod · 0.45

Tested by

no test coverage detected