From d0b575120e2d091b7d66a1898b6ef114298f8433 Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Tue, 27 Apr 1993 07:41:50 +0000 Subject: [PATCH] Definition of (Meta)Class_t eliminated, using Class* From-SVN: r4244 --- gcc/objc/Makefile.in | 9 +++--- gcc/objc/Object.h | 46 +++++++++++++++++++++++------ gcc/objc/Object.m | 23 ++++++++------- gcc/objc/class.c | 44 ++++++++++++++-------------- gcc/objc/init.c | 18 ++++++------ gcc/objc/misc.c | 2 +- gcc/objc/objc-api.h | 58 ++++++++++++++++++------------------- gcc/objc/objc.h | 81 +++++++++++++++++++++++++--------------------------- gcc/objc/objects.c | 8 +++--- gcc/objc/runtime.h | 10 +++---- gcc/objc/selector.c | 2 +- gcc/objc/sendmsg.c | 38 ++++++++++++------------ 12 files changed, 182 insertions(+), 157 deletions(-) diff --git a/gcc/objc/Makefile.in b/gcc/objc/Makefile.in index 2f38a25..c763f13 100644 --- a/gcc/objc/Makefile.in +++ b/gcc/objc/Makefile.in @@ -29,7 +29,6 @@ .SUFFIXES: .m OPTIMIZE= -O -CFLAGS = $(GCC_CFLAGS) VPATH = $(srcdir)/objc @@ -41,11 +40,11 @@ SUBDIR_INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/config .c.o: $(GCC_FOR_TARGET) $(OPTIMIZE) \ - -c $(CFLAGS) $(SUBDIR_INCLUDES) $< + -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< .m.o: $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \ - -c $(CFLAGS) $(SUBDIR_INCLUDES) $< + -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $< # If we were not invoked from the parent dir, # invoke make in the parent dir and have reinvoke this makefile. @@ -76,11 +75,11 @@ copy-headers: $(OBJC_H) done sendmsg.o: sendmsg.c fflags - $(GCC_FOR_TARGET) `cat fflags` -c $(CFLAGS) $(SUBDIR_INCLUDES) $(srcdir)/objc/sendmsg.c + $(GCC_FOR_TARGET) `cat fflags` -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $(srcdir)/objc/sendmsg.c ## Next to are for heuristics on forwarding mechanism... _forward: _forward.c - -$(GCC_FOR_TARGET) -c $(CFLAGS) $(SUBDIR_INCLUDES) $(srcdir)/objc/_forward.c + -$(GCC_FOR_TARGET) -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $(srcdir)/objc/_forward.c -$(GCC_FOR_TARGET) ./_forward.o -o _forward if [ \! -f ./_forward ]; then touch ./_forward; fi diff --git a/gcc/objc/Object.h b/gcc/objc/Object.h index ed2b350..6ef6e87 100644 --- a/gcc/objc/Object.h +++ b/gcc/objc/Object.h @@ -26,7 +26,35 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __object_INCLUDE_GNU #define __object_INCLUDE_GNU -#include "objc/objc.h" +#ifndef __objc_INCLUDE_GNU + +/* This is the minimal set of definitions, which may be sufficient + for simple programs not interacting heavily with the runtime */ + +typedef char BOOL; +#define YES (BOOL)1 +#define NO (BOOL)0 + +typedef void* SEL; + +typedef struct objc_object { + struct objc_class* class_pointer; +} *id; + +typedef id (*IMP)(id, SEL, ...); + +typedef struct objc_class Class; +typedef struct objc_class MetaClass; + +#define nil (id)0 /* id of Nil instance */ +#define Nil (Class*)0 /* id of Nil class */ +typedef char *STR; /* String alias */ + +@class Protocol; +typedef struct objc_typed_stream TypedStream; +typedef void* arglist_t; + +#endif /* not __objc_INCLUDE_GNU */ /* * All classes are derived from Object. As such, @@ -34,7 +62,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ */ @interface Object { - Class_t isa; /* A pointer to the instance's class structure */ + Class* isa; /* A pointer to the instance's class structure */ } /* Initializing classes and instances */ @@ -51,9 +79,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - deepCopy; /* Identifying classes */ -- (Class_t)class; -- (Class_t)superClass; -- (MetaClass_t)metaClass; +- (Class*)class; +- (Class*)superClass; +- (MetaClass*)metaClass; - (const char *)name; /* Identifying and comparing objects */ @@ -67,8 +95,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - (BOOL)isInstance; /* Testing inheritance relationships */ -- (BOOL)isKindOf:(Class_t)aClassObject; -- (BOOL)isMemberOf:(Class_t)aClassObject; +- (BOOL)isKindOf:(Class*)aClassObject; +- (BOOL)isMemberOf:(Class*)aClassObject; - (BOOL)isKindOfClassNamed:(const char *)aClassName; - (BOOL)isMemberOfClassNamed:(const char *)aClassName; @@ -95,8 +123,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - performv:(SEL)aSel :(arglist_t)argFrame; /* Posing */ -+ poseAs:(Class_t)aClassObject; -- (Class_t)transmuteClassTo:(Class_t)aClassObject; ++ poseAs:(Class*)aClassObject; +- (Class*)transmuteClassTo:(Class*)aClassObject; /* Enforcing intentions */ - subclassResponsibility:(SEL)aSel; diff --git a/gcc/objc/Object.m b/gcc/objc/Object.m index dd27f2d..5f35bd3 100644 --- a/gcc/objc/Object.m +++ b/gcc/objc/Object.m @@ -27,6 +27,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "objc/Protocol.h" #include "objc/objc-api.h" +#include "gstdarg.h" +extern void (*_objc_error)(id object, const char *format, va_list); + extern int errno; #define MAX_CLASS_NAME_LEN 256 @@ -78,17 +81,17 @@ extern int errno; return [self copy]; } -- (Class_t)class +- (Class*)class { return object_get_class(self); } -- (Class_t)superClass +- (Class*)superClass { return object_get_super_class(self); } -- (MetaClass_t)metaClass +- (MetaClass*)metaClass { return object_get_meta_class(self); } @@ -128,9 +131,9 @@ extern int errno; return object_is_instance(self); } -- (BOOL)isKindOf:(Class_t)aClassObject +- (BOOL)isKindOf:(Class*)aClassObject { - Class_t class; + Class* class; for (class = self->isa; class!=Nil; class = class_get_super_class(class)) if (class==aClassObject) @@ -138,14 +141,14 @@ extern int errno; return NO; } -- (BOOL)isMemberOf:(Class_t)aClassObject +- (BOOL)isMemberOf:(Class*)aClassObject { return self->isa==aClassObject; } - (BOOL)isKindOfClassNamed:(const char *)aClassName { - Class_t class; + Class* class; if (aClassName!=NULL) for (class = self->isa; class!=Nil; class = class_get_super_class(class)) @@ -252,19 +255,19 @@ extern int errno; return objc_msg_sendv(self, aSel, method_get_argsize(0), argFrame); } -+ poseAs:(Class_t)aClassObject ++ poseAs:(Class*)aClassObject { return class_pose_as(self, aClassObject); } -- (Class_t)transmuteClassTo:(Class_t)aClassObject +- (Class*)transmuteClassTo:(Class*)aClassObject { if (object_is_instance(self)) if (class_is_class(aClassObject)) if (class_get_instance_size(aClassObject)==class_get_instance_size(isa)) if ([self isKindOf:aClassObject]) { - Class_t old_isa = isa; + Class* old_isa = isa; isa = aClassObject; return old_isa; } diff --git a/gcc/objc/class.c b/gcc/objc/class.c index 87ebf25..26f4c4f 100644 --- a/gcc/objc/class.c +++ b/gcc/objc/class.c @@ -33,7 +33,7 @@ static cache_ptr __objc_class_hash = 0; /* This is a hook which is called by objc_get_class and objc_lookup_class if the runtime is not able to find the class. This may e.g. try to load in the class using dynamic loading */ -Class_t (*_objc_lookup_class)(const char* name) = 0; +Class* (*_objc_lookup_class)(const char* name) = 0; /* True when class links has been resolved */ @@ -59,9 +59,9 @@ void __objc_init_class_tables() /* This function adds a class to the class hash table, and assigns the class a number, unless it's already known */ void -__objc_add_class_to_hash(Class_t class) +__objc_add_class_to_hash(Class* class) { - Class_t h_class; + Class* h_class; /* make sure the table is there */ assert(__objc_class_hash); @@ -88,9 +88,9 @@ __objc_add_class_to_hash(Class_t class) /* Get the class object for the class named NAME. If NAME does not identify a known class, the hook _objc_lookup_class is called. If this fails, nil is returned */ -Class_t objc_lookup_class (const char* name) +Class* objc_lookup_class (const char* name) { - Class_t class; + Class* class; /* Make sure the class hash table exists. */ assert (__objc_class_hash); @@ -109,10 +109,10 @@ Class_t objc_lookup_class (const char* name) /* Get the class object for the class named NAME. If NAME does not identify a known class, the hook _objc_lookup_class is called. If this fails, an error message is issued and the system aborts */ -Class_t +Class* objc_get_class (const char *name) { - Class_t class; + Class* class; /* Make sure the class hash table exists. */ assert (__objc_class_hash); @@ -139,7 +139,7 @@ objc_get_class (const char *name) void __objc_resolve_class_links() { node_ptr node; - Class_t object_class = objc_get_class ("Object"); + Class* object_class = objc_get_class ("Object"); assert(object_class); @@ -147,7 +147,7 @@ void __objc_resolve_class_links() for (node = hash_next (__objc_class_hash, NULL); node; node = hash_next (__objc_class_hash, node)) { - Class_t class1 = node->value; + Class* class1 = node->value; /* Make sure we have what we think we have. */ assert (CLS_ISCLASS(class1)); @@ -163,7 +163,7 @@ void __objc_resolve_class_links() if(class1->super_class) { - Class_t a_super_class + Class* a_super_class = objc_get_class ((char *) class1->super_class); assert (a_super_class); @@ -198,8 +198,8 @@ void __objc_resolve_class_links() for (node = hash_next (__objc_class_hash, NULL); node; node = hash_next (__objc_class_hash, node)) { - Class_t class1 = node->value; - Class_t sub_class; + Class* class1 = node->value; + Class* sub_class; for (sub_class = class1->subclass_list; sub_class; sub_class = sub_class->sibling_class) { @@ -223,12 +223,12 @@ I implement posing by hiding SUPER_CLASS, creating new class and meta class structures -- except the impostor itself. The only dramatic effect on the application is that subclasses of SUPER_CLASS cannot do a [ .... super_class ] and expect their real super class. */ -Class_t -class_pose_as (Class_t impostor, Class_t super_class) +Class* +class_pose_as (Class* impostor, Class* super_class) { - Class_t new_class = (Class_t) calloc (1, sizeof (Class)); - MetaClass_t new_meta_class = - (MetaClass_t) __objc_xmalloc(sizeof (MetaClass)); + Class* new_class = (Class*) calloc (1, sizeof (Class)); + MetaClass* new_meta_class = + (MetaClass*) __objc_xmalloc(sizeof (MetaClass)); char *new_name = (char *)__objc_xmalloc ((size_t)strlen ((char*)super_class->name) + 12); /* We must know the state of the hierachy. Do initial setup if needed */ @@ -278,8 +278,8 @@ class_pose_as (Class_t impostor, Class_t super_class) complex, since we have both super_class link, and subclass_list for the involved classes. */ { - Class_t *classpp; - MetaClass_t *metaclasspp; + Class* *classpp; + MetaClass* *metaclasspp; /* Remove impostor from subclass list of super_class */ for (classpp = &(super_class->subclass_list); @@ -350,7 +350,7 @@ class_pose_as (Class_t impostor, Class_t super_class) __objc_add_class_to_hash (new_class); /* Now update dispatch tables for new_class and it's subclasses */ - __objc_update_dispatch_table_for_class ((Class_t) new_meta_class); + __objc_update_dispatch_table_for_class ((Class*) new_meta_class); __objc_update_dispatch_table_for_class (new_class); return new_class; @@ -360,13 +360,13 @@ class_pose_as (Class_t impostor, Class_t super_class) __objc_class_hash_tables_size () { node_ptr node; - Class_t class1; + Class* class1; int total = 0; for (node = hash_next (__objc_class_hash, NULL); node; node = hash_next (__objc_class_hash, node)) { - Class_t class1 = node->value; + Class* class1 = node->value; total += (class1->cache->mask)*sizeof(struct objc_bucket); total += sizeof(struct objc_cache); } diff --git a/gcc/objc/init.c b/gcc/objc/init.c index c42715c..17a650c 100644 --- a/gcc/objc/init.c +++ b/gcc/objc/init.c @@ -44,7 +44,7 @@ static void init_check_module_version(Module_t); static void __objc_init_protocols (struct objc_protocol_list* protos); /* Add protocol to class */ -static void __objc_class_add_protocols (Class_t, struct objc_protocol_list*); +static void __objc_class_add_protocols (Class*, struct objc_protocol_list*); /* Is all categories/classes resolved? */ BOOL __objc_dangling_categories = NO; @@ -95,7 +95,7 @@ __objc_exec_class (Module_t module) DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name); for (i = 0; i < symtab->cls_def_cnt; ++i) { - Class_t class = (Class_t) symtab->defs[i]; + Class* class = (Class*) symtab->defs[i]; /* Make sure we have what we think. */ assert (CLS_ISCLASS(class)); @@ -107,7 +107,7 @@ __objc_exec_class (Module_t module) /* Register all of the selectors in the class and meta class. */ __objc_register_selectors_from_class (class); - __objc_register_selectors_from_class ((Class_t) class->class_pointer); + __objc_register_selectors_from_class ((Class*) class->class_pointer); /* Install the fake dispatch tables */ __objc_install_premature_dtable(class); @@ -125,7 +125,7 @@ __objc_exec_class (Module_t module) for (i = 0; i < symtab->cat_def_cnt; ++i) { Category_t category = symtab->defs[i + symtab->cls_def_cnt]; - Class_t class = objc_lookup_class (category->class_name); + Class* class = objc_lookup_class (category->class_name); /* If the class for the category exists then append its methods. */ if (class) @@ -141,7 +141,7 @@ __objc_exec_class (Module_t module) /* Do class methods. */ if (category->class_methods) - class_add_method_list ((Class_t) class->class_pointer, + class_add_method_list ((Class*) class->class_pointer, category->class_methods); if (category->protocols) @@ -166,7 +166,7 @@ __objc_exec_class (Module_t module) *cell && ((cell = &(*cell)->tail))) { Category_t category = (*cell)->head; - Class_t class = objc_lookup_class (category->class_name); + Class* class = objc_lookup_class (category->class_name); if (class) { @@ -179,7 +179,7 @@ __objc_exec_class (Module_t module) class_add_method_list (class, category->instance_methods); if (category->class_methods) - class_add_method_list ((Class_t) class->class_pointer, + class_add_method_list ((Class*) class->class_pointer, category->class_methods); if (category->protocols) @@ -221,7 +221,7 @@ static void __objc_init_protocols (struct objc_protocol_list* protos) { int i; - Class_t proto_class; + Class* proto_class; if (! protos) return; @@ -251,7 +251,7 @@ __objc_init_protocols (struct objc_protocol_list* protos) } } -static void __objc_class_add_protocols (Class_t class, +static void __objc_class_add_protocols (Class* class, struct objc_protocol_list* protos) { /* Well... */ diff --git a/gcc/objc/misc.c b/gcc/objc/misc.c index 54bd6a2..b9b64ac 100644 --- a/gcc/objc/misc.c +++ b/gcc/objc/misc.c @@ -29,7 +29,7 @@ You should have received a copy of the GNU General Public License along with void objc_error(id object, const char* fmt, va_list); void (*_objc_error)(id, const char*, va_list) = objc_error; -/* id (*_objc_object_alloc)(Class_t) = 0; */ +/* id (*_objc_object_alloc)(Class*) = 0; */ /* id (*_objc_object_dispose)(id) = 0; */ /* id (*_objc_object_copy)(id) = 0; */ diff --git a/gcc/objc/objc-api.h b/gcc/objc/objc-api.h index 8a0370f..2cbe933 100644 --- a/gcc/objc/objc-api.h +++ b/gcc/objc/objc-api.h @@ -28,35 +28,33 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "objc/objc.h" #include "objc/hash.h" -#include +#include static const ARGSIZE = 96; /* for `method_get_argsize()' */ -extern void (*_objc_error)(id object, const char *format, va_list args); - /* ** This is a hook which is called by objc_lookup_class and ** objc_get_class if the runtime is not able to find the class. ** 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_t (*_objc_lookup_class)(const char *name); +extern Class* (*_objc_lookup_class)(const char *name); -extern id (*_objc_object_alloc)(Class_t 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_t class, SEL aSel); +Method_t class_get_class_method(MetaClass* class, SEL aSel); -Method_t class_get_instance_method(Class_t class, SEL aSel); +Method_t class_get_instance_method(Class* class, SEL aSel); -Class_t class_pose_as(Class_t impostor, Class_t superclass); +Class* class_pose_as(Class* impostor, Class* superclass); -Class_t objc_get_class(const char *name); +Class* objc_get_class(const char *name); -Class_t objc_lookup_class(const char *name); +Class* objc_lookup_class(const char *name); const char *sel_get_name(SEL selector); @@ -67,7 +65,7 @@ SEL sel_register_name(const char *name); BOOL sel_is_mapped (SEL aSel); extern inline id -class_create_instance(Class_t class) +class_create_instance(Class* class) { id new = nil; if (CLS_ISCLASS(class)) @@ -80,50 +78,50 @@ class_create_instance(Class_t class) } static inline const char * -class_get_class_name(Class_t 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_t class) +class_get_instance_size(Class* class) { return CLS_ISCLASS(class)?class->instance_size:0; } -static inline MetaClass_t -class_get_meta_class(Class_t class) +static inline MetaClass* +class_get_meta_class(Class* class) { return CLS_ISCLASS(class)?class->class_pointer:Nil; } -static inline Class_t -class_get_super_class(Class_t 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_t class) +class_get_version(Class* class) { return CLS_ISCLASS(class)?class->version:-1; } static inline BOOL -class_is_class(Class_t class) +class_is_class(Class* class) { return CLS_ISCLASS(class); } static inline BOOL -class_is_meta_class(Class_t class) +class_is_meta_class(Class* class) { return CLS_ISMETA(class); } static inline void -class_set_version(Class_t class, long version) +class_set_version(Class* class, long version) { if (CLS_ISCLASS(class)) class->version = version; @@ -141,7 +139,7 @@ method_get_imp(Method_t method) return (method!=METHOD_NULL)?method->method_imp:(IMP)0; } -IMP get_imp (Class_t class, SEL sel); +IMP get_imp (Class* class, SEL sel); extern inline id object_copy(id object) @@ -174,14 +172,14 @@ object_dispose(id object) return nil; } -static inline Class_t +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_t)object + ? (Class*)object : Nil)) : Nil); } @@ -191,11 +189,11 @@ object_get_class_name(id object) { return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) ?object->class_pointer->name - :((Class_t)object)->name) + :((Class*)object)->name) :"Nil"); } -static inline MetaClass_t +static inline MetaClass* object_get_meta_class(id object) { return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) @@ -206,14 +204,14 @@ object_get_meta_class(id object) :Nil); } -static inline Class_t +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_t)object)->super_class + ?((Class*)object)->super_class :Nil)) :Nil); } @@ -221,7 +219,7 @@ object_get_super_class static inline BOOL object_is_class(id object) { - return CLS_ISCLASS((Class_t)object); + return CLS_ISCLASS((Class*)object); } static inline BOOL @@ -233,7 +231,7 @@ object_is_instance(id object) static inline BOOL object_is_meta_class(id object) { - return CLS_ISMETA((Class_t)object); + return CLS_ISMETA((Class*)object); } diff --git a/gcc/objc/objc.h b/gcc/objc/objc.h index c06a013..d5eace3 100644 --- a/gcc/objc/objc.h +++ b/gcc/objc/objc.h @@ -53,29 +53,12 @@ extern const char* __objc_sparse_lookup_id; extern const char* __objc_hash_lookup_id; #endif +#ifndef __object_INCLUDE_GNU -#include -#ifdef IN_GCC -#include -#else -#include -#endif - -#define nil (id)0 /* id of Nil instance */ -#define Nil (Class_t)0 /* id of Nil class */ -typedef char *STR; /* String alias */ - - /* Boolean typedefs */ typedef char BOOL; #define YES (BOOL)1 #define NO (BOOL)0 - -/* For functions which return Method_t */ -#define METHOD_NULL (Method_t)0 - - - /* ** Definition of a selector. Selectors are really of type unsigned int. ** The runtime does this mapping from SEL's to names internally in the @@ -94,6 +77,30 @@ typedef struct objc_object { typedef id (*IMP)(id, SEL, ...); /* +** The compiler generates one of these structures for each class. +** +** This structure is the definition for meta classes. By definition a meta +** class is the class's class. Its most relevant contribution is that its +** method list contain the class's factory methods. +** +** This structure is generated by the compiler in the executable and used by +** the run-time during normal messaging operations. Therefore some members +** change type. The compiler generates "char* const" and places a string in +** the following member variables: class_pointer and super_class. +*/ +typedef struct objc_class MetaClass; +typedef struct objc_class Class; + +#define nil (id)0 /* id of Nil instance */ +#define Nil (Class*)0 /* id of Nil class */ +typedef char *STR; /* String alias */ + +#endif /* __object_INCLUDE_GNU */ + +/* For functions which return Method_t */ +#define METHOD_NULL (Method_t)0 + /* Boolean typedefs */ +/* ** Method descriptor returned by introspective Object methods. ** This is really just the first part of the more complete objc_method ** structure defined below and used internally by the runtime. @@ -159,7 +166,7 @@ typedef struct objc_symtab { compiled (defined) in the module. */ void *defs[1]; /* Variable array of pointers. - cls_def_cnt of type Class_t + cls_def_cnt of type Class* followed by cat_def_cnt of type Category_t. */ } Symtab, *Symtab_t; @@ -272,20 +279,6 @@ struct objc_cache { /* ** The compiler generates one of these structures for each class. -** -** This structure is the definition for meta classes. By definition a meta -** class is the class's class. Its most relevant contribution is that its -** method list contain the class's factory methods. -** -** This structure is generated by the compiler in the executable and used by -** the run-time during normal messaging operations. Therefore some members -** change type. The compiler generates "char* const" and places a string in -** the following member variables: class_pointer and super_class. -*/ -typedef struct objc_class *MetaClass_t; - -/* -** The compiler generates one of these structures for each class. ** ** This structure is the definition for classes. ** @@ -295,7 +288,7 @@ typedef struct objc_class *MetaClass_t; ** the following member variables: super_class. */ struct objc_class { - MetaClass_t class_pointer; /* Pointer to the class's + MetaClass* class_pointer; /* Pointer to the class's meta class. */ struct objc_class* super_class; /* Pointer to the super class. NULL for class @@ -331,10 +324,8 @@ struct objc_class { struct objc_protocol_list *protocols; /* Protocols conformed to */ }; -#define Class struct objc_class -#define Class_t Class* -typedef struct objc_class MetaClass; +#ifndef __object_INCLUDE_GNU /* Protocol support */ #ifndef __OBJC__ @@ -349,13 +340,14 @@ typedef struct objc_protocol { @class Protocol; #endif +#endif + struct objc_protocol_list { struct objc_protocol_list *next; int count; Protocol *list[1]; }; - /* ** This is used to assure consistent access to the info field of ** classes @@ -368,12 +360,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_t */ +/* 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_t */ +/* The structure is of type Class* */ #define _CLS_CLASS 0x1L #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS)) @@ -428,7 +420,9 @@ typedef struct objc_category { ** Well... */ +#ifndef __object_INCLUDE_GNU typedef struct objc_typed_stream TypedStream; +#endif /* ** Structure used when a message is send to a class's super class. The @@ -438,7 +432,7 @@ typedef struct objc_typed_stream TypedStream; typedef struct objc_super { id self; /* Id of the object sending the message. */ - Class_t class; /* Object's super class. */ + Class* class; /* Object's super class. */ } Super, *Super_t; IMP objc_msg_lookup_super(Super_t super, SEL sel); @@ -446,7 +440,9 @@ IMP objc_msg_lookup_super(Super_t super, SEL sel); typedef void* retval_t; /* return value */ typedef void(*apply_t)(void); /* function pointer */ -#if defined(REG_ARGS) || defined(STACK_ARGS) +#ifndef __object_INCLUDE_GNU + +#if defined(REG_ARGS) || defined(STACK_ARGS) typedef struct { char* arg_pointer; @@ -471,6 +467,7 @@ typedef struct { typedef void* arglist_t; #endif +#endif /* not __object_INCLUDE_GNU */ retval_t objc_msg_sendv(id, SEL, size_t, arglist_t); diff --git a/gcc/objc/objects.c b/gcc/objc/objects.c index 5463f6e..8bc922b 100644 --- a/gcc/objc/objects.c +++ b/gcc/objc/objects.c @@ -26,16 +26,16 @@ You should have received a copy of the GNU General Public License along with #include "runtime.h" /* the kitchen sink */ -id __objc_object_alloc(Class_t); +id __objc_object_alloc(Class*); id __objc_object_dispose(id); id __objc_object_copy(id); -id (*_objc_object_alloc)(Class_t) = __objc_object_alloc; +id (*_objc_object_alloc)(Class*) = __objc_object_alloc; id (*_objc_object_dispose)(id) = __objc_object_dispose; id (*_objc_object_copy)(id) = __objc_object_copy; id -class_create_instance(Class_t class) +class_create_instance(Class* class) { id res = (*_objc_object_alloc)(class); res->class_pointer = class; @@ -54,7 +54,7 @@ object_dispose(id object) return (*_objc_object_dispose)(object); } -id __objc_object_alloc(Class_t class) +id __objc_object_alloc(Class* class) { return (id)__objc_xmalloc(class->instance_size); } diff --git a/gcc/objc/runtime.h b/gcc/objc/runtime.h index e61d4d2..ef6e572 100644 --- a/gcc/objc/runtime.h +++ b/gcc/objc/runtime.h @@ -41,15 +41,15 @@ You should have received a copy of the GNU General Public License along with #include "objc/hash.h" /* hash structures */ #include "objc/list.h" /* linear lists */ -extern void __objc_add_class_to_hash(Class_t); /* (objc-class.c) */ +extern void __objc_add_class_to_hash(Class*); /* (objc-class.c) */ extern void __objc_init_selector_tables(); /* (objc-sel.c) */ extern void __objc_init_class_tables(); /* (objc-class.c) */ extern void __objc_init_dispatch_tables(); /* (objc-dispatch.c) */ -extern void __objc_install_premature_dtable(Class_t); /* (objc-dispatch.c) */ +extern void __objc_install_premature_dtable(Class*); /* (objc-dispatch.c) */ extern void __objc_resolve_class_links(); /* (objc-class.c) */ -extern void __objc_register_selectors_from_class(Class_t); /* (objc-sel.c) */ -extern void __objc_update_dispatch_table_for_class (Class_t);/* (objc-msg.c) */ -extern void class_add_method_list(Class_t, MethodList_t); +extern void __objc_register_selectors_from_class(Class*); /* (objc-sel.c) */ +extern void __objc_update_dispatch_table_for_class (Class*);/* (objc-msg.c) */ +extern void class_add_method_list(Class*, MethodList_t); /* True when class links has been resolved */ extern BOOL __objc_class_links_resolved; diff --git a/gcc/objc/selector.c b/gcc/objc/selector.c index 6eb2e43..dfb8ba9 100644 --- a/gcc/objc/selector.c +++ b/gcc/objc/selector.c @@ -51,7 +51,7 @@ void __objc_init_selector_tables() /* This routine is given a class and records all of the methods in its class structure in the record table. */ void -__objc_register_selectors_from_class (Class_t class) +__objc_register_selectors_from_class (Class* class) { MethodList_t method_list; diff --git a/gcc/objc/sendmsg.c b/gcc/objc/sendmsg.c index bf38b67..b8ffed6 100644 --- a/gcc/objc/sendmsg.c +++ b/gcc/objc/sendmsg.c @@ -44,16 +44,16 @@ struct sarray* __objc_uninstalled_dtable = 0; #endif /* Send +initialize to class */ -static void __objc_send_initialize(Class_t); +static void __objc_send_initialize(Class*); -static void __objc_install_dispatch_table_for_class (Class_t); +static void __objc_install_dispatch_table_for_class (Class*); /* Forward declare some functions */ #ifdef OBJC_SPARSE_LOOKUP static void __objc_init_install_dtable(id, SEL); #endif static id __objc_missing_method(id, SEL, ...); -static Method_t search_for_method_in_hierarchy (Class_t class, SEL sel); +static Method_t search_for_method_in_hierarchy (Class* class, SEL sel); static Method_t search_for_method_in_list(MethodList_t list, SEL op); id nil_method(id, SEL, ...); @@ -65,7 +65,7 @@ nil_method(id receiver, SEL op, ...) /* Given a class and selector, return the selector's implementation. */ __inline__ IMP -get_imp (Class_t class, SEL sel) +get_imp (Class* class, SEL sel) { #ifdef OBJC_SPARSE_LOOKUP void* res = sarray_get (class->dtable, (size_t) sel); @@ -165,16 +165,16 @@ static void __objc_init_install_dtable(id receiver, SEL op) else { /* receiver is a class object */ - assert(CLS_ISCLASS((Class_t)receiver)); + assert(CLS_ISCLASS((Class*)receiver)); assert(CLS_ISMETA(receiver->class_pointer)); /* Install real dtable for factory methods */ __objc_install_dispatch_table_for_class (receiver->class_pointer); if(op != sel_get_uid ("initialize")) - __objc_send_initialize((Class_t)receiver); + __objc_send_initialize((Class*)receiver); else - CLS_SETINITIALIZED((Class_t)receiver); + CLS_SETINITIALIZED((Class*)receiver); } allready_initialized: @@ -191,7 +191,7 @@ allready_initialized: /* Install dummy table for class which causes the first message to that class (or instances hereof) to be initialized properly */ -void __objc_install_premature_dtable(Class_t class) +void __objc_install_premature_dtable(Class* class) { #ifdef OBJC_SPARSE_LOOKUP assert(__objc_uninstalled_dtable); @@ -202,7 +202,7 @@ void __objc_install_premature_dtable(Class_t class) } /* Send +initialize to class if not already done */ -static void __objc_send_initialize(Class_t class) +static void __objc_send_initialize(Class* class) { Method_t m; @@ -229,10 +229,10 @@ static void __objc_send_initialize(Class_t class) } static void -__objc_install_dispatch_table_for_class (Class_t class) +__objc_install_dispatch_table_for_class (Class* class) { #ifdef OBJC_SPARSE_LOOKUP - Class_t super; + Class* super; MethodList_t mlist; int counter; @@ -270,9 +270,9 @@ __objc_install_dispatch_table_for_class (Class_t class) #endif } -void __objc_update_dispatch_table_for_class (Class_t class) +void __objc_update_dispatch_table_for_class (Class* class) { - Class_t next; + Class* next; #ifdef OBJC_SPARSE_LOOKUP struct sarray* save; #else @@ -313,7 +313,7 @@ void __objc_update_dispatch_table_for_class (Class_t class) methods installed rightaway, and their selectors are made into SEL's by the function __objc_register_selectors_from_class. */ void -class_add_method_list (Class_t class, MethodList_t list) +class_add_method_list (Class* class, MethodList_t list) { int i; @@ -348,13 +348,13 @@ class_add_method_list (Class_t class, MethodList_t list) Method_t -class_get_instance_method(Class_t class, SEL op) +class_get_instance_method(Class* class, SEL op) { return search_for_method_in_hierarchy(class, op); } Method_t -class_get_class_method(MetaClass_t class, SEL op) +class_get_class_method(MetaClass* class, SEL op) { return search_for_method_in_hierarchy(class, op); } @@ -365,10 +365,10 @@ class_get_class_method(MetaClass_t class, SEL op) otherwise. */ static Method_t -search_for_method_in_hierarchy (Class_t cls, SEL sel) +search_for_method_in_hierarchy (Class* cls, SEL sel) { Method_t method = NULL; - Class_t class; + Class* class; if (! sel_is_mapped (sel)) return NULL; @@ -550,7 +550,7 @@ __objc_cache_insert(Cache_t cache, SEL op, IMP imp) } void* -__objc_cache_miss(Class_t class, SEL op) +__objc_cache_miss(Class* class, SEL op) { Method_t m; Cache_t cache = class->cache; -- 2.7.4