]>
git.saurik.com Git - apple/objc4.git/blob - runtime/objc-runtime.h
1b94c3bbd158559e3ac9070e536800dc6d109b35
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 * Copyright 1988-1996, NeXT Software, Inc.
29 #ifndef _OBJC_RUNTIME_H_
30 #define _OBJC_RUNTIME_H_
36 #import <objc/objc-class.h>
38 typedef struct objc_symtab
*Symtab
;
41 unsigned long sel_ref_cnt
;
43 unsigned short cls_def_cnt
;
44 unsigned short cat_def_cnt
;
49 void *defs
[1]; /* variable size */
52 typedef struct objc_module
*Module
;
55 unsigned long version
;
62 extern "Objective-C" {
72 /* kernel operations */
74 OBJC_EXPORT id
objc_getClass(const char *name
);
75 OBJC_EXPORT id
objc_getMetaClass(const char *name
);
76 OBJC_EXPORT id
objc_msgSend(id self
, SEL op
, ...);
77 #if defined(WINNT) || defined(__cplusplus)
78 // The compiler on NT is broken when dealing with structure-returns.
79 // Help out the compiler group by tweaking the prototype.
80 OBJC_EXPORT id
objc_msgSend_stret(id self
, SEL op
, ...);
82 OBJC_EXPORT
void objc_msgSend_stret(void * stretAddr
, id self
, SEL op
, ...);
84 OBJC_EXPORT id
objc_msgSendSuper(struct objc_super
*super
, SEL op
, ...);
85 #if defined(WINNT) || defined(__cplusplus)
86 // The compiler on NT is broken when dealing with structure-returns.
87 // Help out the compiler group by tweaking the prototype.
88 OBJC_EXPORT id
objc_msgSendSuper_stret(struct objc_super
*super
, SEL op
, ...);
90 OBJC_EXPORT
void objc_msgSendSuper_stret(void * stretAddr
, struct objc_super
*super
, SEL op
, ...);
93 /* forwarding operations */
95 OBJC_EXPORT id
objc_msgSendv(id self
, SEL op
, unsigned arg_size
, marg_list arg_frame
);
96 OBJC_EXPORT
void objc_msgSendv_stret(void * stretAddr
, id self
, SEL op
, unsigned arg_size
, marg_list arg_frame
);
99 getting all the classes in the application...
101 int objc_getClassList(buffer, bufferLen)
102 classes is an array of Class values (which are pointers)
103 which will be filled by the function; if this
104 argument is NULL, no copying is done, only the
105 return value is returned
106 bufferLen is the number of Class values the given buffer
107 can hold; if the buffer is not large enough to
108 hold all the classes, the buffer is filled to
109 the indicated capacity with some arbitrary subset
110 of the known classes, which could be different
112 returns the number of classes, which is the number put
113 in the buffer if the buffer was large enough,
114 or the length the buffer should have been
116 int numClasses = 0, newNumClasses = objc_getClassList(NULL, 0);
117 Class *classes = NULL;
118 while (numClasses < newNumClasses) {
119 numClasses = newNumClasses;
120 classes = realloc(classes, sizeof(Class) * numClasses);
121 newNumClasses = objc_getClassList(classes, numClasses);
123 // now, can use the classes list; if NULL, there are no classes
127 OBJC_EXPORT
int objc_getClassList(Class
*buffer
, int bufferLen
);
129 #define OBSOLETE_OBJC_GETCLASSES 1
130 #if OBSOLETE_OBJC_GETCLASSES
131 OBJC_EXPORT
void *objc_getClasses(void);
134 OBJC_EXPORT id
objc_lookUpClass(const char *name
);
135 OBJC_EXPORT
void objc_addClass(Class myClass
);
137 /* customizing the error handling for objc_getClass/objc_getMetaClass */
139 OBJC_EXPORT
void objc_setClassHandler(int (*)(const char *));
141 /* Making the Objective-C runtime thread safe. */
142 OBJC_EXPORT
void objc_setMultithreaded (BOOL flag
);
144 /* overriding the default object allocation and error handling routines */
146 OBJC_EXPORT
id (*_alloc
)(Class
, unsigned int);
147 OBJC_EXPORT
id (*_copy
)(id
, unsigned int);
148 OBJC_EXPORT
id (*_realloc
)(id
, unsigned int);
149 OBJC_EXPORT
id (*_dealloc
)(id
);
150 OBJC_EXPORT
id (*_zoneAlloc
)(Class
, unsigned int, void *);
151 OBJC_EXPORT
id (*_zoneRealloc
)(id
, unsigned int, void *);
152 OBJC_EXPORT
id (*_zoneCopy
)(id
, unsigned int, void *);
154 OBJC_EXPORT
void (*_error
)(id
, const char *, va_list);
157 #endif /* _OBJC_RUNTIME_H_ */