Changeset 1391 for branches/GNU/src/gcc/libobjc/init.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/init.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.1.1.2
r1390 r1391 1 1 /* GNU Objective C Runtime initialization 2 Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.2 Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc. 3 3 Contributed by Kresten Krab Thorup 4 4 +load support contributed by Ovidiu Predescu <ovidiu@net-community.com> … … 28 28 29 29 /* The version number of this runtime. This must match the number 30 defined in gcc (objc-act.c) */30 defined in gcc (objc-act.c). */ 31 31 #define OBJC_VERSION 8 32 32 #define PROTOCOL_VERSION 2 33 33 34 /* This list contains all modules currently loaded into the runtime */35 static struct objc_list *__objc_module_list = 0; /* !T:MUTEX */36 37 /* This list contains all proto_list's not yet assigned class links */38 static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */34 /* This list contains all modules currently loaded into the runtime. */ 35 static struct objc_list *__objc_module_list = 0; /* !T:MUTEX */ 36 37 /* This list contains all proto_list's not yet assigned class links. */ 38 static struct objc_list *unclaimed_proto_list = 0; /* !T:MUTEX */ 39 39 40 40 /* List of unresolved static instances. */ 41 41 static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */ 42 42 43 /* Global runtime "write" mutex. */43 /* Global runtime "write" mutex. */ 44 44 objc_mutex_t __objc_runtime_mutex = 0; 45 45 46 /* Number of threads that are alive. */46 /* Number of threads that are alive. */ 47 47 int __objc_runtime_threads_alive = 1; /* !T:MUTEX */ 48 48 49 /* Check compiler vs runtime version */49 /* Check compiler vs runtime version. */ 50 50 static void init_check_module_version (Module_t); 51 51 52 /* Assign isa links to protos */53 static void __objc_init_protocols (struct objc_protocol_list *protos);54 55 /* Add protocol to class */56 static void __objc_class_add_protocols (Class, struct objc_protocol_list *);57 58 /* This is a hook which is called by __objc_exec_class every time a class59 or a category is loaded into the runtime. This may e.g. help a60 dynamic loader determine the classes that have been loaded when61 an object file is dynamically linked in */62 void (*_objc_load_callback) (Class class, Category*category); /* !T:SAFE */63 64 /* Is all categories/classes resolved? */52 /* Assign isa links to protos. */ 53 static void __objc_init_protocols (struct objc_protocol_list *protos); 54 55 /* Add protocol to class. */ 56 static void __objc_class_add_protocols (Class, struct objc_protocol_list *); 57 58 /* This is a hook which is called by __objc_exec_class every time a 59 class or a category is loaded into the runtime. This may e.g. help 60 a dynamic loader determine the classes that have been loaded when 61 an object file is dynamically linked in. */ 62 void (*_objc_load_callback) (Class class, Category *category); /* !T:SAFE */ 63 64 /* Is all categories/classes resolved? */ 65 65 BOOL __objc_dangling_categories = NO; /* !T:UNUSED */ 66 66 … … 69 69 struct objc_selector *orig, BOOL is_const); 70 70 71 /* Sends +load to all classes and categories in certain situations. */71 /* Sends +load to all classes and categories in certain situations. */ 72 72 static void objc_send_load (void); 73 73 74 74 /* Inserts all the classes defined in module in a tree of classes that 75 resembles the class hierarchy. This tree is traversed in preorder and the76 classes in its nodes receive the +load message if these methods were not77 executed before. The algorithm ensures that when the +load method of a class78 is executed all the superclasses have been already received the +load79 message.*/75 resembles the class hierarchy. This tree is traversed in preorder 76 and the classes in its nodes receive the +load message if these 77 methods were not executed before. The algorithm ensures that when 78 the +load method of a class is executed all the superclasses have 79 been already received the +load message. */ 80 80 static void __objc_create_classes_tree (Module_t module); 81 81 … … 83 83 84 84 /* A special version that works only before the classes are completely 85 installed in the runtime. */85 installed in the runtime. */ 86 86 static BOOL class_is_subclass_of_class (Class class, Class superclass); 87 87 … … 91 91 } objc_class_tree; 92 92 93 /* This is a linked list of objc_class_tree trees. The head of these trees94 are root classes (their super class is Nil). These different trees95 represent different class hierarchies.*/93 /* This is a linked list of objc_class_tree trees. The head of these 94 trees are root classes (their super class is Nil). These different 95 trees represent different class hierarchies. */ 96 96 static struct objc_list *__objc_class_tree_list = NULL; 97 97 98 /* Keeps the +load methods who have been already executed. This hash should99 not be destroyed during the execution of the program.*/98 /* Keeps the +load methods who have been already executed. This hash 99 should not be destroyed during the execution of the program. */ 100 100 static cache_ptr __objc_load_methods = NULL; 101 101 102 /* Creates a tree of classes whose topmost class is directly inherited from 103 `upper' and the bottom class in this tree is `bottom_class'. The classes 104 in this tree are super classes of `bottom_class'. `subclasses' member 105 of each tree node point to the next subclass tree node. */ 102 /* Creates a tree of classes whose topmost class is directly inherited 103 from `upper' and the bottom class in this tree is 104 `bottom_class'. The classes in this tree are super classes of 105 `bottom_class'. `subclasses' member of each tree node point to the 106 next subclass tree node. */ 107 106 108 static objc_class_tree * 107 109 create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper) 108 110 { 109 111 Class superclass = bottom_class->super_class ? 110 objc_lookup_class ((char *)bottom_class->super_class)112 objc_lookup_class ((char *) bottom_class->super_class) 111 113 : Nil; 112 114 … … 127 129 tree->subclasses = list_cons (prev, tree->subclasses); 128 130 superclass = (superclass->super_class ? 129 objc_lookup_class ((char *)superclass->super_class)131 objc_lookup_class ((char *) superclass->super_class) 130 132 : Nil); 131 133 prev = tree; … … 135 137 } 136 138 137 /* Insert the `class' into the proper place in the `tree' class hierarchy. This 138 function returns a new tree if the class has been successfully inserted into 139 the tree or NULL if the class is not part of the classes hierarchy described 140 by `tree'. This function is private to objc_tree_insert_class(), you should 141 not call it directly. */ 139 /* Insert the `class' into the proper place in the `tree' class 140 hierarchy. This function returns a new tree if the class has been 141 successfully inserted into the tree or NULL if the class is not 142 part of the classes hierarchy described by `tree'. This function is 143 private to objc_tree_insert_class (), you should not call it 144 directly. */ 145 142 146 static objc_class_tree * 143 147 __objc_tree_insert_class (objc_class_tree *tree, Class class) … … 155 159 } 156 160 else if ((class->super_class ? 157 objc_lookup_class ((char *)class->super_class)161 objc_lookup_class ((char *) class->super_class) 158 162 : Nil) 159 163 == tree->class) … … 161 165 /* If class is a direct subclass of tree->class then add class to the 162 166 list of subclasses. First check to see if it wasn't already 163 inserted. */167 inserted. */ 164 168 struct objc_list *list = tree->subclasses; 165 169 objc_class_tree *node; … … 168 172 { 169 173 /* Class has been already inserted; do nothing just return 170 the tree. */171 if (((objc_class_tree *)list->head)->class == class)174 the tree. */ 175 if (((objc_class_tree *) list->head)->class == class) 172 176 { 173 177 DEBUG_PRINTF ("2. class %s was previously inserted\n", … … 187 191 else 188 192 { 189 /* The class is not a direct subclass of tree->class. Search for class's190 superclasses in the list of subclasses.*/193 /* The class is not a direct subclass of tree->class. Search for 194 class's superclasses in the list of subclasses. */ 191 195 struct objc_list *subclasses = tree->subclasses; 192 196 193 /* Precondition: the class must be a subclass of tree->class; otherwise 194 return NULL to indicate our caller that it must take the next tree. */ 195 if (!class_is_subclass_of_class (class, tree->class)) 197 /* Precondition: the class must be a subclass of tree->class; 198 otherwise return NULL to indicate our caller that it must 199 take the next tree. */ 200 if (! class_is_subclass_of_class (class, tree->class)) 196 201 return NULL; 197 202 198 203 for (; subclasses != NULL; subclasses = subclasses->tail) 199 204 { 200 Class aClass = ((objc_class_tree *)(subclasses->head))->class;205 Class aClass = ((objc_class_tree *) (subclasses->head))->class; 201 206 202 207 if (class_is_subclass_of_class (class, aClass)) 203 208 { 204 /* If we found one of class's superclasses we insert the class205 into its subtree and return the original tree since nothing206 has been changed.*/209 /* If we found one of class's superclasses we insert the 210 class into its subtree and return the original tree 211 since nothing has been changed. */ 207 212 subclasses->head 208 213 = __objc_tree_insert_class (subclasses->head, class); … … 212 217 } 213 218 214 /* We haven't found a subclass of `class' in the `subclasses' list.215 Create a new tree of classes whose topmost class is a direct subclass216 of tree->class.*/219 /* We haven't found a subclass of `class' in the `subclasses' 220 list. Create a new tree of classes whose topmost class is a 221 direct subclass of tree->class. */ 217 222 { 218 223 objc_class_tree *new_tree 219 224 = create_tree_of_subclasses_inherited_from (class, tree->class); 220 225 tree->subclasses = list_cons (new_tree, tree->subclasses); 221 226 DEBUG_PRINTF ("5. class %s inserted\n", class->name); … … 225 230 } 226 231 227 /* This function inserts `class' in the right tree hierarchy classes. */ 232 /* This function inserts `class' in the right tree hierarchy classes. */ 233 228 234 static void 229 235 objc_tree_insert_class (Class class) … … 245 251 } 246 252 247 /* If the list was finished but the class hasn't been inserted, insert it248 here.*/249 if (! list_node)253 /* If the list was finished but the class hasn't been inserted, 254 insert it here. */ 255 if (! list_node) 250 256 { 251 257 __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); … … 254 260 } 255 261 256 /* Traverse tree in preorder. Used to send +load. */ 262 /* Traverse tree in preorder. Used to send +load. */ 263 257 264 static void 258 265 objc_preorder_traverse (objc_class_tree *tree, 259 266 int level, 260 void (*function) (objc_class_tree*, int))267 void (*function) (objc_class_tree *, int)) 261 268 { 262 269 struct objc_list *node; … … 267 274 } 268 275 269 /* Traverse tree in postorder. Used to destroy a tree. */ 276 /* Traverse tree in postorder. Used to destroy a tree. */ 277 270 278 static void 271 279 objc_postorder_traverse (objc_class_tree *tree, 272 int level,273 void (*function)(objc_class_tree*, int))280 int level, 281 void (*function) (objc_class_tree *, int)) 274 282 { 275 283 struct objc_list *node; … … 280 288 } 281 289 282 /* Used to print a tree class hierarchy. */ 290 /* Used to print a tree class hierarchy. */ 291 283 292 #ifdef DEBUG 284 293 static void … … 293 302 #endif 294 303 295 /* Walks on a linked list of methods in the reverse order and executes all 296 the methods corresponding to `op' selector. Walking in the reverse order 297 assures the +load of class is executed first and then +load of categories 298 because of the way in which categories are added to the class methods. */ 304 /* Walks on a linked list of methods in the reverse order and executes 305 all the methods corresponding to `op' selector. Walking in the 306 reverse order assures the +load of class is executed first and then 307 +load of categories because of the way in which categories are 308 added to the class methods. */ 309 299 310 static void 300 311 __objc_send_message_in_list (MethodList_t method_list, Class class, SEL op) … … 302 313 int i; 303 314 304 if (! method_list)315 if (! method_list) 305 316 return; 306 317 … … 308 319 __objc_send_message_in_list (method_list->method_next, class, op); 309 320 310 /* Search the method list. */321 /* Search the method list. */ 311 322 for (i = 0; i < method_list->method_count; i++) 312 323 { … … 314 325 315 326 if (mth->method_name && sel_eq (mth->method_name, op) 316 && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp))327 && ! hash_is_key_in_hash (__objc_load_methods, mth->method_imp)) 317 328 { 318 329 /* Add this method into the +load hash table */ … … 321 332 DEBUG_PRINTF ("sending +load in class: %s\n", class->name); 322 333 323 /* The method was found and wasn't previously executed. */334 /* The method was found and wasn't previously executed. */ 324 335 (*mth->method_imp) ((id)class, mth->method_name); 325 336 … … 330 341 331 342 static void 332 __objc_send_load (objc_class_tree *tree, int level) 343 __objc_send_load (objc_class_tree *tree, 344 int level __attribute__ ((__unused__))) 333 345 { 334 346 static SEL load_sel = 0; … … 336 348 MethodList_t method_list = class->class_pointer->methods; 337 349 338 if (! load_sel)350 if (! load_sel) 339 351 load_sel = sel_register_name ("load"); 340 352 … … 343 355 344 356 static void 345 __objc_destroy_class_tree_node (objc_class_tree *tree, int level) 357 __objc_destroy_class_tree_node (objc_class_tree *tree, 358 int level __attribute__ ((__unused__))) 346 359 { 347 360 objc_free (tree); 348 361 } 349 362 350 /* This is used to check if the relationship between two classes before the 351 runtime completely installs the classes. */ 363 /* This is used to check if the relationship between two classes 364 before the runtime completely installs the classes. */ 365 352 366 static BOOL 353 367 class_is_subclass_of_class (Class class, Class superclass) … … 358 372 return YES; 359 373 class = (class->super_class ? 360 objc_lookup_class ((char *)class->super_class)374 objc_lookup_class ((char *) class->super_class) 361 375 : Nil); 362 376 } … … 365 379 } 366 380 367 /* This list contains all the classes in the runtime system for whom their368 superclasses are not yet know to the runtime.*/369 static struct objc_list *unresolved_classes = 0;370 371 /* Extern function used to reference the Object and NXConstantString classes.372 */381 /* This list contains all the classes in the runtime system for whom 382 their superclasses are not yet known to the runtime. */ 383 static struct objc_list *unresolved_classes = 0; 384 385 /* Extern function used to reference the Object and NXConstantString 386 classes. */ 373 387 374 388 extern void __objc_force_linking (void); … … 381 395 } 382 396 383 /* Run through the statics list, removing modules as soon as all its statics 384 have been initialized. */ 397 /* Run through the statics list, removing modules as soon as all its 398 statics have been initialized. */ 399 385 400 static void 386 401 objc_init_statics (void) … … 389 404 struct objc_static_instances **statics_in_module; 390 405 391 objc_mutex_lock (__objc_runtime_mutex);406 objc_mutex_lock (__objc_runtime_mutex); 392 407 393 408 while (*cell) … … 401 416 Class class = objc_lookup_class (statics->class_name); 402 417 403 if (! class)418 if (! class) 404 419 module_initialized = 0; 405 420 /* Actually, the static's class_pointer will be NULL when we … … 431 446 struct objc_list *this = *cell; 432 447 *cell = this->tail; 433 objc_free (this);448 objc_free (this); 434 449 } 435 450 else … … 437 452 } 438 453 439 objc_mutex_unlock (__objc_runtime_mutex);454 objc_mutex_unlock (__objc_runtime_mutex); 440 455 } /* objc_init_statics */ 441 456 442 457 /* This function is called by constructor functions generated for each 443 module compiled. (_GLOBAL_$I$...) The purpose of this function is to444 gather the module pointers so that they may be processed by the445 initialization routines as soon as possible */458 module compiled. (_GLOBAL_$I$...) The purpose of this function is 459 to gather the module pointers so that they may be processed by the 460 initialization routines as soon as possible. */ 446 461 447 462 void … … 452 467 static BOOL previous_constructors = 0; 453 468 454 static struct objc_list *unclaimed_categories = 0;469 static struct objc_list *unclaimed_categories = 0; 455 470 456 471 /* The symbol table (defined in objc-api.h) generated by gcc */ … … 462 477 463 478 /* Entry used to traverse hash lists */ 464 struct objc_list **cell;479 struct objc_list **cell; 465 480 466 481 /* The table of selector references for this module */ … … 473 488 474 489 /* check gcc version */ 475 init_check_module_version (module);490 init_check_module_version (module); 476 491 477 492 /* On the first call of this routine, initialize some data structures. */ 478 if (! previous_constructors)493 if (! previous_constructors) 479 494 { 480 495 /* Initialize thread-safe system */ 481 __objc_init_thread_system ();496 __objc_init_thread_system (); 482 497 __objc_runtime_threads_alive = 1; 483 __objc_runtime_mutex = objc_mutex_allocate ();484 485 __objc_init_selector_tables ();486 __objc_init_class_tables ();487 __objc_init_dispatch_tables ();498 __objc_runtime_mutex = objc_mutex_allocate (); 499 500 __objc_init_selector_tables (); 501 __objc_init_class_tables (); 502 __objc_init_dispatch_tables (); 488 503 __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list); 489 504 __objc_load_methods … … 493 508 494 509 /* Save the module pointer for later processing. (not currently used) */ 495 objc_mutex_lock (__objc_runtime_mutex);496 __objc_module_list = list_cons (module, __objc_module_list);510 objc_mutex_lock (__objc_runtime_mutex); 511 __objc_module_list = list_cons (module, __objc_module_list); 497 512 498 513 /* Replace referenced selectors from names to SEL's. */ … … 502 517 { 503 518 const char *name, *type; 504 name = (char *)selectors[i].sel_id;505 type = (char *)selectors[i].sel_types;519 name = (char *) selectors[i].sel_id; 520 type = (char *) selectors[i].sel_types; 506 521 /* Constructors are constant static data so we can safely store 507 522 pointers to them in the runtime structures. is_const == YES */ 508 523 __sel_register_typed_name (name, type, 509 (struct objc_selector *)&(selectors[i]),524 (struct objc_selector *) &(selectors[i]), 510 525 YES); 511 526 } … … 517 532 { 518 533 Class class = (Class) symtab->defs[i]; 519 const char * superclass = (char*)class->super_class;534 const char *superclass = (char *) class->super_class; 520 535 521 536 /* Make sure we have what we think. */ 522 assert (CLS_ISCLASS (class));523 assert (CLS_ISMETA (class->class_pointer));537 assert (CLS_ISCLASS (class)); 538 assert (CLS_ISMETA (class->class_pointer)); 524 539 DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name); 525 540 526 541 /* Initialize the subclass list to be NULL. 527 In some cases it isn't and this crashes the program. */542 In some cases it isn't and this crashes the program. */ 528 543 class->subclass_list = NULL; 529 544 … … 536 551 537 552 /* Install the fake dispatch tables */ 538 __objc_install_premature_dtable (class);539 __objc_install_premature_dtable (class->class_pointer);553 __objc_install_premature_dtable (class); 554 __objc_install_premature_dtable (class->class_pointer); 540 555 541 556 /* Register the instance methods as class methods, this is 542 only done for root classes. */543 __objc_register_instance_methods_to_class (class);557 only done for root classes. */ 558 __objc_register_instance_methods_to_class (class); 544 559 545 560 if (class->protocols) … … 547 562 548 563 /* Check to see if the superclass is known in this point. If it's not 549 add the class to the unresolved_classes list. */550 if (superclass && ! objc_lookup_class (superclass))564 add the class to the unresolved_classes list. */ 565 if (superclass && ! objc_lookup_class (superclass)) 551 566 unresolved_classes = list_cons (class, unresolved_classes); 552 567 } … … 582 597 583 598 /* Register the instance methods as class methods, this is 584 only done for root classes. */585 __objc_register_instance_methods_to_class (class);599 only done for root classes. */ 600 __objc_register_instance_methods_to_class (class); 586 601 } 587 602 else … … 589 604 /* The object to which the category methods belong can't be found. 590 605 Save the information. */ 591 unclaimed_categories = list_cons (category, unclaimed_categories);606 unclaimed_categories = list_cons (category, unclaimed_categories); 592 607 } 593 608 } … … 626 641 627 642 /* Register the instance methods as class methods, this is 628 only done for root classes. */629 __objc_register_instance_methods_to_class (class);643 only done for root classes. */ 644 __objc_register_instance_methods_to_class (class); 630 645 } 631 646 else … … 635 650 if (unclaimed_proto_list && objc_lookup_class ("Protocol")) 636 651 { 637 list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols); 652 list_mapcar (unclaimed_proto_list, 653 (void (*) (void *))__objc_init_protocols); 638 654 list_free (unclaimed_proto_list); 639 655 unclaimed_proto_list = 0; … … 642 658 objc_send_load (); 643 659 644 objc_mutex_unlock(__objc_runtime_mutex); 645 } 646 647 static void objc_send_load (void) 648 { 649 if (!__objc_module_list) 660 objc_mutex_unlock (__objc_runtime_mutex); 661 } 662 663 static void 664 objc_send_load (void) 665 { 666 if (! __objc_module_list) 650 667 return; 651 668 652 669 /* Try to find out if all the classes loaded so far also have their 653 superclasses known to the runtime. We suppose that the objects that are654 allocated in the +load method are in general of a class declared in the655 same module.*/670 superclasses known to the runtime. We suppose that the objects 671 that are allocated in the +load method are in general of a class 672 declared in the same module. */ 656 673 if (unresolved_classes) 657 674 { 658 675 Class class = unresolved_classes->head; 659 676 660 while (objc_lookup_class ((char *)class->super_class))677 while (objc_lookup_class ((char *) class->super_class)) 661 678 { 662 679 list_remove_head (&unresolved_classes); … … 667 684 } 668 685 669 /* 670 * If we still have classes for whom we don't have yet their super 671 * classes known to the runtime we don't send the +load messages. 672 */ 686 /* If we still have classes for whom we don't have yet their 687 super classes known to the runtime we don't send the +load 688 messages. */ 673 689 if (unresolved_classes) 674 690 return; 675 691 } 676 692 677 /* Special check to allow creating and sending messages to constant strings678 in +load methods. If these classes are not yet known, even if all the679 other classes are known, delay sending of +load.*/680 if (! objc_lookup_class ("NXConstantString") ||681 ! objc_lookup_class ("Object"))693 /* Special check to allow creating and sending messages to constant 694 strings in +load methods. If these classes are not yet known, 695 even if all the other classes are known, delay sending of +load. */ 696 if (! objc_lookup_class ("NXConstantString") || 697 ! objc_lookup_class ("Object")) 682 698 return; 683 699 684 /* Iterate over all modules in the __objc_module_list and call on them the 685 __objc_create_classes_tree function. This function creates a tree of 686 classes that resembles the class hierarchy. */ 687 list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree); 700 /* Iterate over all modules in the __objc_module_list and call on 701 them the __objc_create_classes_tree function. This function 702 creates a tree of classes that resembles the class hierarchy. */ 703 list_mapcar (__objc_module_list, 704 (void (*) (void *)) __objc_create_classes_tree); 688 705 689 706 while (__objc_class_tree_list) … … 700 717 } 701 718 702 list_mapcar (__objc_module_list, (void (*)(void*))__objc_call_callback);719 list_mapcar (__objc_module_list, (void (*) (void *)) __objc_call_callback); 703 720 list_free (__objc_module_list); 704 721 __objc_module_list = NULL; … … 713 730 int i; 714 731 715 /* Iterate thru classes defined in this module and insert them in the classes716 t ree hierarchy.*/732 /* Iterate thru classes defined in this module and insert them in 733 the classes tree hierarchy. */ 717 734 for (i = 0; i < symtab->cls_def_cnt; i++) 718 735 { … … 726 743 __objc_call_callback (Module_t module) 727 744 { 728 /* The runtime mutex is locked in this point */745 /* The runtime mutex is locked in this point. */ 729 746 730 747 Symtab_t symtab = module->symtab; 731 748 int i; 732 749 733 /* Iterate thru classes defined in this module and call the callback for734 each one.*/750 /* Iterate thru classes defined in this module and call the callback 751 for each one. */ 735 752 for (i = 0; i < symtab->cls_def_cnt; i++) 736 753 { 737 754 Class class = (Class) symtab->defs[i]; 738 755 739 /* Call the _objc_load_callback for this class. */756 /* Call the _objc_load_callback for this class. */ 740 757 if (_objc_load_callback) 741 _objc_load_callback (class, 0);742 } 743 744 /* Call the _objc_load_callback for categories. Don't register the instance745 methods as class methods for categories to root classes since they were746 already added in the class.*/758 _objc_load_callback (class, 0); 759 } 760 761 /* Call the _objc_load_callback for categories. Don't register the 762 instance methods as class methods for categories to root classes 763 since they were already added in the class. */ 747 764 for (i = 0; i < symtab->cat_def_cnt; i++) 748 765 { … … 751 768 752 769 if (_objc_load_callback) 753 _objc_load_callback(class, category); 754 } 755 } 756 757 /* Sanity check the version of gcc used to compile `module'*/ 758 static void init_check_module_version(Module_t module) 770 _objc_load_callback (class, category); 771 } 772 } 773 774 /* Sanity check the version of gcc used to compile `module'. */ 775 776 static void 777 init_check_module_version (Module_t module) 759 778 { 760 779 if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module))) … … 762 781 int code; 763 782 764 if (module->version > OBJC_VERSION)783 if (module->version > OBJC_VERSION) 765 784 code = OBJC_ERR_OBJC_VERSION; 766 785 else if (module->version < OBJC_VERSION) … … 769 788 code = OBJC_ERR_MODULE_SIZE; 770 789 771 objc_error (nil, code, "Module %s version %d doesn't match runtime %d\n",772 773 } 774 } 775 776 static void 777 __objc_init_protocols (struct objc_protocol_list *protos)778 { 779 int i;790 objc_error (nil, code, "Module %s version %d doesn't match runtime %d\n", 791 module->name, (int)module->version, OBJC_VERSION); 792 } 793 } 794 795 static void 796 __objc_init_protocols (struct objc_protocol_list *protos) 797 { 798 size_t i; 780 799 static Class proto_class = 0; 781 800 … … 783 802 return; 784 803 785 objc_mutex_lock (__objc_runtime_mutex);786 787 if (! proto_class)788 proto_class = objc_lookup_class ("Protocol");789 790 if (! proto_class)804 objc_mutex_lock (__objc_runtime_mutex); 805 806 if (! proto_class) 807 proto_class = objc_lookup_class ("Protocol"); 808 809 if (! proto_class) 791 810 { 792 811 unclaimed_proto_list = list_cons (protos, unclaimed_proto_list); 793 objc_mutex_unlock (__objc_runtime_mutex);812 objc_mutex_unlock (__objc_runtime_mutex); 794 813 return; 795 814 } … … 799 818 #endif 800 819 801 for (i = 0; i < protos->count; i++)802 { 803 struct objc_protocol *aProto = protos->list[i];820 for (i = 0; i < protos->count; i++) 821 { 822 struct objc_protocol *aProto = protos->list[i]; 804 823 if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION) 805 824 { … … 812 831 else if (protos->list[i]->class_pointer != proto_class) 813 832 { 814 objc_error (nil, OBJC_ERR_PROTOCOL_VERSION,833 objc_error (nil, OBJC_ERR_PROTOCOL_VERSION, 815 834 "Version %d doesn't match runtime protocol version %d\n", 816 (int)((char*)protos->list[i]->class_pointer-(char*)0), 835 (int) ((char *) protos->list[i]->class_pointer 836 - (char *) 0), 817 837 PROTOCOL_VERSION); 818 838 } 819 839 } 820 840 821 objc_mutex_unlock (__objc_runtime_mutex);822 } 823 824 static void __objc_class_add_protocols (Class class,825 struct objc_protocol_list*protos)826 { 827 /* Well... */841 objc_mutex_unlock (__objc_runtime_mutex); 842 } 843 844 static void 845 __objc_class_add_protocols (Class class, struct objc_protocol_list *protos) 846 { 847 /* Well... */ 828 848 if (! protos) 829 849 return; 830 850 831 /* Add it... */851 /* Add it... */ 832 852 protos->next = class->protocols; 833 853 class->protocols = protos; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.