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

1.1     ! root        1: /* Basic data types for Objective C.
        !             2:    Copyright (C) 1992 Free Software Foundation, Inc.
        !             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: 
        !            27: #ifndef __objc_INCLUDE_GNU
        !            28: #define __objc_INCLUDE_GNU
        !            29: 
        !            30: /* If someone is using a c++ compiler then adjust the types in the
        !            31:    file back to C.  */
        !            32: #ifdef __cplusplus
        !            33: extern "C" {
        !            34: #endif
        !            35: 
        !            36: #include  "record.h"
        !            37: 
        !            38: 
        !            39: #define nil (id)0                               /* id of Nil instance */
        !            40: #define Nil (Class_t)0                          /* id of Nil class */
        !            41: typedef char* STR;                              /* String alias */
        !            42: 
        !            43:                                                 /* Boolean typedefs */
        !            44: typedef char  BOOL;
        !            45: #define YES   (BOOL)1
        !            46: #define NO    (BOOL)0
        !            47: 
        !            48: /* Definition of a selector.  Selectors are really of type char*. The
        !            49:    run-time hashes the string's address to locate the method.  If the
        !            50:    method isn't in the hash table then a search is made through the
        !            51:    class hierarchy using strcmp to locate the method.  */
        !            52: #if 0
        !            53: typedef struct objc_selector*   SEL;
        !            54: #else
        !            55: typedef void* SEL;
        !            56: #endif
        !            57: 
        !            58: /* ObjC uses this typedef for untyped instances.  */
        !            59: 
        !            60: typedef struct objc_object {
        !            61:   struct objc_class*  class_pointer;
        !            62: } *id;
        !            63: 
        !            64: /* Prototype for method functions. */
        !            65: typedef id  (*IMP)(id, SEL, ...); 
        !            66: 
        !            67: /* Filer types used to describe Ivars and Methods.  */
        !            68: #define _C_ID       '@'
        !            69: #define _C_CLASS    '#'
        !            70: #define _C_SEL      ':'
        !            71: #define _C_CHR      'c'
        !            72: #define _C_UCHR     'C'
        !            73: #define _C_SHT      's'
        !            74: #define _C_USHT     'S'
        !            75: #define _C_INT      'i'
        !            76: #define _C_UINT     'I'
        !            77: #define _C_LNG      'l'
        !            78: #define _C_ULNG     'L'
        !            79: #define _C_FLT      'f'
        !            80: #define _C_DBL      'd'
        !            81: #define _C_BFLD     'b'
        !            82: #define _C_VOID     'v'
        !            83: #define _C_UNDEF    '?'
        !            84: #define _C_PTR      '^'
        !            85: #define _C_CHARPTR  '*'
        !            86: #define _C_ARY_B    '['
        !            87: #define _C_ARY_E    ']'
        !            88: #define _C_UNION_B  '('
        !            89: #define _C_UNION_E  ')'
        !            90: #define _C_STRUCT_B '{'
        !            91: #define _C_STRUCT_E '}'
        !            92: 
        !            93: /* These definitions are masks used with the "info" member variable in
        !            94:    the lass and meta class structures.  */
        !            95: #define CLS_CLASS         0x1L                  /* The structure is of type
        !            96:                                                   class (Class_t). */
        !            97: #define CLS_META          0x2L                  /* The structure is of type
        !            98:                                                   meta class (MetaClass_t). */
        !            99: #define CLS_INITIALIZED   0x4L                  /* Class is initialized. A
        !           100:                                                   +initialize method is the
        !           101:                                                   first message sent to a
        !           102:                                                   class.  It isn't guaranteed
        !           103:                                                   to be sent only once. */
        !           104: #define CLS_RTI           0x8L                  /* The class has been initialized
        !           105:                                                   within the run time library. */
        !           106: 
        !           107: /* Set this variable nonzero to print a line describing each
        !           108:    message that is sent.  */
        !           109: extern BOOL objc_trace;
        !           110: 
        !           111: 
        !           112: /*
        !           113:  * Whereas a Module (defined further down) is the root (typically) of a file,
        !           114:  * a Symtab is the root of the class and category definitions within the
        !           115:  * module.  
        !           116:  *
        !           117:  * A Symtab contains a variable length array of pointers to classes and
        !           118:  * categories  defined in the module. 
        !           119:  */
        !           120: typedef struct objc_symtab {
        !           121:   unsigned long sel_ref_cnt;                     /* Unknown. */
        !           122:   SEL       *refs;                              /* Unknown. */
        !           123:   unsigned short cls_def_cnt;                   /* Number of classes compiled
        !           124:                                                   (defined) in the module. */
        !           125:   unsigned short cat_def_cnt;                   /* Number of categories 
        !           126:                                                   compiled (defined) in the 
        !           127:                                                   module. */
        !           128:   void      *defs[1];                           /* Variable array of pointers.
        !           129:                                                   cls_def_cnt of type Class_t 
        !           130:                                                   followed by cat_def_cnt of
        !           131:                                                   type Category_t. */
        !           132: } Symtab,   *Symtab_t;
        !           133: 
        !           134: 
        !           135: /*
        !           136:  * The compiler generates one of these structures for each module that
        !           137:  * composes the executable (eg main.m).  
        !           138:  *
        !           139:  * This data structure is the root of the definition tree for the module.  
        !           140:  *
        !           141:  * A collect program runs between ld stages and creates a ObjC ctor array. 
        !           142:  * That array holds a pointer to each module structure of the executable. 
        !           143:  */
        !           144: typedef struct objc_module {
        !           145:   unsigned long version;                        /* Compiler revision. */
        !           146:   unsigned long size;                           /* sizeof(Module). */
        !           147:   const char* name;                             /* Name of the file where the 
        !           148:                                                   module was generated.   The 
        !           149:                                                   name includes the path. */
        !           150:   Symtab_t    symtab;                           /* Pointer to the Symtab of
        !           151:                                                   the module.  The Symtab
        !           152:                                                   holds an array of pointers to 
        !           153:                                                   the classes and categories 
        !           154:                                                   defined in the module. */
        !           155: } Module, *Module_t;
        !           156: 
        !           157: 
        !           158: /*
        !           159:  * The compiler generates one of these structures for a class that has
        !           160:  * instance variables defined in its specification. 
        !           161:  */
        !           162: typedef struct objc_ivar* Ivar_t;
        !           163: typedef struct objc_ivar_list {
        !           164:   int   ivar_count;                             /* Number of structures (Ivar) 
        !           165:                                                   contained in the list.  One
        !           166:                                                   structure per instance 
        !           167:                                                   variable defined in the
        !           168:                                                   class. */
        !           169:   struct objc_ivar {
        !           170:     const char* ivar_name;                      /* Name of the instance
        !           171:                                                   variable as entered in the
        !           172:                                                   class definition. */
        !           173:     const char* ivar_type;                      /* Description of the Ivar's
        !           174:                                                   type.  Useful for 
        !           175:                                                   debuggers. */
        !           176:     int         ivar_offset;                    /* Byte offset from the base 
        !           177:                                                   address of the instance 
        !           178:                                                   structure to the variable. */
        !           179: 
        !           180:   } ivar_list[1];                               /* Variable length 
        !           181:                                                   structure. */
        !           182: } IvarList, *IvarList_t;
        !           183: 
        !           184: 
        !           185: /*
        !           186:  * The compiler generates one (or more) of these structures for a class that
        !           187:  * has methods defined in its specification. 
        !           188:  *
        !           189:  * The implementation of a class can be broken into separate pieces in a file
        !           190:  * and categories can break them across modules. To handle this problem is a
        !           191:  * singly linked list of methods. 
        !           192:  */
        !           193: typedef struct objc_method Method;
        !           194: typedef Method* Method_t;
        !           195: typedef struct objc_method_list {
        !           196:   struct objc_method_list*  method_next;      /* This variable is used to link 
        !           197:                                                 a method list to another.  It 
        !           198:                                                 is a singly linked list. */
        !           199:   int             method_count;               /* Number of methods defined in 
        !           200:                                                 this structure. */
        !           201:   struct objc_method {
        !           202:     SEL         method_name;                  /* This variable is the method's 
        !           203:                                                 name.  It is a char*. 
        !           204:                                                   The unique integer passed to 
        !           205:                                                 objc_msgSend is a char* too.  
        !           206:                                                 It is compared against 
        !           207:                                                 method_name using strcmp. */
        !           208:     const char* method_types;                 /* Description of the method's
        !           209:                                                 parameter list.  Useful for
        !           210:                                                 debuggers. */
        !           211:     IMP         method_imp;                   /* Address of the method in the 
        !           212:                                                 executable. */
        !           213:   } method_list[1];                           /* Variable length 
        !           214:                                                 structure. */
        !           215: } MethodList, *MethodList_t;
        !           216: 
        !           217: 
        !           218: /*
        !           219:  * The compiler generates one of these structures for each class.  
        !           220:  *
        !           221:  * This structure is the definition for meta classes. By definition a meta
        !           222:  * class is the class's class.  Its most relevant contribution is that its
        !           223:  * method list contain the class's factory methods. 
        !           224:  *
        !           225:  * This structure is generated by the compiler in the executable and used by
        !           226:  * the run-time during normal messaging operations.  Therefore some members
        !           227:  * change type. The compiler generates "char* const" and places a string in
        !           228:  * the following member variables:  class_pointer and super_class. 
        !           229:  */
        !           230: typedef struct objc_metaClass {     
        !           231:   struct objc_metaClass*  class_pointer;      /* Pointer to Object meta class. */
        !           232:   struct objc_metaClass*  super_class;        /* Pointer to meta class's
        !           233:                                                 super class. NULL for 
        !           234:                                                 Object. */
        !           235:   const char*             name;               /* Name of the meta class. */
        !           236:   long                    version;            /* Unknown. */
        !           237:   long                    info;               /* Bit mask.  See class masks 
        !           238:                                                 defined above. */
        !           239:   long                    instance_size;      /* Always 0 except for Object.
        !           240:                                                 Should be ignored. */
        !           241:   IvarList_t              ivars;              /* Always NULL except for 
        !           242:                                                 Object.  Should be ignored. */
        !           243:   MethodList_t            methods;            /* Linked List of factory methods 
        !           244:                                                 for the class. */
        !           245:   struct record **        cache;              /* Pointer to factory method dispatch table. */
        !           246: } MetaClass, *MetaClass_t;
        !           247: 
        !           248: 
        !           249: /*
        !           250:  * The compiler generates one of these structures for each class.  
        !           251:  *
        !           252:  * This structure is the definition for classes. 
        !           253:  *
        !           254:  * This structure is generated by the compiler in the executable and used by
        !           255:  * the run-time during normal messaging operations.  Therefore some members
        !           256:  * change type. The compiler generates "char* const" and places a string in
        !           257:  * the following member variables:  super_class. 
        !           258:  */
        !           259: typedef struct objc_class {     
        !           260:   MetaClass_t         class_pointer;          /* Pointer to the class's
        !           261:                                                 meta class. */
        !           262:   struct objc_class*  super_class;            /* Pointer to the super 
        !           263:                                                 class. NULL for class 
        !           264:                                                 Object. */
        !           265:   const char*         name;                   /* Name of the class. */
        !           266:   long                version;                /* Unknown. */
        !           267:   long                info;                   /* Bit mask.  See class masks 
        !           268:                                                 defined above. */
        !           269:   long                instance_size;          /* Size in bytes of the class.  
        !           270:                                                 The sum of the class definition 
        !           271:                                                 and all super class 
        !           272:                                                 definitions. */
        !           273:   IvarList_t          ivars;                  /* Pointer to a structure that
        !           274:                                                 describes the instance 
        !           275:                                                 variables in the class
        !           276:                                                 definition.  NULL indicates
        !           277:                                                 no instance variables.  Does
        !           278:                                                 not include super class
        !           279:                                                 variables. */
        !           280:   MethodList_t        methods;                /* Linked list of instance
        !           281:                                                 methods defined for the 
        !           282:                                                 class. */
        !           283:   struct record **    cache;                  /* Pointer to instance method dispatch table. */
        !           284: } Class, *Class_t;
        !           285: 
        !           286: 
        !           287: /*
        !           288:  * The compiler generates one of these structures for each category.  A class
        !           289:  * may have many categories and contain both instance and factory methods.  
        !           290:  */
        !           291: typedef struct objc_category {
        !           292:   const char*   category_name;                /* Name of the category.  Name
        !           293:                                                 contained in the () of the
        !           294:                                                 category definition. */
        !           295:   const char*   class_name;                   /* Name of the class to which
        !           296:                                                 the category belongs. */
        !           297:   MethodList_t  instance_methods;             /* Linked list of instance
        !           298:                                                 methods defined in the 
        !           299:                                                 category. NULL indicates no
        !           300:                                                 instance methods defined. */
        !           301:   MethodList_t  class_methods;                /* Linked list of factory 
        !           302:                                                 methods defined in the
        !           303:                                                 category.  NULL indicates no
        !           304:                                                 class methods defined. */
        !           305: } Category, *Category_t;
        !           306: 
        !           307: 
        !           308: /*
        !           309:  * Structure used when a message is send to a class's super class.  The
        !           310:  * compiler generates one of these structures and passes it to
        !           311:  * objc_msgSuper. 
        !           312:  */
        !           313: typedef struct objc_super {
        !           314:   id      receiver;                           /* Id of the object sending
        !           315:                                                 the message. */
        !           316:   Class_t class;                              /* Object's super class. */
        !           317: } Super, *Super_t;
        !           318: 
        !           319: /*
        !           320:  * _alloc points to the function, called through class_createInstance, used
        !           321:  * to allocate memory for new instances. 
        !           322:  */
        !           323: extern id (*_alloc)(Class_t);
        !           324: /*
        !           325:  * _dealloc points to the function, called through object_dispose, used to
        !           326:  * free instances. 
        !           327:  */
        !           328: extern id (*_dealloc)(id);
        !           329: /*
        !           330:  * _realloc points to the function, called through object_realloc, used to
        !           331:  * reallocate memory for an object 
        !           332:  */
        !           333: extern id (*_realloc)(id, unsigned int);
        !           334: 
        !           335: /*
        !           336:  * _copy points to the function, called through object_copy, used to create
        !           337:  * an exact copy of an object. 
        !           338:  */
        !           339: extern  id (*_copy)(id);
        !           340: 
        !           341: /*
        !           342:  * _error points to the function that the run-time system calls in response
        !           343:  * to an error.  By default, it prints formatted error messages to the
        !           344:  * standard error stream and calls abort to produce a core file. 
        !           345:  */
        !           346: extern void (*_error)(id object, const char *fmt, va_list ap);
        !           347: 
        !           348: 
        !           349: #ifdef __cplusplus
        !           350: }
        !           351: #endif
        !           352: 
        !           353: 
        !           354: #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.