Changeset 1391 for branches/GNU/src/gcc/libobjc/class.c
- Timestamp:
- Apr 27, 2004, 8:39:34 PM (21 years ago)
- Location:
- branches/GNU/src/gcc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gcc
- Property svn:ignore
-
old new 26 26 configure.vr 27 27 configure.vrs 28 dir.info 28 29 Makefile 29 dir.info30 30 lost+found 31 31 update.out
-
- Property svn:ignore
-
branches/GNU/src/gcc/libobjc/class.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* GNU Objective C Runtime class related functions 2 Copyright (C) 1993, 1995, 1996, 1997, 2001 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002 3 Free Software Foundation, Inc. 3 4 Contributed by Kresten Krab Thorup and Dennis Glatting. 4 5 … … 164 165 /* Setup the table. */ 165 166 static void 166 class_table_setup ( )167 class_table_setup (void) 167 168 { 168 169 /* Start - nothing in the table. */ 169 memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE);170 memset (class_table_array, 0, sizeof (class_node_ptr) * CLASS_TABLE_SIZE); 170 171 171 172 /* The table writing mutex. */ … … 340 341 /* Debugging function - print the class table. */ 341 342 void 342 class_table_print ( )343 class_table_print (void) 343 344 { 344 345 int i; … … 363 364 in real cases. */ 364 365 void 365 class_table_print_histogram ( )366 class_table_print_histogram (void) 366 367 { 367 368 int i, j; … … 409 410 objc_lookup_class if the runtime is not able to find the class. 410 411 This may e.g. try to load in the class using dynamic loading. */ 411 Class (*_objc_lookup_class) (const char*name) = 0; /* !T:SAFE */412 Class (*_objc_lookup_class) (const char *name) = 0; /* !T:SAFE */ 412 413 413 414 … … 416 417 417 418 418 void __objc_init_class_tables() 419 void 420 __objc_init_class_tables (void) 419 421 { 420 422 /* Allocate the class hash table. */ 421 423 422 if (__class_table_lock)424 if (__class_table_lock) 423 425 return; 424 426 425 objc_mutex_lock (__objc_runtime_mutex);427 objc_mutex_lock (__objc_runtime_mutex); 426 428 427 429 class_table_setup (); 428 430 429 objc_mutex_unlock (__objc_runtime_mutex);431 objc_mutex_unlock (__objc_runtime_mutex); 430 432 } 431 433 … … 433 435 class a number, unless it's already known. */ 434 436 void 435 __objc_add_class_to_hash (Class class)437 __objc_add_class_to_hash (Class class) 436 438 { 437 439 Class h_class; 438 440 439 objc_mutex_lock (__objc_runtime_mutex);441 objc_mutex_lock (__objc_runtime_mutex); 440 442 441 443 /* Make sure the table is there. */ 442 assert (__class_table_lock);444 assert (__class_table_lock); 443 445 444 446 /* Make sure it's not a meta class. */ 445 assert (CLS_ISCLASS(class));447 assert (CLS_ISCLASS (class)); 446 448 447 449 /* Check to see if the class is already in the hash table. */ 448 450 h_class = class_table_get_safe (class->name); 449 if (! h_class)451 if (! h_class) 450 452 { 451 453 /* The class isn't in the hash table. Add the class and assign a class … … 453 455 static unsigned int class_number = 1; 454 456 455 CLS_SETNUMBER (class, class_number);456 CLS_SETNUMBER (class->class_pointer, class_number);457 CLS_SETNUMBER (class, class_number); 458 CLS_SETNUMBER (class->class_pointer, class_number); 457 459 458 460 ++class_number; … … 460 462 } 461 463 462 objc_mutex_unlock (__objc_runtime_mutex);464 objc_mutex_unlock (__objc_runtime_mutex); 463 465 } 464 466 … … 466 468 identify a known class, the hook _objc_lookup_class is called. If 467 469 this fails, nil is returned. */ 468 Class objc_lookup_class (const char* name) 470 Class 471 objc_lookup_class (const char *name) 469 472 { 470 473 Class class; … … 476 479 477 480 if (_objc_lookup_class) 478 return (*_objc_lookup_class) (name);481 return (*_objc_lookup_class) (name); 479 482 else 480 483 return 0; … … 495 498 496 499 if (_objc_lookup_class) 497 class = (*_objc_lookup_class) (name);498 499 if (class)500 class = (*_objc_lookup_class) (name); 501 502 if (class) 500 503 return class; 501 504 502 objc_error (nil, OBJC_ERR_BAD_CLASS,503 "objc runtime: cannot find class %s\n", name);505 objc_error (nil, OBJC_ERR_BAD_CLASS, 506 "objc runtime: cannot find class %s\n", name); 504 507 return 0; 505 508 } 506 509 507 510 MetaClass 508 objc_get_meta_class (const char *name)509 { 510 return objc_get_class (name)->class_pointer;511 objc_get_meta_class (const char *name) 512 { 513 return objc_get_class (name)->class_pointer; 511 514 } 512 515 … … 517 520 id class; 518 521 void *es = NULL; 519 while ((class = objc_next_class (&es)))522 while ((class = objc_next_class (&es))) 520 523 ... do something with class; 521 524 */ 522 525 Class 523 objc_next_class (void **enum_state)526 objc_next_class (void **enum_state) 524 527 { 525 528 Class class; 526 529 527 objc_mutex_lock (__objc_runtime_mutex);530 objc_mutex_lock (__objc_runtime_mutex); 528 531 529 532 /* Make sure the table is there. */ 530 assert (__class_table_lock);531 532 class = class_table_next ((struct class_table_enumerator **) enum_state);533 534 objc_mutex_unlock (__objc_runtime_mutex);533 assert (__class_table_lock); 534 535 class = class_table_next ((struct class_table_enumerator **) enum_state); 536 537 objc_mutex_unlock (__objc_runtime_mutex); 535 538 536 539 return class; … … 540 543 can be sure of is that the class_pointer for class objects point to 541 544 the right meta class objects. */ 542 void __objc_resolve_class_links() 545 void 546 __objc_resolve_class_links (void) 543 547 { 544 548 struct class_table_enumerator *es = NULL; … … 546 550 Class class1; 547 551 548 assert (object_class);549 550 objc_mutex_lock (__objc_runtime_mutex);552 assert (object_class); 553 554 objc_mutex_lock (__objc_runtime_mutex); 551 555 552 556 /* Assign subclass links. */ … … 554 558 { 555 559 /* Make sure we have what we think we have. */ 556 assert (CLS_ISCLASS (class1));557 assert (CLS_ISMETA (class1->class_pointer));560 assert (CLS_ISCLASS (class1)); 561 assert (CLS_ISMETA (class1->class_pointer)); 558 562 559 563 /* The class_pointer of all meta classes point to Object's meta … … 561 565 class1->class_pointer->class_pointer = object_class->class_pointer; 562 566 563 if (! (CLS_ISRESOLV(class1)))564 { 565 CLS_SETRESOLV (class1);566 CLS_SETRESOLV (class1->class_pointer);567 if (! CLS_ISRESOLV (class1)) 568 { 569 CLS_SETRESOLV (class1); 570 CLS_SETRESOLV (class1->class_pointer); 567 571 568 if (class1->super_class)572 if (class1->super_class) 569 573 { 570 574 Class a_super_class … … 608 612 { 609 613 sub_class->super_class = class1; 610 if (CLS_ISCLASS(sub_class))614 if (CLS_ISCLASS (sub_class)) 611 615 sub_class->class_pointer->super_class = class1->class_pointer; 612 616 } 613 617 } 614 618 615 objc_mutex_unlock (__objc_runtime_mutex);619 objc_mutex_unlock (__objc_runtime_mutex); 616 620 } 617 621 … … 623 627 class_pose_as (Class impostor, Class super_class) 624 628 { 625 if (! CLS_ISRESOLV (impostor))629 if (! CLS_ISRESOLV (impostor)) 626 630 __objc_resolve_class_links (); 627 631 … … 686 690 into impostor. */ 687 691 688 objc_mutex_lock (__objc_runtime_mutex);692 objc_mutex_lock (__objc_runtime_mutex); 689 693 690 694 class_table_replace (super_class, impostor); 691 695 692 objc_mutex_unlock (__objc_runtime_mutex);696 objc_mutex_unlock (__objc_runtime_mutex); 693 697 694 698 /* Next, we update the dispatch tables... */ -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.