Changeset 15376 in webkit for trunk/JavaScriptCore/API/minidom.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/minidom.c

    r15328 r15376  
    4040    JSObjectRef globalObject = JSContextGetGlobalObject(context);
    4141   
    42     JSInternalStringRef printIString = JSInternalStringCreateUTF8("print");
    43     JSObjectSetProperty(context, globalObject, printIString, JSFunctionMake(context, print), kJSPropertyAttributeNone);
    44     JSInternalStringRelease(printIString);
     42    JSStringRef printIString = JSStringCreateWithUTF8CString("print");
     43    JSObjectSetProperty(context, globalObject, printIString, JSObjectMakeFunction(context, print), kJSPropertyAttributeNone);
     44    JSStringRelease(printIString);
    4545   
    46     JSInternalStringRef node = JSInternalStringCreateUTF8("Node");
    47     JSObjectSetProperty(context, globalObject, node, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);
    48     JSInternalStringRelease(node);
     46    JSStringRef node = JSStringCreateWithUTF8CString("Node");
     47    JSObjectSetProperty(context, globalObject, node, JSObjectMakeConstructor(context, JSNode_construct), kJSPropertyAttributeNone);
     48    JSStringRelease(node);
    4949   
    5050    char* scriptUTF8 = createStringWithContentsOfFile("minidom.js");
    51     JSInternalStringRef script = JSInternalStringCreateUTF8(scriptUTF8);
     51    JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8);
    5252    JSValueRef exception;
    5353    JSValueRef result = JSEvaluate(context, script, NULL, NULL, 0, &exception);
     
    5656    else {
    5757        printf("FAIL: Test script threw exception:\n");
    58         JSInternalStringRef exceptionIString = JSValueCopyStringValue(context, exception);
    59         CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionIString);
     58        JSStringRef exceptionIString = JSValueToStringCopy(context, exception);
     59        CFStringRef exceptionCF = JSStringCopyCFString(kCFAllocatorDefault, exceptionIString);
    6060        CFShow(exceptionCF);
    6161        CFRelease(exceptionCF);
    62         JSInternalStringRelease(exceptionIString);
     62        JSStringRelease(exceptionIString);
    6363    }
    64     JSInternalStringRelease(script);
     64    JSStringRelease(script);
    6565    free(scriptUTF8);
    6666
     
    7171        (void)o;
    7272    }
    73     JSGCCollect();
     73    JSGarbageCollect();
    7474#endif
    7575   
     
    8282{
    8383    if (argc > 0) {
    84         JSInternalStringRef string = JSValueCopyStringValue(context, argv[0]);
    85         size_t numChars = JSInternalStringGetMaxLengthUTF8(string);
     84        JSStringRef string = JSValueToStringCopy(context, argv[0]);
     85        size_t numChars = JSStringGetMaximumUTF8CStringSize(string);
    8686        char stringUTF8[numChars];
    87         JSInternalStringGetCharactersUTF8(string, stringUTF8, numChars);
     87        JSStringGetUTF8CString(string, stringUTF8, numChars);
    8888        printf("%s\n", stringUTF8);
    8989    }
    9090   
    91     return JSUndefinedMake();
     91    return JSValueMakeUndefined();
    9292}
    9393
Note: See TracChangeset for help on using the changeset viewer.