]> git.saurik.com Git - apple/objc4.git/blob - runtime/Object.h
c7cb936c8f6b13d39fd46a4a465cad49fc11e64f
[apple/objc4.git] / runtime / Object.h
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
12 * this file.
13 *
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
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 /*
25 Object.h
26 Copyright 1988-1996 NeXT Software, Inc.
27
28 DEFINED AS: A common class
29 HEADER FILES: <objc/Object.h>
30
31 */
32
33 #ifndef _OBJC_OBJECT_H_
34 #define _OBJC_OBJECT_H_
35
36 #include <objc/objc-runtime.h>
37
38 @class Protocol;
39
40 @interface Object
41 {
42 Class isa; /* A pointer to the instance's class structure */
43 }
44
45 /* Initializing classes and instances */
46
47 + initialize;
48 - init;
49
50 /* Creating, copying, and freeing instances */
51
52 + new;
53 + free;
54 - free;
55 + alloc;
56 - copy;
57 + allocFromZone:(void *)zone;
58 - copyFromZone:(void *)zone;
59 - (void *)zone;
60
61 /* Identifying classes */
62
63 + class;
64 + superclass;
65 + (const char *) name;
66 - class;
67 - superclass;
68 - (const char *) name;
69
70 /* Identifying and comparing instances */
71
72 - self;
73 - (unsigned int) hash;
74 - (BOOL) isEqual:anObject;
75
76 /* Testing inheritance relationships */
77
78 - (BOOL) isKindOf: aClassObject;
79 - (BOOL) isMemberOf: aClassObject;
80 - (BOOL) isKindOfClassNamed: (const char *)aClassName;
81 - (BOOL) isMemberOfClassNamed: (const char *)aClassName;
82
83 /* Testing class functionality */
84
85 + (BOOL) instancesRespondTo:(SEL)aSelector;
86 - (BOOL) respondsTo:(SEL)aSelector;
87
88 /* Testing protocol conformance */
89
90 - (BOOL) conformsTo: (Protocol *)aProtocolObject;
91 + (BOOL) conformsTo: (Protocol *)aProtocolObject;
92
93 /* Obtaining method descriptors from protocols */
94
95 - (struct objc_method_description *) descriptionForMethod:(SEL)aSel;
96 + (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel;
97
98 /* Obtaining method handles */
99
100 - (IMP) methodFor:(SEL)aSelector;
101 + (IMP) instanceMethodFor:(SEL)aSelector;
102
103 /* Sending messages determined at run time */
104
105 - perform:(SEL)aSelector;
106 - perform:(SEL)aSelector with:anObject;
107 - perform:(SEL)aSelector with:object1 with:object2;
108
109 /* Posing */
110
111 + poseAs: aClassObject;
112
113 /* Enforcing intentions */
114
115 - subclassResponsibility:(SEL)aSelector;
116 - notImplemented:(SEL)aSelector;
117
118 /* Error handling */
119
120 - doesNotRecognize:(SEL)aSelector;
121 - error:(const char *)aString, ...;
122
123 /* Debugging */
124
125 - (void) printForDebugger:(void *)stream;
126
127 /* Archiving */
128
129 - awake;
130 - write:(void *)stream;
131 - read:(void *)stream;
132 + (int) version;
133 + setVersion: (int) aVersion;
134
135 /* Forwarding */
136
137 - forward: (SEL)sel : (marg_list)args;
138 - performv: (SEL)sel : (marg_list)args;
139
140 @end
141
142 /* Abstract Protocol for Archiving */
143
144 @interface Object (Archiving)
145
146 - startArchiving: (void *)stream;
147 - finishUnarchiving;
148
149 @end
150
151 /* Abstract Protocol for Dynamic Loading */
152
153 #if !defined(NeXT_PDO)
154 @interface Object (DynamicLoading)
155
156 //+ finishLoading:(headerType *)header;
157 + finishLoading:(struct mach_header *)header;
158 + startUnloading;
159
160 @end
161 #endif
162
163 OBJC_EXPORT id object_dispose(Object *anObject);
164 OBJC_EXPORT id object_copy(Object *anObject, unsigned nBytes);
165 OBJC_EXPORT id object_copyFromZone(Object *anObject, unsigned nBytes, void *z);
166 OBJC_EXPORT id object_realloc(Object *anObject, unsigned nBytes);
167 OBJC_EXPORT id object_reallocFromZone(Object *anObject, unsigned nBytes, void *z);
168
169 #endif /* _OBJC_OBJECT_H_ */