| 43 | |
| 44 | template <typename T> |
| 45 | EncodedJSValue 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 | |
| 75 | template <typename T> |
| 76 | EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec) |
nothing calls this directly
no test coverage detected