| 913 | } |
| 914 | |
| 915 | Ref<JSFunction> V8JavaScriptContext::valueToFunction(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 916 | v8::HandleScope handleScope(_isolate); |
| 917 | |
| 918 | auto val = v8::Local<v8::Function>::Cast(fromValdiJSValue(_isolate, value, exceptionTracker)); |
| 919 | if (!val->IsFunction()) { |
| 920 | exceptionTracker.onError("Was not provided with a function value"); |
| 921 | return nullptr; |
| 922 | } |
| 923 | |
| 924 | v8::Local<v8::Context> context = v8::Local<v8::Context>::New(_isolate, _context); |
| 925 | v8::Local<v8::Private> privateProp = _functionDataProperty.Get(_isolate); |
| 926 | if (val->HasPrivate(context, privateProp).IsNothing()) { |
| 927 | exceptionTracker.onError("Provided function was not wrapped by the v8 js context"); |
| 928 | return nullptr; |
| 929 | } |
| 930 | |
| 931 | auto data = v8::Local<v8::External>::Cast(val->GetPrivate(context, privateProp).ToLocalChecked()); |
| 932 | if (!data->IsExternal()) { |
| 933 | exceptionTracker.onError("Provided function did not contain data of the expected type"); |
| 934 | return nullptr; |
| 935 | } |
| 936 | |
| 937 | return unsafeBridge<JSFunction>(data->Value()); |
| 938 | } |
| 939 | |
| 940 | ValueType V8JavaScriptContext::getValueType(const JSValue& value) { |
| 941 | v8::HandleScope handleScope(_isolate); |
no test coverage detected