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}
872
873Ref<RefCountable> V8JavaScriptContext::valueToWrappedObject(const JSValue& value,
874 JSExceptionTracker& exceptionTracker) {
875 v8::HandleScope handleScope(_isolate);
876 auto indirect = fromValdiJSValueToIndirect(value);
877 auto objectInfo = indirect.getWithWrapperID(_isolate);
878 auto val = v8::Local<v8::Object>::Cast(objectInfo.first);
879
880 if (indirect.isEmpty()) {
881 exceptionTracker.onError("Provided js value is already been cleared");
882 return Ref<RefCountable>();
883 } else if (!val->IsObject()) {
884 exceptionTracker.onError("Provided js value is not object");
885 return Ref<RefCountable>();
886 } else if (objectInfo.second != kWrappedObjectID) {
887 exceptionTracker.onError("Provided js value is not a wrapped object");
888 return Ref<RefCountable>();
889 }
890
891 SC_ASSERT(val->InternalFieldCount() == static_cast<int>(InternalFieldSlot::Count));
892 auto external = v8::Local<v8::External>::Cast(val->GetInternalField(static_cast<int>(InternalFieldSlot::DataSlot)));
893 if (!external->IsExternal()) {
894 exceptionTracker.onError("Internal field value is not of type external");
895 }
896
897 return unsafeBridge<RefCountable>(external->Value());
898}
899
900JSTypedArray V8JavaScriptContext::valueToTypedArray(const JSValue& value, JSExceptionTracker& exceptionTracker) {
901 v8::HandleScope handleScope(_isolate);

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