Ignore:
Timestamp:
Jul 12, 2006, 1:12:08 AM (19 years ago)
Author:
ggaren
Message:

Reviewed by Maciej.


  • Implemented a vast number of renames and comment clarifications suggested during API review.


JSInternalString -> JSString
JS*Make -> JSValueMake*, JSObjectMake*
JSTypeCode -> JSType
JSValueIsInstanceOf -> JSValueIsInstanceOfConstructor (reads strangely well in client code)
JSGC*Protect -> JSValue*Protect
JS*Callback -> JSObject*Callback
JSGetPropertyListCallback -> JSObjectAddPropertiesToListCallback
JSPropertyEnumeratorGetNext -> JSPropertyEnumeratorGetNextName
JSString* ->

JSStringCreateWithUTF8CString, JSStringGetUTF8CString,
JSStringGetMaximumUTF8CStringSize JSStringIsEqualToUTF8CString,
JSStringCreateWithCFString, JSStringCopyCFString, JSStringCreateWithCharacters.


  • Changed functions taking a JSValue out arg and returning a bool indicating whether it was set to simply return a JSValue or NULL.


  • Removed JSStringGetCharacters because it's more documentation than code, and it's just a glorified memcpy built on existing API functionality.


  • Moved standard library includes into the headers that actually require them.


  • Standardized use of the phrase "Create Rule."


  • Removed JSLock from make functions that don't allocate.


  • Added exception handling to JSValueToBoolean, since we now allow callback objects to throw exceptions upon converting to boolean.


  • Renamed JSGCCollect to JSGarbageCollect.
File:
1 edited

Legend:

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

    r15328 r15376  
    3030#include <JavaScriptCore/JSBase.h>
    3131
    32 /*!
    33 @enum JSTypeCode
     32#include <stdbool.h>
     33
     34/*!
     35@enum JSType
    3436@abstract     A constant identifying the type of a JSValue.
    3537@constant     kJSTypeUndefined  The unique undefined value.
     
    4749    kJSTypeString,
    4850    kJSTypeObject
    49 } JSTypeCode;
     51} JSType;
    5052
    5153#ifdef __cplusplus
     
    5557/*!
    5658@function
    57 @abstract       Returns a JavaScript value's type code.
     59@abstract       Returns a JavaScript value's type.
    5860@param value    The JSValue whose type you want to obtain.
    59 @result         A value of type JSTypeCode that identifies value's type.
    60 */
    61 JSTypeCode JSValueGetType(JSValueRef value);
     61@result         A value of type JSType that identifies value's type.
     62*/
     63JSType JSValueGetType(JSValueRef value);
    6264
    6365/*!
     
    151153 by the JS instanceof operator, otherwise false.
    152154*/
    153 bool JSValueIsInstanceOf(JSContextRef context, JSValueRef value, JSObjectRef constructor);
     155bool JSValueIsInstanceOfConstructor(JSContextRef context, JSValueRef value, JSObjectRef constructor);
    154156
    155157// Creating values
     
    160162@result     The unique undefined value.
    161163*/
    162 JSValueRef JSUndefinedMake(void);
     164JSValueRef JSValueMakeUndefined(void);
    163165
    164166/*!
     
    167169@result     The unique null value.
    168170*/
    169 JSValueRef JSNullMake(void);
     171JSValueRef JSValueMakeNull(void);
    170172
    171173/*!
    172174@function
    173175@abstract       Creates a JavaScript value of the boolean type.
    174 @param value    The boolean value to assign to the newly created JSValue.
    175 @result         A JSValue of the boolean type, representing the boolean value of value.
    176 */
    177 
    178 JSValueRef JSBooleanMake(bool value);
     176@param boolean  The bool to assign to the newly created JSValue.
     177@result         A JSValue of the boolean type, representing the value of boolean.
     178*/
     179
     180JSValueRef JSValueMakeBoolean(bool boolean);
    179181
    180182/*!
    181183@function
    182184@abstract       Creates a JavaScript value of the number type.
    183 @param value    The numeric value to assign to the newly created JSValue.
    184 @result         A JSValue of the number type, representing the numeric value of value.
    185 */
    186 JSValueRef JSNumberMake(double value);
     185@param number   The double to assign to the newly created JSValue.
     186@result         A JSValue of the number type, representing the value of number.
     187*/
     188JSValueRef JSValueMakeNumber(double number);
    187189
    188190/*!
    189191@function
    190192@abstract       Creates a JavaScript value of the string type.
    191 @param string   The JSInternalString to assign to the newly created JSValue. The
     193@param string   The JSString to assign to the newly created JSValue. The
    192194 newly created JSValue retains string, and releases it upon garbage collection.
    193 @result         A JSValue of the string type, representing the string value of string.
    194 */
    195 JSValueRef JSStringMake(JSInternalStringRef string);
     195@result         A JSValue of the string type, representing the value of string.
     196*/
     197JSValueRef JSValueMakeString(JSStringRef string);
    196198
    197199// Converting to primitive values
     
    217219/*!
    218220@function
    219 @abstract       Converts a JavaScript value to string and copies the resulting
    220  string into a newly allocated JavaScript string.
    221 @param context  The execution context to use.
    222 @param value    The JSValue to convert.
    223 @result         A JSInternalString containing the result of conversion, or an empty
    224  string if conversion fails. Ownership follows the copy rule.
    225 */
    226 JSInternalStringRef JSValueCopyStringValue(JSContextRef context, JSValueRef value);
     221@abstract       Converts a JavaScript value to string and copies the result into a JavaScript string.
     222@param context  The execution context to use.
     223@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*/
     226JSStringRef JSValueToStringCopy(JSContextRef context, JSValueRef value);
    227227
    228228/*!
     
    243243 equal number of times before becoming eligible for garbage collection.
    244244*/
    245 void JSGCProtect(JSValueRef value);
     245void JSValueProtect(JSValueRef value);
    246246
    247247/*!
     
    252252 equal number of times before becoming eligible for garbage collection.
    253253*/
    254 void JSGCUnprotect(JSValueRef value);
     254void JSValueUnprotect(JSValueRef value);
    255255
    256256/*!
     
    258258@abstract Performs a JavaScript garbage collection.
    259259@discussion JavaScript values that are on the machine stack, in a register,
    260  protected by JSGCProtect, set as the global object of an execution context, or reachable from any such
    261  value will not be collected. It is not normally necessary to call this function
    262  directly; the JS runtime will garbage collect as needed.
    263 */
    264 void JSGCCollect(void);
     260 protected by JSValueProtect, set as the global object of an execution context,
     261 or reachable from any such value will not be collected.
     262 
     263 You are not required to call this function; the JavaScript engine will garbage
     264 collect as needed.
     265*/
     266void JSGarbageCollect(void);
    265267
    266268#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.