| 913 | } |
| 914 | |
| 915 | JSTypedArray V8JavaScriptContext::valueToTypedArray(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 916 | v8::HandleScope handleScope(_isolate); |
| 917 | |
| 918 | v8::Local<v8::Value> val = fromValdiJSValue(_isolate, value, exceptionTracker); |
| 919 | if (!val->IsTypedArray()) { |
| 920 | exceptionTracker.onError("Value is not TypedArray"); |
| 921 | return JSTypedArray(); |
| 922 | } |
| 923 | v8::Local<v8::TypedArray> arr = v8::Local<v8::TypedArray>::Cast(val); |
| 924 | const auto type = getTypedArrayType(val); |
| 925 | void* data = arr->Buffer()->Data(); |
| 926 | const size_t length = arr->ByteLength(); |
| 927 | return JSTypedArray(type, data, length, toRetainedJSValueRef(IndirectV8Persistent::make(_isolate, val))); |
| 928 | } |
| 929 | |
| 930 | Ref<JSFunction> V8JavaScriptContext::valueToFunction(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 931 | v8::HandleScope handleScope(_isolate); |
| 932 | |
| 933 | auto val = v8::Local<v8::Function>::Cast(fromValdiJSValue(_isolate, value, exceptionTracker)); |
| 934 | if (!val->IsFunction()) { |
| 935 | exceptionTracker.onError("Was not provided with a function value"); |
| 936 | return nullptr; |
| 937 | } |
| 938 | |
| 939 | v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context); |
| 940 | v8::Local<v8::Private> privateProp = _functionDataProperty.Get(_isolate); |
| 941 | if (val->HasPrivate(context, privateProp).IsNothing()) { |
no test coverage detected