Annotation of gcc/objc/objc.h, revision 1.1.1.2

1.1       root        1: /* Basic data types for Objective C.
1.1.1.2 ! root        2:    Copyright (C) 1993 Free Software Foundation, Inc.
1.1       root        3: 
                      4: This file is part of GNU CC.
                      5: 
                      6: GNU CC is free software; you can redistribute it and/or modify
                      7: it under the terms of the GNU General Public License as published by
                      8: the Free Software Foundation; either version 2, or (at your option)
                      9: any later version.
                     10: 
                     11: GNU CC is distributed in the hope that it will be useful,
                     12: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     14: GNU General Public License for more details.
                     15: 
                     16: You should have received a copy of the GNU General Public License
                     17: along with GNU CC; see the file COPYING.  If not, write to
                     18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     19: 
                     20: /* As a special exception, if you link this library with files
                     21:    compiled with GCC to produce an executable, this does not cause
                     22:    the resulting executable to be covered by the GNU General Public License.
                     23:    This exception does not however invalidate any other reasons why
                     24:    the executable file might be covered by the GNU General Public License.  */
                     25: 
                     26: #ifndef __objc_INCLUDE_GNU
                     27: #define __objc_INCLUDE_GNU
                     28: 
                     29: #ifdef __cplusplus
                     30: extern "C" {
                     31: #endif
                     32: 
1.1.1.2 ! root       33: #ifdef IN_GCC
        !            34: #include "gstddef.h"
        !            35: #else
        !            36: #include "stddef.h"
        !            37: #endif
1.1       root       38: 
1.1.1.2 ! root       39: /*
        !            40: ** Definition of the boolean type.  
        !            41: */
1.1       root       42: typedef char  BOOL;
                     43: #define YES   (BOOL)1
                     44: #define NO    (BOOL)0
                     45: 
1.1.1.2 ! root       46: /*
        !            47: ** Definition of a selector.  Selectors are really of type unsigned int.
        !            48: ** The runtime does this mapping from SEL's to names internally in the
        !            49: ** sel_... operations.  You should never use the fact that it is actually
        !            50: ** an integer, since other Objective-C implementations use other conventions.
        !            51: */
1.1       root       52: typedef void* SEL;
                     53: 
1.1.1.2 ! root       54: /*
        !            55: ** ObjC uses this typedef for untyped instances.
        !            56: */
1.1       root       57: typedef struct objc_object {
                     58:   struct objc_class*  class_pointer;
                     59: } *id;
                     60: 
                     61: /*
1.1.1.2 ! root       62: ** Definition of method type.  When retrieving the implementation of a
        !            63: ** method, this is type of the pointer returned
        !            64: */
        !            65: typedef id (*IMP)(id, SEL, ...); 
1.1       root       66: 
                     67: /*
1.1.1.2 ! root       68: ** More simple types...
        !            69: */
        !            70: #define nil (id)0                               /* id of Nil instance */
        !            71: #define Nil (Class*)0                          /* id of Nil class */
        !            72: typedef char *STR;                              /* String alias */
1.1       root       73: 
                     74: /*
1.1.1.2 ! root       75: ** The compiler generates one of these structures for each class.  
        !            76: ** 
        !            77: ** This structure is the definition for classes. 
        !            78: ** 
        !            79: ** This structure is generated by the compiler in the executable and used by
        !            80: ** the run-time during normal messaging operations.  Therefore some members
        !            81: ** change type. The compiler generates "char* const" and places a string in
        !            82: ** the following member variables:  super_class. 
        !            83: */
        !            84: typedef struct objc_class MetaClass;
        !            85: typedef struct objc_class Class;
        !            86: struct objc_class {     
        !            87:   MetaClass*         class_pointer;          /* Pointer to the class's
1.1       root       88:                                                 meta class. */
                     89:   struct objc_class*  super_class;            /* Pointer to the super 
                     90:                                                 class. NULL for class 
                     91:                                                 Object. */
                     92:   const char*         name;                   /* Name of the class. */
                     93:   long                version;                /* Unknown. */
1.1.1.2 ! root       94:   unsigned long       info;                   /* Bit mask.  See class masks 
1.1       root       95:                                                 defined above. */
                     96:   long                instance_size;          /* Size in bytes of the class.  
                     97:                                                 The sum of the class definition 
                     98:                                                 and all super class 
                     99:                                                 definitions. */
1.1.1.2 ! root      100:   struct objc_ivar_list* ivars;               /* Pointer to a structure that
1.1       root      101:                                                 describes the instance 
                    102:                                                 variables in the class
                    103:                                                 definition.  NULL indicates
                    104:                                                 no instance variables.  Does
                    105:                                                 not include super class
                    106:                                                 variables. */
1.1.1.2 ! root      107:   struct objc_method_list*  methods;          /* Linked list of instance
1.1       root      108:                                                 methods defined for the 
                    109:                                                 class. */
1.1.1.2 ! root      110:   struct sarray *    dtable;                  /* Pointer to instance 
        !           111:                                                 method dispatch table. */  
        !           112:   struct objc_class* subclass_list;           /* Subclasses */
        !           113:   struct objc_class* sibling_class;
        !           114: 
        !           115:   struct objc_protocol_list *protocols;              /* Protocols conformed to */
        !           116: };
        !           117: 
        !           118: #ifndef __OBJC__
        !           119: typedef struct objc_protocol {
        !           120:   struct objc_class* class_pointer;
        !           121:   char *protocol_name;
        !           122:   struct objc_protocol_list *protocol_list;
        !           123:   struct objc_method_description_list *instance_methods, *class_methods; 
        !           124: } Protocol; 
1.1       root      125: 
1.1.1.2 ! root      126: #else
1.1       root      127: 
1.1.1.2 ! root      128: @class Protocol;
        !           129: #endif 
1.1       root      130: 
1.1.1.2 ! root      131: typedef void* retval_t;                /* return value */
        !           132: typedef void(*apply_t)(void);  /* function pointer */
1.1       root      133: 
1.1.1.2 ! root      134: #if defined(REG_ARGS) || defined(STACK_ARGS) 
1.1       root      135: 
1.1.1.2 ! root      136: typedef struct {
        !           137:   char* arg_pointer;
        !           138: #ifdef STRUCT_RETURN
        !           139:   void* struct_return;
        !           140: #endif
        !           141: #ifdef REG_ARGS
        !           142:   void* regs[2];
        !           143: #endif
        !           144: } *arglist_t;
1.1       root      145: 
1.1.1.2 ! root      146: #ifdef REG_ARGS
        !           147: #define __objc_frame_receiver(FRAME)  (FRAME)->regs[0]
        !           148: #define __objc_frame_selector(FRAME)  ((SEL)(FRAME)->regs[1])
1.1       root      149: 
1.1.1.2 ! root      150: #else
        !           151: #define __objc_frame_receiver(FRAME) ((id*)(FRAME)->arg_pointer)[0]
        !           152: #define __objc_frame_selector(FRAME) ((SEL*)(FRAME)->arg_pointer)[1]
        !           153: #endif
        !           154: #else
1.1       root      155: 
1.1.1.2 ! root      156: typedef void* arglist_t;
1.1       root      157: 
1.1.1.2 ! root      158: #endif
        !           159: 
        !           160: #if defined(__OBJC__) 
        !           161: 
        !           162: #include "objc/sarray.h"
        !           163: 
        !           164: static id nil_method(id rcv, SEL op, ...) { return rcv; }
        !           165: 
        !           166: extern __inline__ IMP
        !           167: objc_msg_lookup(id receiver, SEL op)
        !           168: {
        !           169:   if(receiver)
        !           170:     return sarray_get(receiver->class_pointer->dtable, (size_t) op);
        !           171:   else
        !           172:     return nil_method;
1.1       root      173: }
1.1.1.2 ! root      174: 
        !           175: #else
        !           176: 
        !           177: IMP objc_msg_lookup(id receiver, SEL op);
        !           178: 
1.1       root      179: #endif
                    180: 
1.1.1.2 ! root      181: #ifdef __cplusplus
        !           182: }
        !           183: #endif
1.1       root      184: 
                    185: #endif /* not __objc_INCLUDE_GNU */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.