Lines Matching refs:Class
1 /* GNU Objective C Runtime class related functions
5 Lock-free class table code designed and written from scratch by
28 /* The code in this file critically affects class method invocation
33 that class method invocations are slow. The reason is that when you
42 objc_get_class returns the class pointer corresponding to the string
48 caching the class pointer:
50 Class arrayClass = [NSArray class];
58 In this case, you always perform a class lookup (the first one), but
60 instance method invocation. It helps if you have many class method
61 invocations to the same class.
64 compiler to output tables of class pointers corresponding to all the
65 class method invocations, and to add code to the runtime to update
66 these tables - that should in the end allow class method invocations
68 no class lookup would be involved. I think the Apple Objective-C
73 rewritten the way the runtime is performing class lookup. This
75 at least a class method invocation now takes approximately 4.5 times
79 One of the main reason the new class lookup is so faster is because
97 /* We use a table which maps a class name to the corresponding class
105 ** Class Table Internals
108 /* A node holding a class */
114 const char *name; /* The class name string */
115 int length; /* The class name string length */
116 Class pointer; /* The Class pointer */
124 /* We have 1024 tables. Each table contains all class names which
145 /* CLASS_TABLE_HASH is how we compute the hash of a class name. It is
179 /* Insert a class in the table (used when a new class is
182 class_table_insert (const char *class_name, Class class_pointer)
187 /* Find out the class name's hash and length. */
190 /* Prepare the new node holding the class. */
207 /* Get a class from the table. This does not need mutex protection.
210 static inline Class
227 /* Compare the class names. */
249 /* Enumerate over the class table. */
257 static Class
302 /* Debugging function - print the class table. */
365 /* From now on, the only access to the class table data structure
369 objc_lookup_class if the runtime is not able to find the class.
370 This may e.g. try to load in the class using dynamic loading.
377 Class (*_objc_lookup_class) (const char *name) = 0; /* !T:SAFE */
396 /* True when class links has been resolved. */
403 /* Allocate the class hash table. */
415 /* This function adds a class to the class hash table, and assigns the
416 class a number, unless it's already known. Return 'YES' if the
417 class was added. Return 'NO' if the class was already known. */
419 __objc_add_class_to_hash (Class class)
421 Class existing_class;
428 /* Make sure it's not a meta class. */
429 assert (CLS_ISCLASS (class));
431 /* Check to see if the class is already in the hash table. */
432 existing_class = class_table_get_safe (class->name);
441 /* The class isn't in the hash table. Add the class and assign
442 a class number. */
445 CLS_SETNUMBER (class, class_number);
446 CLS_SETNUMBER (class->class_pointer, class_number);
449 class_table_insert (class->name, class);
456 Class
459 Class class;
464 class = class_table_get_safe (name);
466 if (class)
467 return class;
478 Class
487 Class
490 Class class = objc_getClass (name);
492 if (class)
493 return class->class_pointer;
498 Class
501 Class class = objc_getClass (name);
503 if (class)
504 return class;
506 _objc_abort ("objc_getRequiredClass ('%s') failed: class not found\n", name);
510 objc_getClassList (Class *returnValue, int maxNumberOfClassesToReturn)
536 Class
537 objc_allocateClassPair (Class super_class, const char *class_name, size_t extraBytes)
539 Class new_class;
540 Class new_meta_class;
559 class_createInstance() to create the class. That complication
560 would be relevant if we had class variables, but we don't, so we
566 /* We create an unresolved class, similar to one generated by the
570 class is resolved, the ones that matter will be fixed up. */
577 actual superclass, which will be put there when the class is
609 objc_registerClassPair (Class class_)
633 /* Resolve class links immediately. No point in waiting. */
640 objc_disposeClassPair (Class class_)
701 /* Undo any class_addMethod() on the meta-class. */
734 /* Get the class object for the class named NAME. If NAME does not
735 identify a known class, the hook _objc_lookup_class is called. If
737 Class
740 Class class;
742 class = class_table_get_safe (name);
744 if (class)
745 return class;
748 class = (*__objc_get_unknown_class_handler) (name);
750 if ((!class) && _objc_lookup_class)
751 class = (*_objc_lookup_class) (name);
753 if (class)
754 return class;
756 _objc_abort ("objc runtime: cannot find class %s\n", name);
762 Class
771 Class
795 over all methods in the class (instance methods), while
797 class (class methods). */
798 Class class = Nil;
805 if (class == Nil)
807 /* The first time, we work on the class. */
808 class = node->pointer;
812 /* The second time, we work on the meta class. */
813 class = class->class_pointer;
817 method_list = class->methods;
830 sarray_at_put_safe (class->dtable,
837 sarray_at_put_safe (class->dtable,
852 can be sure of is that the class_pointer for class objects point to
853 the right meta class objects. */
858 Class object_class = objc_get_class ("Object");
859 Class class1;
873 class. */
883 Class a_super_class
888 DEBUG_PRINTF ("making class connections for: %s\n",
895 /* Assign subclass links for meta class of superclass. */
904 else /* A root class, make its meta object be a subclass of
918 Class sub_class;
932 class_getName (Class class_)
941 class_isMetaClass (Class class_)
949 resolves the class links if needed. If you access
951 where the class is not resolved yet! */
952 Class
953 class_getSuperclass (Class class_)
959 the class name (instead of a class pointer) in the
962 class until it is registered. */
971 /* If the class is not resolved yet, super_class would point to a
972 string (the name of the super class) as opposed to the actual
973 super class. In that case, we need to resolve the class links
982 class_getVersion (Class class_)
991 class_setVersion (Class class_, int version)
1000 class_getInstanceSize (Class class_)