]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - API/APICallbackFunction.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / API / APICallbackFunction.h
index 0298ecb59f5cc3fa08e5702fa999bb0ac0265acf..94b10c420b3297e63c070d27b305d54cddda9c28 100644 (file)
@@ -27,9 +27,9 @@
 #define APICallbackFunction_h
 
 #include "APICast.h"
-#include "APIShims.h"
 #include "Error.h"
 #include "JSCallbackConstructor.h"
+#include "JSLock.h"
 #include <wtf/Vector.h>
 
 namespace JSC {
@@ -42,26 +42,26 @@ template <typename T> static EncodedJSValue JSC_HOST_CALL construct(ExecState*);
 };
 
 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)
@@ -83,16 +83,18 @@ EncodedJSValue JSC_HOST_CALL APICallbackFunction::construct(ExecState* exec)
         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);