Annotation of GNUtools/cc/objc/objc.h, revision 1.1

1.1     ! root        1: /* Basic data types for Objective C.
        !             2:    Copyright (C) 1993 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: #ifndef __objc_INCLUDE_GNU
        !            27: #define __objc_INCLUDE_GNU
        !            28: 
        !            29: #ifdef __cplusplus
        !            30: extern "C" {
        !            31: #endif
        !            32: 
        !            33: #ifdef IN_GCC
        !            34: #include "gstddef.h"
        !            35: #else
        !            36: #include "stddef.h"
        !            37: #endif
        !            38: 
        !            39: /*
        !            40: ** Definition of the boolean type.  
        !            41: */
        !            42: typedef char  BOOL;
        !            43: #define YES   (BOOL)1
        !            44: #define NO    (BOOL)0
        !            45: 
        !            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: */
        !            52: typedef void* SEL;
        !            53: 
        !            54: /*
        !            55: ** ObjC uses this typedef for untyped instances.
        !            56: */
        !            57: typedef struct objc_object {
        !            58:   struct objc_class*  class_pointer;
        !            59: } *id;
        !            60: 
        !            61: /*
        !            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, ...); 
        !            66: 
        !            67: /*
        !            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 */
        !            73: 
        !            74: /*
        !            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
        !            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. */
        !            94:   unsigned long       info;                   /* Bit mask.  See class masks 
        !            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. */
        !           100:   struct objc_ivar_list* ivars;               /* Pointer to a structure that
        !           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. */
        !           107:   struct objc_method_list*  methods;          /* Linked list of instance
        !           108:                                                 methods defined for the 
        !           109:                                                 class. */
        !           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; 
        !           125: 
        !           126: #else /* __OBJC__ */
        !           127: @class Protocol;
        !           128: #endif 
        !           129: 
        !           130: typedef void* retval_t;                /* return value */
        !           131: typedef void(*apply_t)(void);  /* function pointer */
        !           132: typedef union {
        !           133:   char *arg_ptr;
        !           134:   char arg_regs[sizeof (char*)];
        !           135: } *arglist_t;                  /* argument frame */
        !           136: 
        !           137: 
        !           138: #if defined(__OBJC__) 
        !           139: #include "objc/sarray.h"
        !           140: 
        !           141: /*
        !           142:   This is the function called when messages are send to nil.  You may
        !           143:   set a breakpoint in your debugger at this function to catch messages
        !           144:   too nil.
        !           145: */
        !           146: extern id nil_method(id rcv, SEL op, ...);
        !           147: 
        !           148: /*
        !           149:   The messager is inlined, thus it is defined here directly.  The
        !           150:   inlining is quite time-consuming when optimizing.  This will be
        !           151:   taken care of later by hand-coding the messager in the compiler.
        !           152: */
        !           153: extern __inline__ IMP
        !           154: objc_msg_lookup(id receiver, SEL op)
        !           155: {
        !           156:   if(receiver)
        !           157:     return sarray_get(receiver->class_pointer->dtable, (size_t)(op));
        !           158:   else
        !           159:     return nil_method;
        !           160: }
        !           161: 
        !           162: #else
        !           163: 
        !           164: IMP objc_msg_lookup(id receiver, SEL op);
        !           165: 
        !           166: #endif
        !           167: 
        !           168: #ifdef __cplusplus
        !           169: }
        !           170: #endif
        !           171: 
        !           172: #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.