objc-runtime.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
00003  *
00004  * @APPLE_LICENSE_HEADER_START@
00005  * 
00006  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
00007  * Reserved.  This file contains Original Code and/or Modifications of
00008  * Original Code as defined in and that are subject to the Apple Public
00009  * Source License Version 1.1 (the "License").  You may not use this file
00010  * except in compliance with the License.  Please obtain a copy of the
00011  * License at http://www.apple.com/publicsource and read it before using
00012  * this file.
00013  * 
00014  * The Original Code and all software distributed under the License are
00015  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
00016  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
00017  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
00019  * License for the specific language governing rights and limitations
00020  * under the License.
00021  * 
00022  * @APPLE_LICENSE_HEADER_END@
00023  */
00024 /*
00025  *  objc-runtime.h
00026  *  Copyright 1988-1996, NeXT Software, Inc.
00027  */
00028 
00029 #ifndef _OBJC_RUNTIME_H_
00030 #define _OBJC_RUNTIME_H_
00031 
00032 //#import <stdarg.h>
00033 #include "objc/objc.h"
00034 #include "objc/objc-class.h"
00035 
00036 typedef struct objc_symtab *Symtab;
00037 
00038 struct objc_symtab {
00039     unsigned long   sel_ref_cnt;
00040     SEL         *refs;      
00041     unsigned short  cls_def_cnt;
00042     unsigned short  cat_def_cnt;
00043     void        *defs[1];   /* variable size */
00044 };
00045 
00046 typedef struct objc_module *Module;
00047 
00048 struct objc_module {
00049     unsigned long   version;
00050     unsigned long   size;
00051     const char  *name;
00052     Symtab      symtab; 
00053 };
00054 
00055 struct objc_super {
00056     id receiver;
00057     //Class class;
00058     Class pclass;
00059 };
00060 
00061 /* kernel operations */
00062 
00063 OBJC_EXPORT id objc_getClass(const char *name);
00064 OBJC_EXPORT id objc_getMetaClass(const char *name);
00065 OBJC_EXPORT id objc_msgSend(id self, SEL op, ...);
00066 #if defined(WINNT) || defined(__cplusplus)
00067 // The compiler on NT is broken when dealing with structure-returns.
00068 // Help out the compiler group by tweaking the prototype.
00069 OBJC_EXPORT id objc_msgSend_stret(id self, SEL op, ...);
00070 #else
00071 OBJC_EXPORT void objc_msgSend_stret(void * stretAddr, id self, SEL op, ...);
00072 #endif
00073 OBJC_EXPORT id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
00074 #if defined(WINNT) || defined(__cplusplus)
00075 // The compiler on NT is broken when dealing with structure-returns.
00076 // Help out the compiler group by tweaking the prototype.
00077 OBJC_EXPORT id objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...);
00078 #else
00079 OBJC_EXPORT void objc_msgSendSuper_stret(void * stretAddr, struct objc_super *super, SEL op, ...);
00080 #endif
00081 
00082 /* forwarding operations */
00083 
00084 OBJC_EXPORT id objc_msgSendv(id self, SEL op, unsigned arg_size, marg_list arg_frame);
00085 OBJC_EXPORT void objc_msgSendv_stret(void * stretAddr, id self, SEL op, unsigned arg_size, marg_list arg_frame);
00086 
00087 /* 
00088     getting all the classes in the application...
00089     
00090     int objc_getClassList(buffer, bufferLen)
00091     classes is an array of Class values (which are pointers)
00092         which will be filled by the function; if this
00093         argument is NULL, no copying is done, only the
00094         return value is returned
00095     bufferLen is the number of Class values the given buffer
00096         can hold; if the buffer is not large enough to
00097         hold all the classes, the buffer is filled to
00098         the indicated capacity with some arbitrary subset
00099         of the known classes, which could be different
00100         from call to call
00101     returns the number of classes, which is the number put
00102         in the buffer if the buffer was large enough,
00103         or the length the buffer should have been
00104 
00105     int numClasses = 0, newNumClasses = objc_getClassList(NULL, 0);
00106     Class *classes = NULL;
00107     while (numClasses < newNumClasses) {
00108         numClasses = newNumClasses;
00109         classes = realloc(classes, sizeof(Class) * numClasses);
00110         newNumClasses = objc_getClassList(classes, numClasses);
00111     }
00112     // now, can use the classes list; if NULL, there are no classes
00113     free(classes);
00114 
00115 */
00116 OBJC_EXPORT int objc_getClassList(Class *buffer, int bufferLen);
00117 
00118 #define OBSOLETE_OBJC_GETCLASSES 1
00119 #if OBSOLETE_OBJC_GETCLASSES
00120 OBJC_EXPORT void *objc_getClasses(void);
00121 #endif
00122 
00123 OBJC_EXPORT id objc_lookUpClass(const char *name);
00124 OBJC_EXPORT void objc_addClass(Class myClass);
00125 
00126 /* customizing the error handling for objc_getClass/objc_getMetaClass */
00127 
00128 OBJC_EXPORT void objc_setClassHandler(int (*)(const char *));
00129 
00130 /* Making the Objective-C runtime thread safe. */
00131 OBJC_EXPORT void objc_setMultithreaded (BOOL flag);
00132 
00133 /* overriding the default object allocation and error handling routines */
00134 
00135 OBJC_EXPORT id  (*_alloc)(Class, unsigned int);
00136 OBJC_EXPORT id  (*_copy)(id, unsigned int);
00137 OBJC_EXPORT id  (*_realloc)(id, unsigned int);
00138 OBJC_EXPORT id  (*_dealloc)(id);
00139 OBJC_EXPORT id  (*_zoneAlloc)(Class, unsigned int, void *);
00140 OBJC_EXPORT id  (*_zoneRealloc)(id, unsigned int, void *);
00141 OBJC_EXPORT id  (*_zoneCopy)(id, unsigned int, void *);
00142 
00143 OBJC_EXPORT void    (*_error)(id, const char *, va_list);
00144 
00145 
00146 #endif /* _OBJC_RUNTIME_H_ */

Generated on Tue Sep 19 21:18:25 2006 for Boomerang by  doxygen 1.4.6