Changeset 15376 in webkit for trunk/JavaScriptCore/API/JSNode.c


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/JSNode.c

    r15328 r15376  
    4040    // Example of throwing a type error for invalid values
    4141    if (!JSValueIsObjectOfClass(thisObject, JSNode_class(context))) {
    42         JSInternalStringRef message = JSInternalStringCreateUTF8("TypeError: appendChild can only be called on nodes");
    43         *exception = JSStringMake(message);
    44         JSInternalStringRelease(message);
     42        JSStringRef message = JSStringCreateWithUTF8CString("TypeError: appendChild can only be called on nodes");
     43        *exception = JSValueMakeString(message);
     44        JSStringRelease(message);
    4545    } else if (argc < 1 || !JSValueIsObjectOfClass(argv[0], JSNode_class(context))) {
    46         JSInternalStringRef message = JSInternalStringCreateUTF8("TypeError: first argument to appendChild must be a node");
    47         *exception = JSStringMake(message);
    48         JSInternalStringRelease(message);
     46        JSStringRef message = JSStringCreateWithUTF8CString("TypeError: first argument to appendChild must be a node");
     47        *exception = JSValueMakeString(message);
     48        JSStringRelease(message);
    4949    } else {
    5050        Node* node = JSObjectGetPrivate(thisObject);
     
    5454    }
    5555
    56     return JSUndefinedMake();
     56    return JSValueMakeUndefined();
    5757}
    5858
     
    7474    }
    7575   
    76     return JSUndefinedMake();
     76    return JSValueMakeUndefined();
    7777}
    7878
     
    9696    }
    9797   
    98     return JSUndefinedMake();
     98    return JSValueMakeUndefined();
    9999}
    100100
     
    114114}
    115115
    116 static bool JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue, JSValueRef* exception)
     116static JSValueRef JSNode_getNodeType(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    117117{
    118118    UNUSED_PARAM(context);
     
    121121    Node* node = JSObjectGetPrivate(object);
    122122    if (node) {
    123         JSInternalStringRef nodeType = JSInternalStringCreateUTF8(node->nodeType);
    124         *returnValue = JSStringMake(nodeType);
    125         JSInternalStringRelease(nodeType);
    126         return true;
    127     }
    128     return false;
    129 }
    130 
    131 static bool JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, JSInternalStringRef propertyName, JSValueRef* returnValue, JSValueRef* exception)
     123        JSStringRef nodeType = JSStringCreateWithUTF8CString(node->nodeType);
     124        JSValueRef value = JSValueMakeString(nodeType);
     125        JSStringRelease(nodeType);
     126        return value;
     127    }
     128   
     129    return NULL;
     130}
     131
     132static JSValueRef JSNode_getChildNodes(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
    132133{
    133134    UNUSED_PARAM(propertyName);
    134135    Node* node = JSObjectGetPrivate(thisObject);
    135136    assert(node);
    136     *returnValue = JSNodeList_new(context, NodeList_new(node));
    137     return true;
    138 }
    139 
    140 static bool JSNode_getFirstChild(JSContextRef context, JSObjectRef object, JSInternalStringRef propertyName, JSValueRef* returnValue, JSValueRef* exception)
     137    return JSNodeList_new(context, NodeList_new(node));
     138}
     139
     140static JSValueRef JSNode_getFirstChild(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
    141141{
    142142    UNUSED_PARAM(context);
     
    144144    UNUSED_PARAM(object);
    145145   
    146     *returnValue = JSUndefinedMake();
    147     return true;
     146    return JSValueMakeUndefined();
    148147}
    149148
     
    180179    if (!prototype) {
    181180        prototype = JSObjectMake(context, JSNodePrototype_class(context), NULL);
    182         JSGCProtect(prototype);
     181        JSValueProtect(prototype);
    183182    }
    184183    return prototype;
Note: See TracChangeset for help on using the changeset viewer.