--- gcc/objc/objc-api.h 2018/04/24 18:10:15 1.1 +++ gcc/objc/objc-api.h 2018/04/24 18:26:44 1.1.1.4 @@ -1,5 +1,5 @@ /* GNU Objective-C Runtime API. - Copyright (C) 1993 Free Software Foundation, Inc. + Copyright (C) 1993, 1995 Free Software Foundation, Inc. This file is part of GNU CC. @@ -15,7 +15,8 @@ License for more details. You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ /* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause the resulting @@ -44,8 +45,6 @@ struct objc_method_description char *types; /* type encoding */ }; - - /* Filer types used to describe Ivars and Methods. */ #define _C_ID '@' #define _C_CLASS '#' @@ -92,19 +91,29 @@ extern BOOL objc_trace; */ typedef struct objc_symtab { unsigned long sel_ref_cnt; /* Unknown. */ - SEL *refs; /* Unknown. */ + SEL refs; /* Unknown. */ unsigned short cls_def_cnt; /* Number of classes compiled (defined) in the module. */ unsigned short cat_def_cnt; /* Number of categories compiled (defined) in the module. */ void *defs[1]; /* Variable array of pointers. - cls_def_cnt of type Class* + cls_def_cnt of type Class followed by cat_def_cnt of type Category_t. */ } Symtab, *Symtab_t; +/* For every class which happens to have statically allocated instances in + this module, one OBJC_STATIC_INSTANCES is allocated by the compiler. + INSTANCES is NULL terminated and points to all statically allocated + instances of this class. */ +struct objc_static_instances +{ + char *class_name; + id instances[0]; +}; + /* ** The compiler generates one of these structures for each module that ** composes the executable (eg main.m). @@ -120,6 +129,10 @@ typedef struct objc_module { const char* name; /* Name of the file where the module was generated. The name includes the path. */ + + /* Pointer to a NULL terminated array of objc_static_instances. */ + struct objc_static_instances **statics; + Symtab_t symtab; /* Pointer to the Symtab of the module. The Symtab holds an array of pointers to @@ -146,7 +159,7 @@ typedef struct objc_ivar_list { const char* ivar_type; /* Description of the Ivar's type. Useful for debuggers. */ - int ivar_offset; /* Byte offset from the base + int ivar_offset; /* Byte offset from the base address of the instance structure to the variable. */ @@ -169,7 +182,7 @@ typedef struct objc_method_list { struct objc_method_list* method_next; /* This variable is used to link a method list to another. It is a singly linked list. */ - int method_count; /* Number of methods defined in + int method_count; /* Number of methods defined in this structure. */ struct objc_method { SEL method_name; /* This variable is the method's @@ -205,12 +218,12 @@ struct objc_protocol_list { #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask) #define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask) -/* The structure is of type MetaClass* */ +/* The structure is of type MetaClass */ #define _CLS_META 0x2L #define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META)) -/* The structure is of type Class* */ +/* The structure is of type Class */ #define _CLS_CLASS 0x1L #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS)) @@ -236,7 +249,8 @@ struct objc_protocol_list { */ #define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2)) #define CLS_SETNUMBER(cls, num) \ - ({ assert(CLS_GETNUMBER(cls)==0); \ + ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \ + (cls)->info >>= (HOST_BITS_PER_LONG/2); \ __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); }) /* @@ -269,16 +283,14 @@ typedef struct objc_category { typedef struct objc_super { id self; /* Id of the object sending the message. */ - Class* class; /* Object's super class. */ + Class class; /* Object's super class. */ } Super, *Super_t; IMP objc_msg_lookup_super(Super_t super, SEL sel); -retval_t objc_msg_sendv(id, SEL, size_t, arglist_t); - +retval_t objc_msg_sendv(id, SEL, arglist_t); -static const ARGSIZE = 96; /* for `method_get_argsize()' */ /* ** This is a hook which is called by objc_lookup_class and @@ -286,110 +298,125 @@ static const ARGSIZE = 96; /* for `meth ** This may e.g. try to load in the class using dynamic loading. ** The function is guaranteed to be passed a non-NULL name string. */ -extern Class* (*_objc_lookup_class)(const char *name); +extern Class (*_objc_lookup_class)(const char *name); + +/* +** This is a hook which is called by __objc_exec_class every time a class +** or a category is loaded into the runtime. This may e.g. help a +** dynamic loader determine the classes that have been loaded when +** an object file is dynamically linked in. +*/ +extern void (*_objc_load_callback)(Class class, Category* category); -extern id (*_objc_object_alloc)(Class* class); +extern id (*_objc_object_alloc)(Class class); extern id (*_objc_object_copy)(id object); extern id (*_objc_object_dispose)(id object); -Method_t class_get_class_method(MetaClass* class, SEL aSel); +Method_t class_get_class_method(MetaClass class, SEL aSel); -Method_t class_get_instance_method(Class* class, SEL aSel); +Method_t class_get_instance_method(Class class, SEL aSel); -Class* class_pose_as(Class* impostor, Class* superclass); +Class class_pose_as(Class impostor, Class superclass); -Class* objc_get_class(const char *name); +Class objc_get_class(const char *name); -Class* objc_lookup_class(const char *name); +Class objc_lookup_class(const char *name); + +Class objc_next_class(void **enum_state); const char *sel_get_name(SEL selector); +const char *sel_get_type(SEL selector); + SEL sel_get_uid(const char *name); +SEL sel_get_any_uid(const char *name); + +SEL sel_get_any_typed_uid(const char *name); + +SEL sel_get_typed_uid(const char *name, const char*); + SEL sel_register_name(const char *name); +SEL sel_register_typed_name(const char *name, const char*type); + + BOOL sel_is_mapped (SEL aSel); -extern id class_create_instance(Class* class); +extern id class_create_instance(Class class); static inline const char * -class_get_class_name(Class* class) +class_get_class_name(Class class) { return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0); } static inline long -class_get_instance_size(Class* class) +class_get_instance_size(Class class) { return CLS_ISCLASS(class)?class->instance_size:0; } -static inline MetaClass* -class_get_meta_class(Class* class) +static inline MetaClass +class_get_meta_class(Class class) { return CLS_ISCLASS(class)?class->class_pointer:Nil; } -static inline Class* -class_get_super_class(Class* class) +static inline Class +class_get_super_class(Class class) { return CLS_ISCLASS(class)?class->super_class:Nil; } static inline int -class_get_version(Class* class) +class_get_version(Class class) { return CLS_ISCLASS(class)?class->version:-1; } static inline BOOL -class_is_class(Class* class) +class_is_class(Class class) { return CLS_ISCLASS(class); } static inline BOOL -class_is_meta_class(Class* class) +class_is_meta_class(Class class) { return CLS_ISMETA(class); } static inline void -class_set_version(Class* class, long version) +class_set_version(Class class, long version) { if (CLS_ISCLASS(class)) class->version = version; } -static inline unsigned int -method_get_argsize(Method_t method) -{ - return ARGSIZE; /* This was a magic number (96)... */ -} - static inline IMP method_get_imp(Method_t method) { return (method!=METHOD_NULL)?method->method_imp:(IMP)0; } -IMP get_imp (Class* class, SEL sel); +IMP get_imp (Class class, SEL sel); id object_copy(id object); id object_dispose(id object); -static inline Class* +static inline Class object_get_class(id object) { return ((object!=nil) ? (CLS_ISCLASS(object->class_pointer) ? object->class_pointer : (CLS_ISMETA(object->class_pointer) - ? (Class*)object + ? (Class)object : Nil)) : Nil); } @@ -399,11 +426,11 @@ object_get_class_name(id object) { return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) ?object->class_pointer->name - :((Class*)object)->name) + :((Class)object)->name) :"Nil"); } -static inline MetaClass* +static inline MetaClass object_get_meta_class(id object) { return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) @@ -414,14 +441,14 @@ object_get_meta_class(id object) :Nil); } -static inline Class* +static inline Class object_get_super_class (id object) { return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) ?object->class_pointer->super_class :(CLS_ISMETA(object->class_pointer) - ?((Class*)object)->super_class + ?((Class)object)->super_class :Nil)) :Nil); } @@ -429,7 +456,7 @@ object_get_super_class static inline BOOL object_is_class(id object) { - return CLS_ISCLASS((Class*)object); + return CLS_ISCLASS((Class)object); } static inline BOOL @@ -441,7 +468,7 @@ object_is_instance(id object) static inline BOOL object_is_meta_class(id object) { - return CLS_ISMETA((Class*)object); + return CLS_ISMETA((Class)object); } #endif /* not __objc_api_INCLUDE_GNU */