--- gcc/objc/objc.h 2018/04/24 18:10:16 1.1.1.2 +++ gcc/objc/objc.h 2018/04/24 18:26:47 1.1.1.5 @@ -1,5 +1,5 @@ /* Basic data types for Objective C. - 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 @@ GNU General Public License for more deta 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 @@ -30,26 +31,34 @@ the Free Software Foundation, 675 Mass A extern "C" { #endif -#ifdef IN_GCC -#include "gstddef.h" -#else -#include "stddef.h" -#endif +#include /* ** Definition of the boolean type. */ -typedef char BOOL; +typedef unsigned char BOOL; #define YES (BOOL)1 #define NO (BOOL)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 -** sel_... operations. You should never use the fact that it is actually -** an integer, since other Objective-C implementations use other conventions. +** Definition of a selector. Selectors themselves are not unique, but +** the sel_id is a unique identifier. */ -typedef void* SEL; +typedef const struct objc_selector +{ + void *sel_id; + const char *sel_types; +} *SEL; + +inline static BOOL +sel_eq (SEL s1, SEL s2) +{ + if (s1 == 0 || s2 == 0) + return s1 == s2; + else + return s1->sel_id == s2->sel_id; +} + /* ** ObjC uses this typedef for untyped instances. @@ -68,7 +77,7 @@ typedef id (*IMP)(id, SEL, ...); ** More simple types... */ #define nil (id)0 /* id of Nil instance */ -#define Nil (Class*)0 /* id of Nil class */ +#define Nil (Class)0 /* id of Nil class */ typedef char *STR; /* String alias */ /* @@ -81,10 +90,10 @@ typedef char *STR; ** change type. The compiler generates "char* const" and places a string in ** the following member variables: super_class. */ -typedef struct objc_class MetaClass; -typedef struct objc_class Class; +typedef struct objc_class *MetaClass; +typedef struct objc_class *Class; struct objc_class { - MetaClass* 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 @@ -123,61 +132,20 @@ typedef struct objc_protocol { struct objc_method_description_list *instance_methods, *class_methods; } Protocol; -#else - +#else /* __OBJC__ */ @class Protocol; #endif typedef void* retval_t; /* return value */ typedef void(*apply_t)(void); /* function pointer */ +typedef union { + char *arg_ptr; + char arg_regs[sizeof (char*)]; +} *arglist_t; /* argument frame */ -#if defined(REG_ARGS) || defined(STACK_ARGS) - -typedef struct { - char* arg_pointer; -#ifdef STRUCT_RETURN - void* struct_return; -#endif -#ifdef REG_ARGS - void* regs[2]; -#endif -} *arglist_t; - -#ifdef REG_ARGS -#define __objc_frame_receiver(FRAME) (FRAME)->regs[0] -#define __objc_frame_selector(FRAME) ((SEL)(FRAME)->regs[1]) - -#else -#define __objc_frame_receiver(FRAME) ((id*)(FRAME)->arg_pointer)[0] -#define __objc_frame_selector(FRAME) ((SEL*)(FRAME)->arg_pointer)[1] -#endif -#else - -typedef void* arglist_t; - -#endif - -#if defined(__OBJC__) - -#include "objc/sarray.h" - -static id nil_method(id rcv, SEL op, ...) { return rcv; } - -extern __inline__ IMP -objc_msg_lookup(id receiver, SEL op) -{ - if(receiver) - return sarray_get(receiver->class_pointer->dtable, (size_t) op); - else - return nil_method; -} - -#else IMP objc_msg_lookup(id receiver, SEL op); -#endif - #ifdef __cplusplus } #endif