Commit e35ec852 by Richard Kenner

Changed Class * to Class in order to match NEXTSTEP and OpenStep runtime.

Changed Class * to Class in order to match NEXTSTEP and OpenStep
runtime.
(objc_static_instances): New struct to record static instances of a certain
class.
(objc_module): New tag STATICS to point to the table of objc_statics_instances.

From-SVN: r9493
parent 89f0bef3
/* GNU Objective-C Runtime API. /* 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. This file is part of GNU CC.
...@@ -97,12 +97,22 @@ typedef struct objc_symtab { ...@@ -97,12 +97,22 @@ typedef struct objc_symtab {
compiled (defined) in the compiled (defined) in the
module. */ module. */
void *defs[1]; /* Variable array of pointers. 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 followed by cat_def_cnt of
type Category_t. */ type Category_t. */
} Symtab, *Symtab_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 ** The compiler generates one of these structures for each module that
** composes the executable (eg main.m). ** composes the executable (eg main.m).
...@@ -118,6 +128,10 @@ typedef struct objc_module { ...@@ -118,6 +128,10 @@ typedef struct objc_module {
const char* name; /* Name of the file where the const char* name; /* Name of the file where the
module was generated. The module was generated. The
name includes the path. */ 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 Symtab_t symtab; /* Pointer to the Symtab of
the module. The Symtab the module. The Symtab
holds an array of pointers to holds an array of pointers to
...@@ -203,12 +217,12 @@ struct objc_protocol_list { ...@@ -203,12 +217,12 @@ struct objc_protocol_list {
#define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask) #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
#define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= 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_META 0x2L
#define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META)) #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_CLASS 0x1L
#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS)) #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
...@@ -268,7 +282,7 @@ typedef struct objc_category { ...@@ -268,7 +282,7 @@ typedef struct objc_category {
typedef struct objc_super { typedef struct objc_super {
id self; /* Id of the object sending id self; /* Id of the object sending
the message. */ the message. */
Class* class; /* Object's super class. */ Class class; /* Object's super class. */
} Super, *Super_t; } Super, *Super_t;
IMP objc_msg_lookup_super(Super_t super, SEL sel); IMP objc_msg_lookup_super(Super_t super, SEL sel);
...@@ -283,25 +297,25 @@ retval_t objc_msg_sendv(id, SEL, arglist_t); ...@@ -283,25 +297,25 @@ retval_t objc_msg_sendv(id, SEL, arglist_t);
** This may e.g. try to load in the class using dynamic loading. ** 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. ** 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);
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_copy)(id object);
extern id (*_objc_object_dispose)(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); Class objc_next_class(void **enum_state);
const char *sel_get_name(SEL selector); const char *sel_get_name(SEL selector);
...@@ -320,53 +334,53 @@ SEL sel_register_typed_name(const char *name, const char*type); ...@@ -320,53 +334,53 @@ SEL sel_register_typed_name(const char *name, const char*type);
BOOL sel_is_mapped (SEL aSel); BOOL sel_is_mapped (SEL aSel);
extern id class_create_instance(Class* class); extern id class_create_instance(Class class);
static inline const char * 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); return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0);
} }
static inline long static inline long
class_get_instance_size(Class* class) class_get_instance_size(Class class)
{ {
return CLS_ISCLASS(class)?class->instance_size:0; return CLS_ISCLASS(class)?class->instance_size:0;
} }
static inline MetaClass* static inline MetaClass
class_get_meta_class(Class* class) class_get_meta_class(Class class)
{ {
return CLS_ISCLASS(class)?class->class_pointer:Nil; return CLS_ISCLASS(class)?class->class_pointer:Nil;
} }
static inline Class* static inline Class
class_get_super_class(Class* class) class_get_super_class(Class class)
{ {
return CLS_ISCLASS(class)?class->super_class:Nil; return CLS_ISCLASS(class)?class->super_class:Nil;
} }
static inline int static inline int
class_get_version(Class* class) class_get_version(Class class)
{ {
return CLS_ISCLASS(class)?class->version:-1; return CLS_ISCLASS(class)?class->version:-1;
} }
static inline BOOL static inline BOOL
class_is_class(Class* class) class_is_class(Class class)
{ {
return CLS_ISCLASS(class); return CLS_ISCLASS(class);
} }
static inline BOOL static inline BOOL
class_is_meta_class(Class* class) class_is_meta_class(Class class)
{ {
return CLS_ISMETA(class); return CLS_ISMETA(class);
} }
static inline void static inline void
class_set_version(Class* class, long version) class_set_version(Class class, long version)
{ {
if (CLS_ISCLASS(class)) if (CLS_ISCLASS(class))
class->version = version; class->version = version;
...@@ -378,20 +392,20 @@ method_get_imp(Method_t method) ...@@ -378,20 +392,20 @@ method_get_imp(Method_t method)
return (method!=METHOD_NULL)?method->method_imp:(IMP)0; 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_copy(id object);
id object_dispose(id object); id object_dispose(id object);
static inline Class* static inline Class
object_get_class(id object) object_get_class(id object)
{ {
return ((object!=nil) return ((object!=nil)
? (CLS_ISCLASS(object->class_pointer) ? (CLS_ISCLASS(object->class_pointer)
? object->class_pointer ? object->class_pointer
: (CLS_ISMETA(object->class_pointer) : (CLS_ISMETA(object->class_pointer)
? (Class*)object ? (Class)object
: Nil)) : Nil))
: Nil); : Nil);
} }
...@@ -401,11 +415,11 @@ object_get_class_name(id object) ...@@ -401,11 +415,11 @@ object_get_class_name(id object)
{ {
return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
?object->class_pointer->name ?object->class_pointer->name
:((Class*)object)->name) :((Class)object)->name)
:"Nil"); :"Nil");
} }
static inline MetaClass* static inline MetaClass
object_get_meta_class(id object) object_get_meta_class(id object)
{ {
return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
...@@ -416,14 +430,14 @@ object_get_meta_class(id object) ...@@ -416,14 +430,14 @@ object_get_meta_class(id object)
:Nil); :Nil);
} }
static inline Class* static inline Class
object_get_super_class object_get_super_class
(id object) (id object)
{ {
return ((object!=nil)?(CLS_ISCLASS(object->class_pointer) return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
?object->class_pointer->super_class ?object->class_pointer->super_class
:(CLS_ISMETA(object->class_pointer) :(CLS_ISMETA(object->class_pointer)
?((Class*)object)->super_class ?((Class)object)->super_class
:Nil)) :Nil))
:Nil); :Nil);
} }
...@@ -431,7 +445,7 @@ object_get_super_class ...@@ -431,7 +445,7 @@ object_get_super_class
static inline BOOL static inline BOOL
object_is_class(id object) object_is_class(id object)
{ {
return CLS_ISCLASS((Class*)object); return CLS_ISCLASS((Class)object);
} }
static inline BOOL static inline BOOL
...@@ -443,7 +457,7 @@ object_is_instance(id object) ...@@ -443,7 +457,7 @@ object_is_instance(id object)
static inline BOOL static inline BOOL
object_is_meta_class(id object) object_is_meta_class(id object)
{ {
return CLS_ISMETA((Class*)object); return CLS_ISMETA((Class)object);
} }
#endif /* not __objc_api_INCLUDE_GNU */ #endif /* not __objc_api_INCLUDE_GNU */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment