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

Method valueToWrappedObject

valdi/src/valdi/v8/V8JavaScriptContext.cpp:873–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871
872int32_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
888Ref<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) {

Callers 4

unwrapWrappedObjectFunction · 0.45
thisFromCallContextFunction · 0.45

Calls 7

getWithWrapperIDMethod · 0.80
onErrorMethod · 0.65
CastFunction · 0.50
isEmptyMethod · 0.45
GetInternalFieldMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected