Changeset 15481 in webkit for trunk/JavaScriptCore/API/testapi.c
- Timestamp:
- Jul 17, 2006, 1:14:39 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/testapi.c
r15480 r15481 130 130 131 131 if (JSStringIsEqualToUTF8CString(propertyName, "alwaysOne")) { 132 return JSValueMakeNumber( 1);132 return JSValueMakeNumber(context, 1); 133 133 } 134 134 135 135 if (JSStringIsEqualToUTF8CString(propertyName, "myPropertyName")) { 136 return JSValueMakeNumber( 1);136 return JSValueMakeNumber(context, 1); 137 137 } 138 138 139 139 if (JSStringIsEqualToUTF8CString(propertyName, "cantFind")) { 140 return JSValueMakeUndefined( );140 return JSValueMakeUndefined(context); 141 141 } 142 142 143 143 if (JSStringIsEqualToUTF8CString(propertyName, "0")) { 144 *exception = JSValueMakeNumber( 1);145 return JSValueMakeNumber( 1);144 *exception = JSValueMakeNumber(context, 1); 145 return JSValueMakeNumber(context, 1); 146 146 } 147 147 … … 170 170 171 171 if (JSStringIsEqualToUTF8CString(propertyName, "throwOnDelete")) { 172 *exception = JSValueMakeNumber( 2);172 *exception = JSValueMakeNumber(context, 2); 173 173 return false; 174 174 } … … 198 198 UNUSED_PARAM(thisObject); 199 199 200 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber( 0)))201 return JSValueMakeNumber( 1);202 203 return JSValueMakeUndefined( );200 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0))) 201 return JSValueMakeNumber(context, 1); 202 203 return JSValueMakeUndefined(context); 204 204 } 205 205 … … 209 209 UNUSED_PARAM(object); 210 210 211 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber( 0)))212 return JSValueToObject(context, JSValueMakeNumber( 1), NULL);213 214 return JSValueToObject(context, JSValueMakeNumber( 0), NULL);211 if (argumentCount > 0 && JSValueIsStrictEqual(context, arguments[0], JSValueMakeNumber(context, 0))) 212 return JSValueToObject(context, JSValueMakeNumber(context, 1), NULL); 213 214 return JSValueToObject(context, JSValueMakeNumber(context, 0), NULL); 215 215 } 216 216 … … 233 233 switch (type) { 234 234 case kJSTypeNumber: 235 return JSValueMakeNumber( 1);235 return JSValueMakeNumber(context, 1); 236 236 default: 237 237 break; … … 305 305 } 306 306 307 return JSValueMakeUndefined( );307 return JSValueMakeUndefined(context); 308 308 } 309 309 … … 332 332 333 333 JSObjectRef globalObject = JSContextGetGlobalObject(context); 334 assert(JSValueIsObject( globalObject));335 336 JSValueRef jsUndefined = JSValueMakeUndefined( );337 JSValueRef jsNull = JSValueMakeNull( );338 JSValueRef jsTrue = JSValueMakeBoolean( true);339 JSValueRef jsFalse = JSValueMakeBoolean( false);340 JSValueRef jsZero = JSValueMakeNumber( 0);341 JSValueRef jsOne = JSValueMakeNumber( 1);342 JSValueRef jsOneThird = JSValueMakeNumber( 1.0 / 3.0);343 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull( ));334 assert(JSValueIsObject(context, globalObject)); 335 336 JSValueRef jsUndefined = JSValueMakeUndefined(context); 337 JSValueRef jsNull = JSValueMakeNull(context); 338 JSValueRef jsTrue = JSValueMakeBoolean(context, true); 339 JSValueRef jsFalse = JSValueMakeBoolean(context, false); 340 JSValueRef jsZero = JSValueMakeNumber(context, 0); 341 JSValueRef jsOne = JSValueMakeNumber(context, 1); 342 JSValueRef jsOneThird = JSValueMakeNumber(context, 1.0 / 3.0); 343 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull(context)); 344 344 345 345 // FIXME: test funny utf8 characters 346 346 JSStringRef jsEmptyIString = JSStringCreateWithUTF8CString(""); 347 JSValueRef jsEmptyString = JSValueMakeString( jsEmptyIString);347 JSValueRef jsEmptyString = JSValueMakeString(context, jsEmptyIString); 348 348 349 349 JSStringRef jsOneIString = JSStringCreateWithUTF8CString("1"); 350 JSValueRef jsOneString = JSValueMakeString( jsOneIString);350 JSValueRef jsOneString = JSValueMakeString(context, jsOneIString); 351 351 352 352 #if defined(__APPLE__) … … 360 360 361 361 JSStringRef jsCFIString = JSStringCreateWithCFString(cfString); 362 JSValueRef jsCFString = JSValueMakeString( jsCFIString);362 JSValueRef jsCFString = JSValueMakeString(context, jsCFIString); 363 363 364 364 CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8); 365 365 366 366 JSStringRef jsCFEmptyIString = JSStringCreateWithCFString(cfEmptyString); 367 JSValueRef jsCFEmptyString = JSValueMakeString( jsCFEmptyIString);367 JSValueRef jsCFEmptyString = JSValueMakeString(context, jsCFEmptyIString); 368 368 369 369 CFIndex cfStringLength = CFStringGetLength(cfString); … … 373 373 buffer); 374 374 JSStringRef jsCFIStringWithCharacters = JSStringCreateWithCharacters(buffer, cfStringLength); 375 JSValueRef jsCFStringWithCharacters = JSValueMakeString( jsCFIStringWithCharacters);375 JSValueRef jsCFStringWithCharacters = JSValueMakeString(context, jsCFIStringWithCharacters); 376 376 377 377 JSStringRef jsCFEmptyIStringWithCharacters = JSStringCreateWithCharacters(buffer, CFStringGetLength(cfEmptyString)); 378 JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString( jsCFEmptyIStringWithCharacters);379 #endif // __APPLE__ 380 381 assert(JSValueGetType( jsUndefined) == kJSTypeUndefined);382 assert(JSValueGetType( jsNull) == kJSTypeNull);383 assert(JSValueGetType( jsTrue) == kJSTypeBoolean);384 assert(JSValueGetType( jsFalse) == kJSTypeBoolean);385 assert(JSValueGetType( jsZero) == kJSTypeNumber);386 assert(JSValueGetType( jsOne) == kJSTypeNumber);387 assert(JSValueGetType( jsOneThird) == kJSTypeNumber);388 assert(JSValueGetType( jsEmptyString) == kJSTypeString);389 assert(JSValueGetType( jsOneString) == kJSTypeString);390 #if defined(__APPLE__) 391 assert(JSValueGetType( jsCFString) == kJSTypeString);392 assert(JSValueGetType( jsCFStringWithCharacters) == kJSTypeString);393 assert(JSValueGetType( jsCFEmptyString) == kJSTypeString);394 assert(JSValueGetType( jsCFEmptyStringWithCharacters) == kJSTypeString);378 JSValueRef jsCFEmptyStringWithCharacters = JSValueMakeString(context, jsCFEmptyIStringWithCharacters); 379 #endif // __APPLE__ 380 381 assert(JSValueGetType(context, jsUndefined) == kJSTypeUndefined); 382 assert(JSValueGetType(context, jsNull) == kJSTypeNull); 383 assert(JSValueGetType(context, jsTrue) == kJSTypeBoolean); 384 assert(JSValueGetType(context, jsFalse) == kJSTypeBoolean); 385 assert(JSValueGetType(context, jsZero) == kJSTypeNumber); 386 assert(JSValueGetType(context, jsOne) == kJSTypeNumber); 387 assert(JSValueGetType(context, jsOneThird) == kJSTypeNumber); 388 assert(JSValueGetType(context, jsEmptyString) == kJSTypeString); 389 assert(JSValueGetType(context, jsOneString) == kJSTypeString); 390 #if defined(__APPLE__) 391 assert(JSValueGetType(context, jsCFString) == kJSTypeString); 392 assert(JSValueGetType(context, jsCFStringWithCharacters) == kJSTypeString); 393 assert(JSValueGetType(context, jsCFEmptyString) == kJSTypeString); 394 assert(JSValueGetType(context, jsCFEmptyStringWithCharacters) == kJSTypeString); 395 395 #endif // __APPLE__ 396 396 … … 419 419 420 420 exception = NULL; 421 assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber( 1), &exception));421 assert(!JSValueIsEqual(context, jsObjectNoProto, JSValueMakeNumber(context, 1), &exception)); 422 422 assert(exception); 423 423 … … 510 510 511 511 jsGlobalValue = JSObjectMake(context, NULL, NULL); 512 JSValueProtect( jsGlobalValue);513 JSGarbageCollect( );514 assert(JSValueIsObject( jsGlobalValue));515 JSValueUnprotect( jsGlobalValue);512 JSValueProtect(context, jsGlobalValue); 513 JSGarbageCollect(context); 514 assert(JSValueIsObject(context, jsGlobalValue)); 515 JSValueUnprotect(context, jsGlobalValue); 516 516 517 517 JSStringRef goodSyntax = JSStringCreateWithUTF8CString("x = 1;"); … … 532 532 result = JSEvaluateScript(context, badSyntax, NULL, NULL, 1, &exception); 533 533 assert(!result); 534 assert(JSValueIsObject( exception));534 assert(JSValueIsObject(context, exception)); 535 535 536 536 JSStringRef array = JSStringCreateWithUTF8CString("Array"); … … 539 539 result = JSObjectCallAsConstructor(context, arrayConstructor, 0, NULL, NULL); 540 540 assert(result); 541 assert(JSValueIsObject( result));541 assert(JSValueIsObject(context, result)); 542 542 assert(JSValueIsInstanceOfConstructor(context, result, arrayConstructor, NULL)); 543 assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull( ), arrayConstructor, NULL));543 assert(!JSValueIsInstanceOfConstructor(context, JSValueMakeNull(context), arrayConstructor, NULL)); 544 544 545 545 o = JSValueToObject(context, result, NULL); 546 546 exception = NULL; 547 assert(JSValueIsUndefined( JSObjectGetPropertyAtIndex(context, o, 0, &exception)));547 assert(JSValueIsUndefined(context, JSObjectGetPropertyAtIndex(context, o, 0, &exception))); 548 548 assert(!exception); 549 549 550 JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber( 1), &exception);550 JSObjectSetPropertyAtIndex(context, o, 0, JSValueMakeNumber(context, 1), &exception); 551 551 assert(!exception); 552 552 … … 562 562 JSStringRef line = JSStringCreateWithUTF8CString("line"); 563 563 assert(!JSObjectMakeFunction(context, NULL, 0, NULL, functionBody, NULL, 1, &exception)); 564 assert(JSValueIsObject( exception));564 assert(JSValueIsObject(context, exception)); 565 565 v = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), line, NULL); 566 566 assertEqualsAsNumber(v, 2); // FIXME: Lexer::setCode bumps startingLineNumber by 1 -- we need to change internal callers so that it doesn't have to (saying '0' to mean '1' in the API would be really confusing -- it's really confusing internally, in fact) … … 573 573 JSStringRelease(functionBody); 574 574 assert(!exception); 575 assert(JSObjectIsFunction( function));575 assert(JSObjectIsFunction(context, function)); 576 576 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, NULL); 577 577 assert(v); … … 583 583 v = JSObjectCallAsFunction(context, function, NULL, 0, NULL, &exception); 584 584 assert(v && !exception); 585 assert(JSValueIsUndefined( v));585 assert(JSValueIsUndefined(context, v)); 586 586 587 587 exception = NULL; … … 592 592 function = JSObjectMakeFunction(context, foo, 1, argumentNames, functionBody, NULL, 1, &exception); 593 593 assert(function && !exception); 594 JSValueRef arguments[] = { JSValueMakeNumber( 2) };594 JSValueRef arguments[] = { JSValueMakeNumber(context, 2) }; 595 595 v = JSObjectCallAsFunction(context, function, NULL, 1, arguments, &exception); 596 596 JSStringRelease(foo); … … 598 598 599 599 string = JSValueToStringCopy(context, function, NULL); 600 assertEqualsAsUTF8String(JSValueMakeString( string), "function foo(foo) \n{\n return foo;\n}");600 assertEqualsAsUTF8String(JSValueMakeString(context, string), "function foo(foo) \n{\n return foo;\n}"); 601 601 JSStringRelease(string); 602 602 … … 618 618 619 619 o = JSObjectMake(context, NULL, NULL); 620 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber( 1), kJSPropertyAttributeNone, NULL);621 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber( 1), kJSPropertyAttributeDontEnum, NULL);620 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeNone, NULL); 621 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeDontEnum, NULL); 622 622 JSPropertyNameArrayRef nameArray = JSObjectCopyPropertyNames(context, o); 623 623 size_t expectedCount = JSPropertyNameArrayGetCount(nameArray); … … 645 645 JSStringRef script = JSStringCreateWithUTF8CString(scriptUTF8); 646 646 result = JSEvaluateScript(context, script, NULL, NULL, 1, &exception); 647 if (JSValueIsUndefined( result))647 if (JSValueIsUndefined(context, result)) 648 648 printf("PASS: Test script executed successfully.\n"); 649 649 else { … … 661 661 JSObjectMake(context, MyObject_class(context), 0); 662 662 JSObjectMake(context, MyObject_class(context), 0); 663 JSGarbageCollect( );663 JSGarbageCollect(context); 664 664 assert(didFinalize); 665 665
Note:
See TracChangeset
for help on using the changeset viewer.