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

Method valueToWrappedObject

valdi/src/valdi/hermes/HermesJavaScriptContext.cpp:897–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895
896 return hermes::vm::Callable::call(handle, *_runtime);
897}
898
899JSValueRef HermesJavaScriptContext::callObjectAsFunction(const JSValue& object, JSFunctionCallContext& callContext) {
900 hermes::vm::GCScope gcScope(*_runtime);
901 const auto* hermesValue = toPinnedHermesValue(object);
902
903 if (!hermes::vm::vmisa<hermes::vm::Callable>(*hermesValue)) {
904 callContext.getExceptionTracker().onError("Value is not a function");
905 return newUndefined();
906 }
907
908 auto handle = hermes::vm::Handle<hermes::vm::Callable>::vmcast(hermesValue);
909
910 auto thisValue = toHermesValue(callContext.getThisValue());
911 hermes::vm::ScopedNativeCallFrame callFrame(*_runtime,
912 static_cast<uint32_t>(callContext.getParameterSize()),
913 handle.getHermesValue(),
914 hermes::vm::HermesValue::encodeUndefinedValue(),
915 thisValue.isUndefined() ? _runtime->getGlobal().getHermesValue() :
916 thisValue);
917
918 auto callResult = doCall(callFrame, handle, callContext);
919
920 if (!checkException(callResult.getStatus(), callContext.getExceptionTracker())) {
921 return newUndefined();
922 }
923
924 return toJSValueRef(callResult->get());
925}
926
927JSValueRef HermesJavaScriptContext::callObjectAsConstructor(const JSValue& object, JSFunctionCallContext& callContext) {
928 hermes::vm::GCScope gcScope(*_runtime);
929 const auto* hermesValue = toPinnedHermesValue(object);
930

Callers

nothing calls this directly

Calls 6

canReceiveNativeStateFunction · 0.85
getStatusMethod · 0.80
getMethod · 0.65
getValueMethod · 0.65
contextMethod · 0.65
isObjectMethod · 0.45

Tested by

no test coverage detected