#define APICallbackFunction_h
#include "APICast.h"
-#include "APIShims.h"
#include "Error.h"
#include "JSCallbackConstructor.h"
+#include "JSLock.h"
#include <wtf/Vector.h>
namespace JSC {
};
template <typename T>
-EncodedJSValue APICallbackFunction::call(ExecState* exec)
+EncodedJSValue JSC_HOST_CALL APICallbackFunction::call(ExecState* exec)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(exec->callee());
- JSObjectRef thisObjRef = toRef(exec->hostThisValue().toThisObject(exec));
+ JSObjectRef thisObjRef = toRef(jsCast<JSObject*>(exec->thisValue().toThis(exec, NotStrictMode)));
int argumentCount = static_cast<int>(exec->argumentCount());
Vector<JSValueRef, 16> arguments;
arguments.reserveInitialCapacity(argumentCount);
for (int i = 0; i < argumentCount; i++)
- arguments.uncheckedAppend(toRef(exec, exec->argument(i)));
+ arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));
JSValueRef exception = 0;
JSValueRef result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = jsCast<T*>(toJS(functionRef))->functionCallback()(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
}
if (exception)
- throwError(exec, toJS(exec, exception));
+ exec->vm().throwException(exec, toJS(exec, exception));
// result must be a valid JSValue.
if (!result)
Vector<JSValueRef, 16> arguments;
arguments.reserveInitialCapacity(argumentCount);
for (size_t i = 0; i < argumentCount; ++i)
- arguments.uncheckedAppend(toRef(exec, exec->argument(i)));
+ arguments.uncheckedAppend(toRef(exec, exec->uncheckedArgument(i)));
JSValueRef exception = 0;
JSObjectRef result;
{
- APICallbackShim callbackShim(exec);
+ JSLock::DropAllLocks dropAllLocks(exec);
result = callback(ctx, constructorRef, argumentCount, arguments.data(), &exception);
}
- if (exception)
- throwError(exec, toJS(exec, exception));
+ if (exception) {
+ exec->vm().throwException(exec, toJS(exec, exception));
+ return JSValue::encode(toJS(exec, exception));
+ }
// result must be a valid JSValue.
if (!result)
return throwVMTypeError(exec);