Changeset 15483 in webkit for trunk/JavaScriptCore/API/testapi.c
- Timestamp:
- Jul 17, 2006, 2:06:57 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/API/testapi.c
r15482 r15483 242 242 } 243 243 244 static bool didFinalize = false;244 static bool MyObject_didFinalize = false; 245 245 static void MyObject_finalize(JSObjectRef object) 246 246 { 247 247 UNUSED_PARAM(context); 248 248 UNUSED_PARAM(object); 249 didFinalize = true;249 MyObject_didFinalize = true; 250 250 } 251 251 … … 291 291 } 292 292 293 static void Base_initialize(JSContextRef context, JSObjectRef object, JSValueRef* exception) 294 { 295 assert(!JSObjectGetPrivate(object)); 296 JSObjectSetPrivate(object, (void*)1); 297 } 298 299 static bool Base_didFinalize; 300 static void Base_finalize(JSObjectRef object) 301 { 302 assert((void*)3 == JSObjectGetPrivate(object)); 303 Base_didFinalize = true; 304 } 305 306 static JSClassRef Base_class(JSContextRef context) 307 { 308 static JSClassRef jsClass; 309 if (!jsClass) { 310 JSClassDefinition definition = kJSClassDefinitionNull; 311 definition.initialize = Base_initialize; 312 definition.finalize = Base_finalize; 313 jsClass = JSClassCreate(&definition); 314 } 315 return jsClass; 316 } 317 318 static void Derived_initialize(JSContextRef context, JSObjectRef object, JSValueRef* exception) 319 { 320 assert((void*)1 == JSObjectGetPrivate(object)); 321 JSObjectSetPrivate(object, (void*)2); 322 } 323 324 static void Derived_finalize(JSObjectRef object) 325 { 326 assert((void*)2 == JSObjectGetPrivate(object)); 327 JSObjectSetPrivate(object, (void*)3); 328 } 329 330 static JSClassRef Derived_class(JSContextRef context) 331 { 332 static JSClassRef jsClass; 333 if (!jsClass) { 334 JSClassDefinition definition = kJSClassDefinitionNull; 335 definition.parentClass = Base_class(context); 336 definition.initialize = Derived_initialize; 337 definition.finalize = Derived_finalize; 338 jsClass = JSClassCreate(&definition); 339 } 340 return jsClass; 341 } 342 293 343 static JSValueRef print_callAsFunction(JSContextRef context, JSObjectRef functionObject, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 294 344 { … … 312 362 UNUSED_PARAM(constructorObject); 313 363 314 JSObjectRef result = JSObjectMake(context, NULL, 0 );364 JSObjectRef result = JSObjectMake(context, NULL, 0, NULL); 315 365 if (argumentCount > 0) { 316 366 JSStringRef value = JSStringCreateWithUTF8CString("value"); … … 341 391 JSValueRef jsOne = JSValueMakeNumber(context, 1); 342 392 JSValueRef jsOneThird = JSValueMakeNumber(context, 1.0 / 3.0); 343 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull(context) );393 JSObjectRef jsObjectNoProto = JSObjectMake(context, NULL, JSValueMakeNull(context), NULL); 344 394 345 395 // FIXME: test funny utf8 characters … … 395 445 #endif // __APPLE__ 396 446 397 JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL );447 JSObjectRef myObject = JSObjectMake(context, MyObject_class(context), NULL, NULL); 398 448 assert(didInitialize); 399 449 JSStringRef myObjectIString = JSStringCreateWithUTF8CString("MyObject"); … … 509 559 #endif // __APPLE__ 510 560 511 jsGlobalValue = JSObjectMake(context, NULL, NULL );561 jsGlobalValue = JSObjectMake(context, NULL, NULL, NULL); 512 562 JSValueProtect(context, jsGlobalValue); 513 563 JSGarbageCollect(context); … … 617 667 assert(!JSObjectGetPrivate(myConstructor)); 618 668 619 o = JSObjectMake(context, NULL, NULL );669 o = JSObjectMake(context, NULL, NULL, NULL); 620 670 JSObjectSetProperty(context, o, jsOneIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeNone, NULL); 621 671 JSObjectSetProperty(context, o, jsCFIString, JSValueMakeNumber(context, 1), kJSPropertyAttributeDontEnum, NULL); … … 640 690 assert(JSValueIsEqual(context, v, o, NULL)); 641 691 642 692 exception = NULL; 693 o = JSObjectMake(context, Derived_class(context), NULL, &exception); 694 assert(!exception); 695 assert(JSObjectGetPrivate(o) == (void*)2); 696 o = NULL; 643 697 644 698 char* scriptUTF8 = createStringWithContentsOfFile("testapi.js"); … … 659 713 660 714 // Allocate a few dummies so that at least one will be collected 661 JSObjectMake(context, MyObject_class(context), 0);662 JSObjectMake(context, MyObject_class(context), 0);715 JSObjectMake(context, MyObject_class(context), NULL, NULL); 716 JSObjectMake(context, MyObject_class(context), NULL, NULL); 663 717 JSGarbageCollect(context); 664 assert(didFinalize); 718 assert(MyObject_didFinalize); 719 assert(Base_didFinalize); 665 720 666 721 JSStringRelease(jsEmptyIString);
Note:
See TracChangeset
for help on using the changeset viewer.