Changeset 15404 in webkit


Ignore:
Timestamp:
Jul 13, 2006, 1:56:52 AM (19 years ago)
Author:
ggaren
Message:

Pleasing to Maciej.


  • Renamed JSEvaluate -> JSEvaluateScript, JSCheckSyntax -> JSCheckScriptSyntax
  • Added exception out parameters to JSValueTo* and JSValueIsEqual because they can throw
  • Removed JSObjectGetDescription because it's useless and vague, and JSValueToString/JSValueIsObjectOfClass do a better job, anyway
  • Clarified comments about "IsFunction/Constructor" to indicate that they are true of all functions/constructors, not just those created by JSObjectMake*
Location:
trunk/JavaScriptCore
Files:
14 edited

Legend:

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

    r15376 r15404  
    6363}
    6464
    65 JSValueRef JSEvaluate(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     65JSValueRef JSEvaluateScript(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    6666{
    6767    JSLock lock;
     
    8686}
    8787
    88 bool JSCheckSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
     88bool JSCheckScriptSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
    8989{
    9090    JSLock lock;
  • trunk/JavaScriptCore/API/JSContextRef.h

    r15376 r15404  
    7272@param sourceURL          A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions.
    7373@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions.
    74 @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.
    75 @result                   The JSValue that results from evaluating script, or NULL if an uncaught exception is thrown.
     74@param exception          A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
     75@result                   The JSValue that results from evaluating script, or NULL if an exception is thrown.
    7676*/
    77 JSValueRef JSEvaluate(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     77JSValueRef JSEvaluateScript(JSContextRef context, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    7878
    7979/*!
    80 @function JSCheckSyntax
     80@function JSCheckScriptSyntax
    8181@abstract                 Checks for syntax errors in a string of JavaScript.
    8282@param context            The execution context to use.
     
    8787@result                   true if the script is syntactically correct, otherwise false.
    8888*/
    89 bool JSCheckSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
     89bool JSCheckScriptSyntax(JSContextRef context, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception);
    9090
    9191#ifdef __cplusplus
  • trunk/JavaScriptCore/API/JSNode.c

    r15376 r15404  
    4949    } else {
    5050        Node* node = JSObjectGetPrivate(thisObject);
    51         Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0]));
     51        Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
    5252
    5353        Node_appendChild(node, child);
     
    6767            if (JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
    6868                Node* node = JSObjectGetPrivate(thisObject);
    69                 Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0]));
     69                Node* child = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
    7070               
    7171                Node_removeChild(node, child);
     
    8787                if (JSValueIsObjectOfClass(argv[1], JSNode_class(context))) {
    8888                    Node* node = JSObjectGetPrivate(thisObject);
    89                     Node* newChild = JSObjectGetPrivate(JSValueToObject(context, argv[0]));
    90                     Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, argv[1]));
     89                    Node* newChild = JSObjectGetPrivate(JSValueToObject(context, argv[0], NULL));
     90                    Node* oldChild = JSObjectGetPrivate(JSValueToObject(context, argv[1], NULL));
    9191                   
    9292                    Node_replaceChild(node, newChild, oldChild);
  • trunk/JavaScriptCore/API/JSNodeList.c

    r15376 r15404  
    3434        NodeList* nodeList = JSObjectGetPrivate(thisObject);
    3535        assert(nodeList);
    36         Node* node = NodeList_item(nodeList, JSValueToNumber(context, argv[0]));
     36        Node* node = NodeList_item(nodeList, JSValueToNumber(context, argv[0], exception));
    3737        if (node)
    3838            return JSNode_new(context, node);
     
    7575    NodeList* nodeList = JSObjectGetPrivate(thisObject);
    7676    assert(nodeList);
    77     double index = JSValueToNumber(context, JSValueMakeString(propertyName));
     77    double index = JSValueToNumber(context, JSValueMakeString(propertyName), exception);
    7878    unsigned uindex = index;
    7979    if (uindex == index) { // false for NaN
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r15385 r15404  
    9797}
    9898
    99 JSStringRef JSObjectGetDescription(JSObjectRef object)
    100 {
    101     JSLock lock;
    102     JSObject* jsObject = toJS(object);
    103     return toRef(jsObject->className().rep());
    104 }
    105 
    10699JSValueRef JSObjectGetPrototype(JSObjectRef object)
    107100{
  • trunk/JavaScriptCore/API/JSObjectRef.h

    r15385 r15404  
    386386/*!
    387387@function
    388 @abstract Gets a short description of a JavaScript object.
    389 @param context The execution context to use.
    390 @param object The object whose description you want to get.
    391 @result A JSString containing the object's description. This is usually the object's class name.
    392 */
    393 JSStringRef JSObjectGetDescription(JSObjectRef object);
    394 
    395 /*!
    396 @function
    397388@abstract Gets an object's prototype.
    398389@param object A JSObject whose prototype you want to get.
     
    466457/*!
    467458@function
    468 @abstract Tests whether an object is a function.
     459@abstract Tests whether an object can be called as a function.
    469460@param object The JSObject to test.
    470 @result true if the object is a function, otherwise false.
     461@result true if the object can be called as a function, otherwise false.
    471462*/
    472463bool JSObjectIsFunction(JSObjectRef object);
     
    485476/*!
    486477@function
    487 @abstract Tests whether an object is a constructor.
     478@abstract Tests whether an object can be called as a constructor.
    488479@param object The JSObject to test.
    489 @result true if the object is a constructor, otherwise false.
     480@result true if the object can be called as a constructor, otherwise false.
    490481*/
    491482bool JSObjectIsConstructor(JSObjectRef object);
  • trunk/JavaScriptCore/API/JSStringRef.cpp

    r15400 r15404  
    6969    UString::Rep* rep = toJS(string);
    7070    rep->deref();
    71 }
    72 
    73 JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value)
    74 {
    75     JSLock lock;
    76     JSValue* jsValue = toJS(value);
    77     ExecState* exec = toJS(context);
    78 
    79     JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref());
    80     if (exec->hadException())
    81         exec->clearException();
    82     return stringRef;
    8371}
    8472
  • trunk/JavaScriptCore/API/JSValueRef.cpp

    r15376 r15404  
    110110}
    111111
    112 bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b)
     112bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b, JSValueRef* exception)
    113113{
    114114    JSLock lock;
     
    117117    JSValue* jsB = toJS(b);
    118118
    119     bool result = equal(exec, jsA, jsB);
    120     if (exec->hadException())
    121         exec->clearException();
     119    bool result = equal(exec, jsA, jsB); // false if an exception is thrown
     120    if (exec->hadException()) {
     121        if (exception)
     122            *exception = toRef(exec->exception());
     123        exec->clearException();
     124    }
    122125    return result;
    123126}
     
    130133    JSValue* jsB = toJS(b);
    131134   
    132     bool result = strictEqual(exec, jsA, jsB);
    133     if (exec->hadException())
    134         exec->clearException();
     135    bool result = strictEqual(exec, jsA, jsB); // can't throw because it doesn't perform value conversion
     136    ASSERT(!exec->hadException());
    135137    return result;
    136138}
     
    170172}
    171173
    172 bool JSValueToBoolean(JSContextRef context, JSValueRef value)
     174bool JSValueToBoolean(JSContextRef context, JSValueRef value, JSValueRef* exception)
    173175{
    174176    JSLock lock;
     
    178180    bool boolean = jsValue->toBoolean(exec);
    179181    if (exec->hadException()) {
     182        if (exception)
     183            *exception = toRef(exec->exception());
    180184        exec->clearException();
    181185        boolean = false;
     
    184188}
    185189
    186 double JSValueToNumber(JSContextRef context, JSValueRef value)
     190double JSValueToNumber(JSContextRef context, JSValueRef value, JSValueRef* exception)
    187191{
    188192    JSLock lock;
     
    192196    double number = jsValue->toNumber(exec);
    193197    if (exec->hadException()) {
     198        if (exception)
     199            *exception = toRef(exec->exception());
    194200        exec->clearException();
    195201        number = NaN;
     
    198204}
    199205
    200 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value)
     206JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value, JSValueRef* exception)
     207{
     208    JSLock lock;
     209    JSValue* jsValue = toJS(value);
     210    ExecState* exec = toJS(context);
     211   
     212    JSStringRef stringRef = toRef(jsValue->toString(exec).rep()->ref());
     213    if (exec->hadException()) {
     214        if (exception)
     215            *exception = toRef(exec->exception());
     216        exec->clearException();
     217        stringRef = 0;
     218    }
     219    return stringRef;
     220}
     221
     222JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value, JSValueRef* exception)
    201223{
    202224    JSLock lock;
     
    206228    JSObjectRef objectRef = toRef(jsValue->toObject(exec));
    207229    if (exec->hadException()) {
     230        if (exception)
     231            *exception = toRef(exec->exception());
    208232        exec->clearException();
    209233        objectRef = 0;
  • trunk/JavaScriptCore/API/JSValueRef.h

    r15376 r15404  
    125125/*!
    126126@function
    127 @abstract       Tests whether two JavaScript values are equal, as compared by the JS == operator.
    128 @param context  The execution context to use.
    129 @param a        The first value to test.
    130 @param b        The second value to test.
    131 @result         true if the two values are equal, otherwise false.
    132 */
    133 bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b);
     127@abstract Tests whether two JavaScript values are equal, as compared by the JS == operator.
     128@param context The execution context to use.
     129@param a The first value to test.
     130@param b The second value to test.
     131@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
     132@result true if the two values are equal, false if they are not equal or an exception is thrown.
     133*/
     134bool JSValueIsEqual(JSContextRef context, JSValueRef a, JSValueRef b, JSValueRef* exception);
    134135
    135136/*!
     
    204205@param context  The execution context to use.
    205206@param value    The JSValue to convert.
    206 @result         The boolean result of conversion.
    207 */
    208 bool JSValueToBoolean(JSContextRef context, JSValueRef value);
     207@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
     208@result         The boolean result of conversion, or false if an exception is thrown.
     209*/
     210bool JSValueToBoolean(JSContextRef context, JSValueRef value, JSValueRef* exception);
    209211
    210212/*!
     
    213215@param context  The execution context to use.
    214216@param value    The JSValue to convert.
    215 @result         The numeric result of conversion, or NaN if conversion fails.
    216 */
    217 double JSValueToNumber(JSContextRef context, JSValueRef value);
     217@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
     218@result         The numeric result of conversion, or NaN if an exception is thrown.
     219*/
     220double JSValueToNumber(JSContextRef context, JSValueRef value, JSValueRef* exception);
    218221
    219222/*!
     
    222225@param context  The execution context to use.
    223226@param value    The JSValue to convert.
    224 @result         A JSString with the result of conversion, or an empty string if conversion fails. Ownership follows the Create Rule.
    225 */
    226 JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value);
     227@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
     228@result         A JSString with the result of conversion, or NULL if an exception is thrown. Ownership follows the Create Rule.
     229*/
     230JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value, JSValueRef* exception);
    227231
    228232/*!
     
    231235@param context  The execution context to use.
    232236@param value    The JSValue to convert.
     237@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
    233238@result         The JSObject result of conversion, or NULL if conversion fails.
    234239*/
    235 JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value);
     240JSObjectRef JSValueToObject(JSContextRef context, JSValueRef value, JSValueRef* exception);
    236241
    237242// Garbage collection
  • trunk/JavaScriptCore/API/minidom.c

    r15376 r15404  
    5151    JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
    5252    JSValueRef exception;
    53     JSValueRef result = JSEvaluate(context, script, NULL, NULL, 0, &exception);
     53    JSValueRef result = JSEvaluateScript(context, script, NULL, NULL, 0, &exception);
    5454    if (result)
    5555        printf("PASS: Test script executed successfully.\n");
    5656    else {
    5757        printf("FAIL: Test script threw exception:\n");
    58         JSStringRef exceptionIString = JSValueToStringCopy(context, exception);
     58        JSStringRef exceptionIString = JSValueToStringCopy(context, exception, NULL);
    5959        CFStringRef exceptionCF = JSStringCopyCFString(kCFAllocatorDefault, exceptionIString);
    6060        CFShow(exceptionCF);
     
    8282{
    8383    if (argc > 0) {
    84         JSStringRef string = JSValueToStringCopy(context, argv[0]);
     84        JSStringRef string = JSValueToStringCopy(context, argv[0], NULL);
    8585        size_t numChars = JSStringGetMaximumUTF8CStringSize(string);
    8686        char stringUTF8[numChars];
  • trunk/JavaScriptCore/API/testapi.c

    r15385 r15404  
    3939static void assertEqualsAsBoolean(JSValueRef value, bool expectedValue)
    4040{
    41     if (JSValueToBoolean(context, value) != expectedValue)
     41    if (JSValueToBoolean(context, value, NULL) != expectedValue)
    4242        fprintf(stderr, "assertEqualsAsBoolean failed: %p, %d\n", value, expectedValue);
    4343}
     
    4545static void assertEqualsAsNumber(JSValueRef value, double expectedValue)
    4646{
    47     double number = JSValueToNumber(context, value);
     47    double number = JSValueToNumber(context, value, NULL);
    4848    if (number != expectedValue && !(isnan(number) && isnan(expectedValue)))
    4949        fprintf(stderr, "assertEqualsAsNumber failed: %p, %lf\n", value, expectedValue);
     
    5252static void assertEqualsAsUTF8String(JSValueRef value, const char* expectedValue)
    5353{
    54     JSStringRef valueAsString = JSValueToStringCopy(context, value);
     54    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);
    5555
    5656    size_t jsSize = JSStringGetMaximumUTF8CStringSize(valueAsString);
     
    7070static void assertEqualsAsCharactersPtr(JSValueRef value, const char* expectedValue)
    7171{
    72     JSStringRef valueAsString = JSValueToStringCopy(context, value);
     72    JSStringRef valueAsString = JSValueToStringCopy(context, value, NULL);
    7373
    7474    size_t jsLength = JSStringGetLength(valueAsString);
     
    196196
    197197    if (argc > 0 && JSValueIsStrictEqual(context, argv[0], JSValueMakeNumber(0)))
    198         return JSValueToObject(context, JSValueMakeNumber(1));
    199    
    200     return JSValueToObject(context, JSValueMakeNumber(0));
     198        return JSValueToObject(context, JSValueMakeNumber(1), NULL);
     199   
     200    return JSValueToObject(context, JSValueMakeNumber(0), NULL);
    201201}
    202202
     
    206206
    207207    JSStringRef numberString = JSStringCreateWithUTF8CString("Number");
    208     JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString));
     208    JSObjectRef numberConstructor = JSValueToObject(context, JSObjectGetProperty(context, JSContextGetGlobalObject(context), numberString), NULL);
    209209    JSStringRelease(numberString);
    210210
     
    219219    switch (type) {
    220220    case kJSTypeBoolean:
    221         return JSValueMakeBoolean(false); // default object conversion is 'true'
     221        *exception = JSValueMakeNumber(2);
     222        return NULL;
    222223    case kJSTypeNumber:
    223224        return JSValueMakeNumber(1);
     
    269270   
    270271    if (argc > 0) {
    271         JSStringRef string = JSValueToStringCopy(context, argv[0]);
     272        JSStringRef string = JSValueToStringCopy(context, argv[0], NULL);
    272273        size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string);
    273274        char stringUTF8[sizeUTF8];
     
    302303   
    303304    context = JSContextCreate(NULL);
    304 
     305   
     306    JSObjectRef globalObject = JSContextGetGlobalObject(context);
     307    assert(JSValueIsObject(globalObject));
     308   
    305309    JSValueRef jsUndefined = JSValueMakeUndefined();
    306310    JSValueRef jsNull = JSValueMakeNull();
     
    364368#endif // __APPLE__
    365369
     370    JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
     371    assert(didInitialize);
     372    JSStringRef myObjectIString = JSStringCreateWithUTF8CString("MyObject");
     373    JSObjectSetProperty(context, globalObject, myObjectIString, myObject, kJSPropertyAttributeNone);
     374    JSStringRelease(myObjectIString);
     375   
     376    JSValueRef exception;
     377
    366378    // Conversions that throw exceptions
    367     assert(NULL == JSValueToObject(context, jsNull));
    368     assert(isnan(JSValueToNumber(context, jsObjectNoProto)));
    369     assertEqualsAsCharactersPtr(jsObjectNoProto, "");
     379    exception = NULL;
     380    assert(NULL == JSValueToObject(context, jsNull, &exception));
     381    assert(exception);
     382   
     383    exception = NULL;
     384    assert(isnan(JSValueToNumber(context, jsObjectNoProto, &exception)));
     385    assert(exception);
     386
     387    exception = NULL;
     388    assert(!JSValueToStringCopy(context, jsObjectNoProto, &exception));
     389    assert(exception);
     390   
     391    exception = NULL;
     392    assert(!JSValueToBoolean(context, myObject, &exception));
     393    assert(exception);
     394   
     395    exception = NULL;
     396    assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(1), &exception));
     397    assert(exception);
    370398
    371399    assertEqualsAsBoolean(jsUndefined, false);
     
    437465    assert(!JSValueIsStrictEqual(context, jsOne, jsOneString));
    438466
    439     assert(JSValueIsEqual(context, jsOne, jsOneString));
    440     assert(!JSValueIsEqual(context, jsTrue, jsFalse));
     467    assert(JSValueIsEqual(context, jsOne, jsOneString, NULL));
     468    assert(!JSValueIsEqual(context, jsTrue, jsFalse, NULL));
    441469   
    442470#if defined(__APPLE__)
     
    458486    JSValueUnprotect(jsGlobalValue);
    459487
    460     /* JSInterpreter.h */
    461    
    462     JSObjectRef globalObject = JSContextGetGlobalObject(context);
    463     assert(JSValueIsObject(globalObject));
    464 
    465488    JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;");
    466489    JSStringRef badSyntax = JSStringCreateWithUTF8CString("x := 1;");
    467     assert(JSCheckSyntax(context, goodSyntax, NULL, 0, NULL));
    468     assert(!JSCheckSyntax(context, badSyntax, NULL, 0, NULL));
     490    assert(JSCheckScriptSyntax(context, goodSyntax, NULL, 0, NULL));
     491    assert(!JSCheckScriptSyntax(context, badSyntax, NULL, 0, NULL));
    469492
    470493    JSValueRef result;
    471     JSValueRef exception;
    472494    JSValueRef v;
    473495    JSObjectRef o;
    474496
    475     result = JSEvaluate(context, goodSyntax, NULL, NULL, 1, NULL);
     497    result = JSEvaluateScript(context, goodSyntax, NULL, NULL, 1, NULL);
    476498    assert(result);
    477     assert(JSValueIsEqual(context, result, jsOne));
     499    assert(JSValueIsEqual(context, result, jsOne, NULL));
    478500
    479501    exception = NULL;
    480     result = JSEvaluate(context, badSyntax, NULL, NULL, 1, &exception);
     502    result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception);
    481503    assert(!result);
    482504    assert(JSValueIsObject(exception));
     
    485507    v = JSObjectGetProperty(context, globalObject, array);
    486508    assert(v);
    487     JSObjectRef arrayConstructor = JSValueToObject(context, v);
     509    JSObjectRef arrayConstructor = JSValueToObject(context, v, NULL);
    488510    JSStringRelease(array);
    489511    result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL);
     
    499521    assert(!JSObjectMakeFunctionWithBody(context, functionBody, NULL, 1, &exception));
    500522    assert(JSValueIsObject(exception));
    501     v = JSObjectGetProperty(context, JSValueToObject(context, exception), line);
     523    v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line);
    502524    assert(v);
    503525    assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact)
     
    511533    assert(JSObjectIsFunction(function));
    512534    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
    513     assert(JSValueIsEqual(context, v, arrayConstructor));
     535    assert(JSValueIsEqual(context, v, arrayConstructor, NULL));
    514536                                                 
    515     JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL);
    516     assert(didInitialize);
    517     JSStringRef myObjectIString = JSStringCreateWithUTF8CString("MyObject");
    518     JSObjectSetProperty(context, globalObject, myObjectIString, myObject, kJSPropertyAttributeNone);
    519     JSStringRelease(myObjectIString);
    520 
    521537    JSStringRef print = JSStringCreateWithUTF8CString("print");
    522538    JSObjectRef printFunction = JSObjectMakeFunction(context, print_callAsFunction);
     
    552568    JSStringRelease(functionBody);
    553569    v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL);
    554     assert(JSValueIsEqual(context, v, globalObject));
     570    assert(JSValueIsEqual(context, v, globalObject, NULL));
    555571    v = JSObjectCallAsFunction(context, function, o, 0, NULL, NULL);
    556     assert(JSValueIsEqual(context, v, o));
     572    assert(JSValueIsEqual(context, v, o, NULL));
    557573   
    558574    char* scriptUTF8 = createStringWithContentsOfFile("testapi.js");
    559575    JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
    560     result = JSEvaluate(context, script, NULL, NULL, 1, &exception);
     576    result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception);
    561577    if (JSValueIsUndefined(result))
    562578        printf("PASS: Test script executed successfully.\n");
    563579    else {
    564580        printf("FAIL: Test script returned unexcpected value:\n");
    565         JSStringRef exceptionIString = JSValueToStringCopy(context, exception);
     581        JSStringRef exceptionIString = JSValueToStringCopy(context, exception, NULL);
    566582        CFStringRef exceptionCF = JSStringCopyCFString(kCFAllocatorDefault, exceptionIString);
    567583        CFShow(exceptionCF);
  • trunk/JavaScriptCore/API/testapi.js

    r15384 r15404  
    7373shouldBe("MyObject()", undefined);
    7474shouldBe("typeof new MyObject()", "object");
    75 shouldBe("MyObject ? 1 : 0", 0); // toBoolean
     75shouldBe("MyObject ? 1 : 0", 2); // toBoolean -- should throw 2
    7676shouldBe("+MyObject", 1); // toNumber
    7777shouldBe("(MyObject.toString())", "[object CallbackObject]"); // toString
  • trunk/JavaScriptCore/ChangeLog

    r15400 r15404  
     12006-07-13  Geoffrey Garen  <[email protected]>
     2
     3        Pleasing to Maciej.
     4       
     5        - Renamed JSEvaluate -> JSEvaluateScript, JSCheckSyntax -> JSCheckScriptSyntax
     6        - Added exception out parameters to JSValueTo* and JSValueIsEqual because
     7        they can throw
     8        - Removed JSObjectGetDescription because it's useless and vague, and
     9        JSValueToString/JSValueIsObjectOfClass do a better job, anyway
     10        - Clarified comments about "IsFunction/Constructor" to indicate that they
     11        are true of all functions/constructors, not just those created by JSObjectMake*
     12
    1132006-07-12  Geoffrey Garen  <[email protected]>
    214
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r15385 r15404  
    22.objc_class_name_WebScriptObjectPrivate
    33.objc_class_name_WebUndefined
    4 _JSCheckSyntax
     4_JSCheckScriptSyntax
    55_JSClassCreate
    66_JSClassRelease
     
    99_JSContextDestroy
    1010_JSContextGetGlobalObject
    11 _JSEvaluate
     11_JSEvaluateScript
    1212_JSGarbageCollect
    1313_JSObjectCallAsConstructor
     
    1515_JSObjectCreatePropertyEnumerator
    1616_JSObjectDeleteProperty
    17 _JSObjectGetDescription
    1817_JSObjectGetPrivate
    1918_JSObjectGetProperty
Note: See TracChangeset for help on using the changeset viewer.