| 871 | |
| 872 | int32_t V8JavaScriptContext::valueToInt(const JSValue& value, JSExceptionTracker& exceptionTracker) { |
| 873 | v8::HandleScope handleScope(_isolate); |
| 874 | |
| 875 | auto val = v8::Local<v8::Int32>::Cast(fromValdiJSValue(_isolate, value, exceptionTracker)); |
| 876 | if (!exceptionTracker) { |
| 877 | return 0; |
| 878 | } |
| 879 | |
| 880 | if (!val->IsInt32()) { |
| 881 | exceptionTracker.onError("Value is not an int32 type and cannot be converted"); |
| 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | return val->Value(); |
| 886 | } |
| 887 | |
| 888 | Ref<RefCountable> V8JavaScriptContext::valueToWrappedObject(const JSValue& value, |
| 889 | JSExceptionTracker& exceptionTracker) { |
| 890 | v8::HandleScope handleScope(_isolate); |
| 891 | auto indirect = fromValdiJSValueToIndirect(value); |
| 892 | auto objectInfo = indirect.getWithWrapperID(_isolate); |
| 893 | auto val = v8::Local<v8::Object>::Cast(objectInfo.first); |
| 894 | |
| 895 | if (indirect.isEmpty()) { |
| 896 | exceptionTracker.onError("Provided js value is already been cleared"); |
| 897 | return Ref<RefCountable>(); |
| 898 | } else if (!val->IsObject()) { |
| 899 | exceptionTracker.onError("Provided js value is not object"); |
| 900 | return Ref<RefCountable>(); |
| 901 | } else if (objectInfo.second != kWrappedObjectID) { |
no test coverage detected