Ignore:
Timestamp:
Jul 3, 2006, 7:35:09 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Darin.


  • Refined value conversions in the API:
    • failed toNumber returns NaN
    • failed toObject returns NULL
    • failed toString returns empty string


  • Refined excpetion handling in the API:
    • failed value conversions do not throw exceptions
    • uncaught exceptions in JSEvaluate, JSObjectCallAsFunction, and JSObjectCallAsConstructor are returned through a JSValueRef* exception argument
    • removed JSContextHasException, because JSContextGetException does the same job


  • API/JSBase.h:
  • API/JSCharBufferRef.cpp: (JSValueCopyStringValue):
  • API/JSContextRef.cpp: (JSEvaluate):
  • API/JSContextRef.h:
  • API/JSNodeList.c: Added test code demonstrating how you would use toNumber, and why you probably don't need toUInt32, etc. (JSNodeListPrototype_item): (JSNodeList_getProperty):
  • API/JSObjectRef.cpp: (JSValueToObject): (JSObjectCallAsFunction): (JSObjectCallAsConstructor):
  • API/JSObjectRef.h:
  • API/JSValueRef.cpp: (JSValueToNumber):
  • API/JSValueRef.h:
  • API/minidom.c: (main):
  • API/testapi.c: (main): Added tests for new rules, and call to JSGCProtect to fix Intel crash
  • JavaScriptCore.exp:
File:
1 edited

Legend:

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

    r15133 r15149  
    4646
    4747    JSObjectRef objectRef = toRef(jsValue->toObject(exec));
    48     // FIXME: What should we do with this exception?
    49     if (exec->hadException())
     48    if (exec->hadException()) {
    5049        exec->clearException();
     50        objectRef = NULL;
     51    }
    5152    return objectRef;
    5253}   
     
    177178}
    178179
    179 bool JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* returnValue)
     180JSValueRef JSObjectCallAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception)
    180181{
    181182    JSLock lock;
     
    188189        argList.append(toJS(argv[i]));
    189190   
    190     *returnValue = jsObject->call(exec, jsThisObject, argList);
     191    JSValueRef result = toRef(jsObject->call(exec, jsThisObject, argList));
    191192    if (exec->hadException()) {
     193        if (exception)
     194            *exception = exec->exception();
     195        result = NULL;
    192196        exec->clearException();
    193         return false;
    194     }
    195     return true;
     197    }
     198    return result;
    196199}
    197200
     
    202205}
    203206
    204 bool JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* returnValue)
     207JSObjectRef JSObjectCallAsConstructor(JSContextRef context, JSObjectRef object, size_t argc, JSValueRef argv[], JSValueRef* exception)
    205208{
    206209    JSLock lock;
     
    212215        argList.append(toJS(argv[i]));
    213216   
    214     *returnValue = jsObject->construct(exec, argList);
     217    JSObjectRef result = toRef(jsObject->construct(exec, argList));
    215218    if (exec->hadException()) {
     219        if (exception)
     220            *exception = exec->exception();
     221        result = NULL;
    216222        exec->clearException();
    217         return false;
    218     }
    219     return true;
     223    }
     224    return result;
    220225}
    221226
Note: See TracChangeset for help on using the changeset viewer.