Changeset 15328 in webkit for trunk/JavaScriptCore/API/minidom.c
- Timestamp:
- Jul 10, 2006, 10:37:00 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/minidom.c
r15317 r15328 40 40 JSObjectRef globalObject = JSContextGetGlobalObject(context); 41 41 42 JSInternalStringRef print Buf= JSInternalStringCreateUTF8("print");43 JSObjectSetProperty(context, globalObject, print Buf, JSFunctionMake(context, print), kJSPropertyAttributeNone);44 JSInternalStringRelease(print Buf);42 JSInternalStringRef printIString = JSInternalStringCreateUTF8("print"); 43 JSObjectSetProperty(context, globalObject, printIString, JSFunctionMake(context, print), kJSPropertyAttributeNone); 44 JSInternalStringRelease(printIString); 45 45 46 JSInternalStringRef node Buf= JSInternalStringCreateUTF8("Node");47 JSObjectSetProperty(context, globalObject, node Buf, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone);48 JSInternalStringRelease(node Buf);46 JSInternalStringRef node = JSInternalStringCreateUTF8("Node"); 47 JSObjectSetProperty(context, globalObject, node, JSConstructorMake(context, JSNode_construct), kJSPropertyAttributeNone); 48 JSInternalStringRelease(node); 49 49 50 char* script = createStringWithContentsOfFile("minidom.js");51 JSInternalStringRef script Buf = JSInternalStringCreateUTF8(script);50 char* scriptUTF8 = createStringWithContentsOfFile("minidom.js"); 51 JSInternalStringRef script = JSInternalStringCreateUTF8(scriptUTF8); 52 52 JSValueRef exception; 53 JSValueRef result = JSEvaluate(context, script Buf, NULL, NULL, 0, &exception);53 JSValueRef result = JSEvaluate(context, script, NULL, NULL, 0, &exception); 54 54 if (result) 55 55 printf("PASS: Test script executed successfully.\n"); 56 56 else { 57 57 printf("FAIL: Test script threw exception:\n"); 58 JSInternalStringRef exception Buf= JSValueCopyStringValue(context, exception);59 CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exception Buf);58 JSInternalStringRef exceptionIString = JSValueCopyStringValue(context, exception); 59 CFStringRef exceptionCF = CFStringCreateWithJSInternalString(kCFAllocatorDefault, exceptionIString); 60 60 CFShow(exceptionCF); 61 61 CFRelease(exceptionCF); 62 JSInternalStringRelease(exception Buf);62 JSInternalStringRelease(exceptionIString); 63 63 } 64 JSInternalStringRelease(script Buf);65 free(script );64 JSInternalStringRelease(script); 65 free(scriptUTF8); 66 66 67 67 #if 0 // used for leak/finalize debugging … … 82 82 { 83 83 if (argc > 0) { 84 JSInternalStringRef string Buf= JSValueCopyStringValue(context, argv[0]);85 size_t numChars = JSInternalStringGetMaxLengthUTF8(string Buf);86 char string [numChars];87 JSInternalStringGetCharactersUTF8(string Buf, 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); 89 89 } 90 90
Note:
See TracChangeset
for help on using the changeset viewer.