Changeset 15328 in webkit for trunk/JavaScriptCore/API/minidom.c


Ignore:
Timestamp:
Jul 10, 2006, 10:37:00 PM (19 years ago)
Author:
ggaren
Message:

Reviewed by Darin.


  • Changed public header includes to the <JavaScriptCore/ style.
  • Changed instances of 'buffer' to 'string' since we decided on JSInternalString instead of JSStringBuffer.
  • API/JSContextRef.h:
  • API/JSInternalStringRef.cpp: (JSStringMake): (JSInternalStringRetain): (JSInternalStringRelease): (JSValueCopyStringValue): (JSInternalStringGetLength): (JSInternalStringGetCharactersPtr): (JSInternalStringGetCharacters): (JSInternalStringGetMaxLengthUTF8): (JSInternalStringGetCharactersUTF8): (CFStringCreateWithJSInternalString):
  • API/JSInternalStringRef.h:
  • API/JSNode.c: (JSNodePrototype_appendChild): (JSNode_getNodeType):
  • API/JSObjectRef.cpp: (JSObjectCallAsConstructor):
  • API/JSValueRef.h:
  • API/JavaScriptCore.h:
  • API/minidom.c: (main): (print):
  • API/testapi.c: (MyObject_getPropertyList): (myConstructor_callAsConstructor): (main): I noticed that we were prematurely releasing some string buffers, so I moved their release calls to the end of main(). I got rid of 'Buf' in *Buf (sometimes changing to 'IString', when necessary to differentiate a variable) to match the buffer->string change.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/minidom.c

    r15317 r15328  
    4040    JSObjectRef globalObject = JSContextGetGlobalObject(context);
    4141   
    42     JSInternalStringRef printBuf = JSInternalStringCreateUTF8("print");
    43     JSObjectSetProperty(context, globalObject, printBuf, JSFunctionMake(context, print), kJSPropertyAttributeNone);
    44     JSInternalStringRelease(printBuf);
     42    JSInternalStringRef printIString = JSInternalStringCreateUTF8("print");
     43    JSObjectSetProperty(context, globalObject, printIString, JSFunctionMake(context, print), kJSPropertyAttributeNone);
     44    JSInternalStringRelease(printIString);
    4545   
    46     JSInternalStringRef nodeBuf = JSInternalStringCreateUTF8("Node");
    47     JSObjectSetProperty(context, globalObject, nodeBuf, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);
    48     JSInternalStringRelease(nodeBuf);
     46    JSInternalStringRef node = JSInternalStringCreateUTF8("Node");
     47    JSObjectSetProperty(context, globalObject, node, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);
     48    JSInternalStringRelease(node);
    4949   
    50     char* script = createStringWithContentsOfFile("minidom.js");
    51     JSInternalStringRef scriptBuf = JSInternalStringCreateUTF8(script);
     50    char* scriptUTF8 = createStringWithContentsOfFile("minidom.js");
     51    JSInternalStringRef script = JSInternalStringCreateUTF8(scriptUTF8);
    5252    JSValueRef exception;
    53     JSValueRef result = JSEvaluate(context, scriptBuf, NULL, NULL, 0, &exception);
     53    JSValueRef result = JSEvaluate(context, script, NULL, NULL, 0, &exception);
    5454    if (result)
    5555        printf("PASS: Test script executed successfully.\n");
    5656    else {
    5757        printf("FAIL: Test script threw exception:\n");
    58         JSInternalStringRef exceptionBuf = JSValueCopyStringValue(context, exception);
    59         CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionBuf);
     58        JSInternalStringRef exceptionIString = JSValueCopyStringValue(context, exception);
     59        CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionIString);
    6060        CFShow(exceptionCF);
    6161        CFRelease(exceptionCF);
    62         JSInternalStringRelease(exceptionBuf);
     62        JSInternalStringRelease(exceptionIString);
    6363    }
    64     JSInternalStringRelease(scriptBuf);
    65     free(script);
     64    JSInternalStringRelease(script);
     65    free(scriptUTF8);
    6666
    6767#if 0 // used for leak/finalize debugging   
     
    8282{
    8383    if (argc > 0) {
    84         JSInternalStringRef stringBuf = JSValueCopyStringValue(context, argv[0]);
    85         size_t numChars = JSInternalStringGetMaxLengthUTF8(stringBuf);
    86         char string[numChars];
    87         JSInternalStringGetCharactersUTF8(stringBuf, string, numChars);
    88         printf("%s\n", string);
     84        JSInternalStringRef string = JSValueCopyStringValue(context, argv[0]);
     85        size_t numChars = JSInternalStringGetMaxLengthUTF8(string);
     86        char stringUTF8[numChars];
     87        JSInternalStringGetCharactersUTF8(string, stringUTF8, numChars);
     88        printf("%s\n", stringUTF8);
    8989    }
    9090   
Note: See TracChangeset for help on using the changeset viewer.