Changeset 15224 in webkit for trunk/JavaScriptCore/API/testapi.c
- Timestamp:
- Jul 7, 2006, 7:02:47 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/testapi.c
r15213 r15224 130 130 } 131 131 132 static bool MyObject_hasProperty(JSObjectRef object, JSStringBufferRef propertyName) 133 { 132 static bool MyObject_hasProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName) 133 { 134 UNUSED_PARAM(context); 134 135 UNUSED_PARAM(object); 135 136 … … 166 167 } 167 168 168 static bool MyObject_setProperty(JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value) 169 { 169 static bool MyObject_setProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName, JSValueRef value) 170 { 171 UNUSED_PARAM(context); 170 172 UNUSED_PARAM(object); 171 173 UNUSED_PARAM(value); … … 177 179 } 178 180 179 static bool MyObject_deleteProperty(JSObjectRef object, JSStringBufferRef propertyName) 180 { 181 static bool MyObject_deleteProperty(JSContextRef context, JSObjectRef object, JSStringBufferRef propertyName) 182 { 183 UNUSED_PARAM(context); 181 184 UNUSED_PARAM(object); 182 185 … … 187 190 } 188 191 189 static void MyObject_getPropertyList(JSObjectRef object, JSPropertyListRef propertyList) 190 { 192 static void MyObject_getPropertyList(JSContextRef context, JSObjectRef object, JSPropertyListRef propertyList) 193 { 194 UNUSED_PARAM(context); 195 191 196 JSStringBufferRef propertyNameBuf; 192 197 … … 223 228 } 224 229 225 static bool MyObject_convertToType(JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue) 226 { 230 static bool MyObject_convertToType(JSContextRef context, JSObjectRef object, JSTypeCode typeCode, JSValueRef* returnValue) 231 { 232 UNUSED_PARAM(context); 227 233 UNUSED_PARAM(object); 228 234 … … 268 274 static JSClassRef jsClass; 269 275 if (!jsClass) { 270 jsClass = JSClassCreate( context,NULL, NULL, &MyObject_callbacks, NULL);276 jsClass = JSClassCreate(NULL, NULL, &MyObject_callbacks, NULL); 271 277 } 272 278 … … 312 318 UNUSED_PARAM(argv); 313 319 314 context = JSContextCreate(NULL , NULL);320 context = JSContextCreate(NULL); 315 321 316 322 JSValueRef jsUndefined = JSUndefinedMake(); … … 339 345 kCFAllocatorNull); 340 346 341 JSStringBufferRef jsCFStringBuf = JSStringBufferCreate WithCFString(cfString);347 JSStringBufferRef jsCFStringBuf = JSStringBufferCreateCF(cfString); 342 348 JSValueRef jsCFString = JSStringMake(jsCFStringBuf); 343 349 344 350 CFStringRef cfEmptyString = CFStringCreateWithCString(kCFAllocatorDefault, "", kCFStringEncodingUTF8); 345 351 346 JSStringBufferRef jsCFEmptyStringBuf = JSStringBufferCreate WithCFString(cfEmptyString);352 JSStringBufferRef jsCFEmptyStringBuf = JSStringBufferCreateCF(cfEmptyString); 347 353 JSValueRef jsCFEmptyString = JSStringMake(jsCFEmptyStringBuf); 348 354 … … 500 506 JSValueRef result; 501 507 JSValueRef exception; 508 JSValueRef v; 509 JSObjectRef o; 502 510 503 511 result = JSEvaluate(context, goodSyntaxBuf, NULL, NULL, 1, NULL); 504 512 assert(result); 505 513 assert(JSValueIsEqual(context, result, jsOne)); 506 514 515 exception = NULL; 507 516 result = JSEvaluate(context, badSyntaxBuf, NULL, NULL, 1, &exception); 508 517 assert(!result); … … 527 536 JSStringBufferRelease(badSyntaxBuf); 528 537 538 v = NULL; 529 539 JSStringBufferRef arrayBuf = JSStringBufferCreateUTF8("Array"); 530 JSValueRef v;531 540 assert(JSObjectGetProperty(context, globalObject, arrayBuf, &v)); 532 541 JSObjectRef arrayConstructor = JSValueToObject(context, v); … … 539 548 JSStringBufferRef functionBuf; 540 549 550 v = NULL; 551 exception = NULL; 541 552 functionBuf = JSStringBufferCreateUTF8("rreturn Array;"); 542 assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1)); 553 JSStringBufferRef lineBuf = JSStringBufferCreateUTF8("line"); 554 assert(!JSFunctionMakeWithBody(context, functionBuf, NULL, 1, &exception)); 555 assert(JSValueIsObject(exception)); 556 assert(JSObjectGetProperty(context, exception, lineBuf, &v)); 557 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) 543 558 JSStringBufferRelease(functionBuf); 559 JSStringBufferRelease(lineBuf); 544 560 545 561 functionBuf = JSStringBufferCreateUTF8("return Array;"); 546 JSObjectRef function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1 );562 JSObjectRef function = JSFunctionMakeWithBody(context, functionBuf, NULL, 1, NULL); 547 563 JSStringBufferRelease(functionBuf); 548 564 … … 558 574 559 575 JSStringBufferRef printBuf = JSStringBufferCreateUTF8("print"); 560 JSObjectSetProperty(context, globalObject, printBuf, JSFunctionMake(context, print_callAsFunction), kJSPropertyAttributeNone); 576 JSValueRef printFunction = JSFunctionMake(context, print_callAsFunction); 577 JSObjectSetProperty(context, globalObject, printBuf, printFunction, kJSPropertyAttributeNone); 561 578 JSStringBufferRelease(printBuf); 579 580 assert(JSObjectSetPrivate(printFunction, (void*)1)); 581 assert(JSObjectGetPrivate(printFunction) == (void*)1); 562 582 563 583 JSStringBufferRef myConstructorBuf = JSStringBufferCreateUTF8("MyConstructor"); 564 JSObjectSetProperty(context, globalObject, myConstructorBuf, JSConstructorMake(context, myConstructor_callAsConstructor), kJSPropertyAttributeNone); 584 JSValueRef myConstructor = JSConstructorMake(context, myConstructor_callAsConstructor); 585 JSObjectSetProperty(context, globalObject, myConstructorBuf, myConstructor, kJSPropertyAttributeNone); 565 586 JSStringBufferRelease(myConstructorBuf); 566 567 JSClassRef nullCallbacksClass = JSClassCreate(context, NULL, NULL, NULL, NULL); 587 588 assert(JSObjectSetPrivate(myConstructor, (void*)1)); 589 assert(JSObjectGetPrivate(myConstructor) == (void*)1); 590 591 o = JSObjectMake(context, NULL, NULL); 592 JSObjectSetProperty(context, o, jsOneString, JSNumberMake(1), kJSPropertyAttributeNone); 593 JSObjectSetProperty(context, o, jsCFString, JSNumberMake(1), kJSPropertyAttributeDontEnum); 594 JSPropertyEnumeratorRef enumerator = JSObjectCreatePropertyEnumerator(context, o); 595 int count = 0; 596 while (JSPropertyEnumeratorGetNext(context, enumerator)) 597 ++count; 598 JSPropertyEnumeratorRelease(enumerator); 599 assert(count == 1); // jsCFString should not be enumerated 600 601 JSClassRef nullCallbacksClass = JSClassCreate(NULL, NULL, NULL, NULL); 568 602 JSClassRelease(nullCallbacksClass); 569 603
Note:
See TracChangeset
for help on using the changeset viewer.