JSObject* jsObject = toJS(object);
JSObject* jsThisObject = toJS(thisObject);
+ if (!jsThisObject)
+ jsThisObject = exec->dynamicInterpreter()->globalObject();
+
List argList;
for (size_t i = 0; i < argc; i++)
argList.append(toJS(argv[i]));
if (exec->hadException()) {
if (exception)
*exception = exec->exception();
- result = NULL;
exec->clearException();
+ result = NULL;
}
return result;
}
@abstract Calls an object as a function.
@param context The execution context to use.
@param object The JSObject to call as a function.
-@param thisObject The JSObject to use as 'this' in the function call.
+@param thisObject The object to use as "this," or NULL to use the global object as "this."
@param argc An integer count of the number of arguments in argv.
@param argv A JSValue array of the arguments to pass to the function.
@param exception A pointer to a JSValueRef in which to store an uncaught exception, if any. Pass NULL if you do not care to store an uncaught exception.
JSClassRef nullCallbacksClass = JSClassCreate(NULL, NULL, NULL, NULL);
JSClassRelease(nullCallbacksClass);
+ functionBuf = JSStringBufferCreateUTF8("return this;");
+ function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1, NULL);
+ JSStringBufferRelease(functionBuf);
+ v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
+ assert(JSValueIsEqual(context, v, globalObject));
+ v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
+ assert(JSValueIsEqual(context, v, o));
+
char* script = createStringWithContentsOfFile("testapi.js");
JSStringBufferRef scriptBuf = JSStringBufferCreateUTF8(script);
result = JSEvaluate(context, scriptBuf, NULL, NULL, 1, &exception);
+2006-07-08 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by TimO.
+
+ - Added ability to pass NULL for thisObject when calling JSObjectCallAsFunction,
+ to match JSEvaluate.
+
+ * API/JSObjectRef.cpp:
+ (JSObjectCallAsFunction):
+ * API/JSObjectRef.h:
+ * API/testapi.c:
+ (main):
+
=== Safari-521.15 ===
2006-07-07 Geoffrey Garen <ggaren@apple.com>