Changeset 15233 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jul 8, 2006, 10:42:39 AM (19 years ago)
Author:
ggaren
Message:

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):
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15225 r15233  
    218218    JSObject* jsThisObject = toJS(thisObject);
    219219
     220    if (!jsThisObject)
     221        jsThisObject = exec->dynamicInterpreter()->globalObject();
     222   
    220223    List argList;
    221224    for (size_t i = 0; i < argc; i++)
     
    226229        if (exception)
    227230            *exception = exec->exception();
     231        exec->clearException();
    228232        result = NULL;
    229         exec->clearException();
    230233    }
    231234    return result;
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15225 r15233  
    442442@param context The execution context to use.
    443443@param object The JSObject to call as a function.
    444 @param thisObject The JSObject to use as 'this' in the function call.
     444@param thisObject The object to use as "this," or NULL to use the global object as "this."
    445445@param argc An integer count of the number of arguments in argv.
    446446@param argv A JSValue array of the  arguments to pass to the function.
  • trunk/JavaScriptCore/API/testapi.c

    r15225 r15233  
    602602    JSClassRelease(nullCallbacksClass);
    603603   
     604    functionBuf = JSStringBufferCreateUTF8("return this;");
     605    function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1, NULL);
     606    JSStringBufferRelease(functionBuf);
     607    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
     608    assert(JSValueIsEqual(context, v, globalObject));
     609    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
     610    assert(JSValueIsEqual(context, v, o));
     611   
    604612    char* script = createStringWithContentsOfFile("testapi.js");
    605613    JSStringBufferRef scriptBuf = JSStringBufferCreateUTF8(script);
  • trunk/JavaScriptCore/ChangeLog

    r15228 r15233  
     12006-07-08  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by TimO.
     4
     5        - Added ability to pass NULL for thisObject when calling JSObjectCallAsFunction,
     6        to match JSEvaluate.
     7       
     8        * API/JSObjectRef.cpp:
     9        (JSObjectCallAsFunction):
     10        * API/JSObjectRef.h:
     11        * API/testapi.c:
     12        (main):
     13
    114=== Safari-521.15 ===
    215
Note: See TracChangeset for help on using the changeset viewer.