Ignore:
Timestamp:
Jul 10, 2006, 5:26:25 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Darin.


Added exception out parameter to API object callbacks, removed semi-bogus
JSContext(.*)Exception functions.


To make these calls syntactically simple, I added an exceptionSlot()
method to the ExecState class, which provides a JSValue slot in which to
store a JSValue* exception.

  • API/APICast.h: (toRef):
  • API/JSCallbackConstructor.cpp: (KJS::JSCallbackConstructor::construct):
  • API/JSCallbackFunction.cpp: (KJS::JSCallbackFunction::callAsFunction):
  • API/JSCallbackObject.cpp: (KJS::JSCallbackObject::init): (KJS::JSCallbackObject::getOwnPropertySlot): (KJS::JSCallbackObject::put): (KJS::JSCallbackObject::deleteProperty): (KJS::JSCallbackObject::construct): (KJS::JSCallbackObject::callAsFunction): (KJS::JSCallbackObject::getPropertyList): (KJS::JSCallbackObject::toBoolean): (KJS::JSCallbackObject::toNumber): (KJS::JSCallbackObject::toString): (KJS::JSCallbackObject::staticValueGetter): (KJS::JSCallbackObject::callbackGetter):
  • API/JSContextRef.cpp: (JSCheckSyntax):
  • API/JSContextRef.h:
  • API/JSNode.c: (JSNodePrototype_appendChild): (JSNodePrototype_removeChild): (JSNodePrototype_replaceChild): (JSNode_getNodeType): (JSNode_getChildNodes): (JSNode_getFirstChild): (JSNode_construct):
  • API/JSNode.h:
  • API/JSNodeList.c: (JSNodeListPrototype_item): (JSNodeList_length): (JSNodeList_getProperty):
  • API/JSObjectRef.h:
  • API/minidom.c: (print):
  • API/testapi.c: (MyObject_initialize): (MyObject_hasProperty): (MyObject_getProperty): (MyObject_setProperty): (MyObject_deleteProperty): (MyObject_getPropertyList): (MyObject_callAsFunction): (MyObject_callAsConstructor): (MyObject_convertToType): (print_callAsFunction): (myConstructor_callAsConstructor): (main):
  • JavaScriptCore.exp:
  • kjs/ExecState.h: (KJS::ExecState::exceptionHandle):
File:
1 edited

Legend:

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

    r15310 r15317  
    6060@param context The execution context to use.
    6161@param object The JSObject being created.
     62@param exception A pointer to a JSValueRef in which to return an exception, if any.
    6263@discussion If you named your function Initialize, you would declare it like this:
    6364
    64 void Initialize(JSContextRef context, JSObjectRef object);
     65void Initialize(JSContextRef context, JSObjectRef object, JSValueRef* exception);
    6566*/
    6667typedef void
    67 (*JSInitializeCallback)         (JSContextRef context, JSObjectRef object);
     68(*JSInitializeCallback) (JSContextRef context, JSObjectRef object, JSValueRef* exception);
    6869
    6970/*!
     
    7677*/
    7778typedef void           
    78 (*JSFinalizeCallback)           (JSObjectRef object);
     79(*JSFinalizeCallback) (JSObjectRef object);
    7980
    8081/*!
     
    8485@param object The JSObject to search for the property.
    8586@param propertyName A JSInternalString containing the name of the property look up.
     87@param exception A pointer to a JSValueRef in which to return an exception, if any.
    8688@result true if object has the property, otherwise false.
    8789@discussion If you named your function HasProperty, you would declare it like this:
    8890
    89 bool HasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
     91bool HasProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* exception);
    9092
    9193This callback enables optimization in cases where only a property's existence needs to be known, not its value, and computing its value would be expensive. If this callback is NULL, the getProperty callback will be used to service hasProperty calls.
    9294*/
    9395typedef bool
    94 (*JSHasPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
     96(*JSHasPropertyCallback) (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* exception);
    9597
    9698/*!
     
    101103@param propertyName A JSInternalString containing the name of the property to get.
    102104@param returnValue A pointer to a JSValue in which to store the property's value.
     105@param exception A pointer to a JSValueRef in which to return an exception, if any.
    103106@result true if object has the property in question, otherwise false. If this function returns true, returnValue is assumed to contain a valid JSValue.
    104107@discussion If you named your function GetProperty, you would declare it like this:
    105108
    106 bool GetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue);
     109bool GetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue, JSValueRef* exception);
    107110
    108111If this function returns false, the get request forwards to object's static property table, then its parent class chain (which includes the default object class), then its prototype chain.
    109112*/
    110113typedef bool
    111 (*JSGetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue);
     114(*JSGetPropertyCallback) (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue, JSValueRef* exception);
    112115
    113116/*!
     
    118121@param propertyName A JSInternalString containing the name of the property to set.
    119122@param value A JSValue to use as the property's value.
     123@param exception A pointer to a JSValueRef in which to return an exception, if any.
    120124@result true if the property was successfully set, otherwise false.
    121125@discussion If you named your function SetProperty, you would declare it like this:
    122126
    123 bool SetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value);
     127bool SetProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value, JSValueRef* exception);
    124128
    125129If this function returns false, the set request forwards to object's static property table, then its parent class chain (which includes the default object class).
    126130*/
    127131typedef bool
    128 (*JSSetPropertyCallback)        (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value);
     132(*JSSetPropertyCallback) (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef value, JSValueRef* exception);
    129133
    130134/*!
     
    134138@param object The JSObject in which to delete the property.
    135139@param propertyName A JSInternalString containing the name of the property to delete.
     140@param exception A pointer to a JSValueRef in which to return an exception, if any.
    136141@result true if propertyName was successfully deleted, otherwise false.
    137142@discussion If you named your function DeleteProperty, you would declare it like this:
    138143
    139 bool DeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
     144bool DeleteProperty(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* exception);
    140145
    141146If this function returns false, the delete request forwards to object's static property table, then its parent class chain (which includes the default object class).
    142147*/
    143148typedef bool
    144 (*JSDeletePropertyCallback)     (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName);
     149(*JSDeletePropertyCallback) (JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* exception);
    145150
    146151/*!
     
    150155@param object The JSObject whose properties need to be added to propertyList.
    151156@param propertyList A JavaScript property list that will be used to enumerate object's properties.
     157@param exception A pointer to a JSValueRef in which to return an exception, if any.
    152158@discussion If you named your function GetPropertyList, you would declare it like this:
    153159
    154 void GetPropertyList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList);
     160void GetPropertyList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
    155161
    156162Use JSPropertyListAdd to add properties to propertyList.
     
    159165*/
    160166typedef void
    161 (*JSGetPropertyListCallback)    (JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList);
     167(*JSGetPropertyListCallback) (JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList, JSValueRef* exception);
    162168
    163169/*!
     
    169175@param argc An integer count of the number of arguments in argv.
    170176@param argv A JSValue array of the  arguments passed to the function.
     177@param exception A pointer to a JSValueRef in which to return an exception, if any.
    171178@result A JSValue that is the function's return value.
    172179@discussion If you named your function CallAsFunction, you would declare it like this:
    173180
    174 JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[]);
     181JSValueRef CallAsFunction(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
    175182
    176183If your callback were invoked by the JavaScript expression 'myObject.myMemberFunction()', function would be set to myMemberFunction, and thisObject would be set to myObject.
     
    179186*/
    180187typedef JSValueRef
    181 (*JSCallAsFunctionCallback)     (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[]);
     188(*JSCallAsFunctionCallback) (JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, JSValueRef argv[], JSValueRef* exception);
    182189
    183190/*!
     
    188195@param argc An integer count of the number of arguments in argv.
    189196@param argv A JSValue array of the  arguments passed to the function.
     197@param exception A pointer to a JSValueRef in which to return an exception, if any.
    190198@result A JSObject that is the constructor's return value.
    191199@discussion If you named your function CallAsConstructor, you would declare it like this:
    192200
    193 JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[]);
     201JSObjectRef CallAsConstructor(JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[], JSValueRef* exception);
    194202
    195203If your callback were invoked by the JavaScript expression 'new myConstructorFunction()', constructor would be set to myConstructorFunction.
     
    198206*/
    199207typedef JSObjectRef
    200 (*JSCallAsConstructorCallback)  (JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[]);
     208(*JSCallAsConstructorCallback) (JSContextRef context, JSObjectRef constructor, size_t argc, JSValueRef argv[], JSValueRef* exception);
    201209
    202210/*!
     
    207215@param typeCode A JSTypeCode specifying the JavaScript type to convert to.
    208216@param returnValue A pointer to a JSValue in which to store the converted value.
     217@param exception A pointer to a JSValueRef in which to return an exception, if any.
    209218@result true if the value was converted, otherwise false. If this function returns true, returnValue is assumed to contain a valid JSValue.
    210219@discussion If you named your function ConvertToType, you would declare it like this:
    211220
    212 bool ConvertToType(JSContextRef context, JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue);
     221bool ConvertToType(JSContextRef context, JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue, JSValueRef* exception);
    213222
    214223If this function returns false, the conversion request forwards to object's parent class chain (which includes the default object class).
    215224*/
    216225typedef bool
    217 (*JSConvertToTypeCallback)      (JSContextRef context, JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue);
     226(*JSConvertToTypeCallback) (JSContextRef context, JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue, JSValueRef* exception);
    218227
    219228/*!
Note: See TracChangeset for help on using the changeset viewer.