Ignore:
Timestamp:
Jul 17, 2006, 3:49:28 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Removed the exception parameter from the initialize callback and, by extension, JSObjectMake. We have never had a need for exceptions when iniitializing, so the parameter seemed likely to "get in the way."


Also, an exception in JavaScript is thrown in response to input --
"invalid URL", "index not a number", etc., so it's the job of the
constructor function, not the initialize method, to throw.


If initialize *really* wants to throw, it can communicate the throw to
the constructor through the constructed object's private data (e.g., set
it to NULL, signaling to the consntructor that initialization failed.)


  • Added JSObjectMakeWithData, which enables a constructor to set private data on an object *before* it has been initialized. That way, the initialize methods can properly operate on the data.
  • API/JSNode.c: Moved ref into the initialize method, for better encapsulation, now that it's possible.
  • API/JSNodeList.c: ditto
  • API/minidom.c: (main): Do more aggressive garbage collection to test ref/deref and initialize/finalize.
  • API/minidom.js: store childNodes in a temporary so it doesn't get re-created like a thousand times. This makes debugging ref/deref easier
File:
1 edited

Legend:

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

    r15483 r15484  
    6363@param ctx The execution context to use.
    6464@param object The JSObject being created.
    65 @param exception A pointer to a JSValueRef in which to return an exception, if any.
    6665@discussion If you named your function Initialize, you would declare it like this:
    6766
    68 void Initialize(JSContextRef ctx, JSObjectRef object, JSValueRef* exception);
     67void Initialize(JSContextRef ctx, JSObjectRef object);
    6968
    7069Unlike the other object callbacks, the initialize callback is called on the least
     
    7271*/
    7372typedef void
    74 (*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object, JSValueRef* exception);
     73(*JSObjectInitializeCallback) (JSContextRef ctx, JSObjectRef object);
    7574
    7675/*!
     
    380379/*!
    381380@function
    382 @abstract Creates a JavaScript object with a given class and prototype.
     381@abstract Creates a JavaScript object.
    383382@param ctx The execution context to use.
    384383@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class.
    385384@param prototype The prototype to assign to the object. Pass NULL to use the default object prototype.
    386 @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.
    387 @result A JSObject with the given class and prototype.
    388 */
    389 JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype, JSValueRef* exception);
     385@result A JSObject with the given class, prototype, and private data.
     386@discussion The default object class does not allocate storage for private data, so you must provide a non-NULL JSClass if you want your object to be able to store private data.
     387*/
     388JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype);
     389
     390/*!
     391@function
     392@abstract Creates a JavaScript object.
     393@param ctx The execution context to use.
     394@param jsClass The JSClass to assign to the object. Pass NULL to use the default object class.
     395@param prototype The prototype to assign to the object. Pass NULL to use the default object prototype.
     396@param data A void* to set as the object's private data. Pass NULL to specify no private data.
     397@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.
     398@result A JSObject with the given class, prototype, and private data.
     399@discussion The default object class does not allocate storage for private data, so you must provide a non-NULL JSClass if you want your object to be able to store private data.
     400 
     401data will be set on the created object before the intialize methods in its class chain are called. This enables the initialize methods to retrieve and manipulate data through JSObjectGetPrivate.
     402*/
     403JSObjectRef JSObjectMakeWithData(JSContextRef ctx, JSClassRef jsClass, JSValueRef prototype, void* data);
    390404
    391405/*!
     
    512526/*!
    513527@function
    514 @abstract Gets a pointer to private data from an object.
     528@abstract Gets an object's private data.
    515529@param object A JSObject whose private data you want to get.
    516 @result A void* that points to the object's private data, if the object has private data, otherwise NULL.
     530@result A void* that is the object's private data, if the object has private data, otherwise NULL.
    517531*/
    518532void* JSObjectGetPrivate(JSObjectRef object);
     
    522536@abstract Sets a pointer to private data on an object.
    523537@param object A JSObject whose private data you want to set.
    524 @param data A void* that points to the object's private data.
     538@param data A void* to set as the object's private data.
    525539@result true if the object can store private data, otherwise false.
    526 @discussion Only custom objects created with a JSClass can store private data.
     540@discussion The default object class does not allocate storage for private data. Only objects created with a non-NULL JSClass can store private data.
    527541*/
    528542bool JSObjectSetPrivate(JSObjectRef object, void* data);
Note: See TracChangeset for help on using the changeset viewer.