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

Method call

third-party/jscore/include/JavaScriptCore/APICallbackFunction.h:45–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44template <typename T>
45EncodedJSValue JSC_HOST_CALL APICallbackFunction::call(ExecState* exec)
46{
47 VM& vm = exec->vm();
48 auto scope = DECLARE_THROW_SCOPE(vm);
49 JSContextRef execRef = toRef(exec);
50 JSObjectRef functionRef = toRef(exec->jsCallee());
51 JSObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode)));
52
53 int argumentCount = static_cast<int>(exec->argumentCount());
54 Vector<JSValueRef, 16> arguments;
55 arguments.reserveInitialCapacity(argumentCount);
56 for (int i = 0; i < argumentCount; i++)
57 arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));
58
59 JSValueRef exception = 0;
60 JSValueRef result;
61 {
62 JSLock::DropAllLocks dropAllLocks(exec);
63 result = jsCast<T*>(toJS(functionRef))->functionCallback()(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
64 }
65 if (exception)
66 throwException(exec, scope, toJS(exec, exception));
67
68 // result must be a valid JSValue.
69 if (!result)
70 return JSValue::encode(jsUndefined());
71
72 return JSValue::encode(toJS(exec, result));
73}
74
75template <typename T>
76EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec)

Callers

nothing calls this directly

Calls 5

toRefFunction · 0.85
toJSFunction · 0.85
encodeFunction · 0.85
functionCallbackMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected