Fixed a lazySlot bug where lazy slots in different objects end up pointing to the...
[io/quag.git] / libs / iovm / source / IoObject.h
blobf4302cfefd14c21ae82ab58935e5cea805f4c324
1 /*#io
2 docCopyright("Steve Dekorte", 2002)
3 docLicense("BSD revised")
4 */
6 #ifndef OBJECT_DEFINED
7 #define OBJECT_DEFINED 1
9 #include "IoVMApi.h"
11 #include "Common.h"
12 #include "PHash.h"
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
18 #define IoObject_clean(self) PHash_clean(IoObject_slots(self));
19 #define IOREF(value) IoObject_addingRef_((IoObject *)self, (IoObject *)value)
20 //#define IOALLOCREF(value) IoObject_isReferenced_(value, 1)
22 #define IOOBJECT_ISTYPE(self, typeName) \
23 IoObject_hasCloneFunc_(self, (IoTagCloneFunc *)Io ## typeName ## _rawClone)
25 #define ISOBJECT(self) IOOBJECT_ISTYPE(self, Object)
27 #include "IoObject_struct.h"
28 #include "IoMessage.h"
29 #include "IoSeq.h"
31 IOVM_API IoObject *IoObject_proto(void *state);
32 IOVM_API IoObject *IoObject_protoFinish(void *state);
33 IOVM_API IoObject *IoObject_localsProto(void *state);
35 IOVM_API IoObject *IOCLONE(IoObject *self);
36 IOVM_API IoObject *IoObject_rawClone(IoObject *self);
37 IOVM_API IoObject *IoObject_justClone(IoObject *self);
38 IOVM_API IoObject *IoObject_rawClonePrimitive(IoObject *self);
39 IOVM_API IoObject *IoObject_new(void *state);
41 IOVM_API IoObject *IoObject_addMethod_(IoObject *self, IoSymbol *slotName, IoMethodFunc *fp);
42 IOVM_API void IoObject_addMethodTable_(IoObject *self, IoMethodTable *methodTable);
44 IOVM_API void IoObject_dealloc(IoObject *self);
45 IOVM_API void IoObject_willFree(IoObject *self);
46 IOVM_API void IoObject_free(IoObject *self);
48 // inheritance
50 IOVM_API int IoObject_hasProtos(IoObject *self);
51 IOVM_API int IoObject_rawProtosCount(IoObject *self);
52 IOVM_API void IoObject_rawAppendProto_(IoObject *self, IoObject *p);
53 IOVM_API void IoObject_rawPrependProto_(IoObject *self, IoObject *p);
54 IOVM_API void IoObject_rawRemoveProto_(IoObject *self, IoObject *p);
55 IOVM_API void IoObject_rawRemoveAllProtos(IoObject *self);
56 IOVM_API void IoObject_rawSetProto_(IoObject *self, IoObject *proto);
58 IOVM_API IoObject *IoObject_objectProto(IoObject *self, IoObject *locals, IoMessage *m);
59 IOVM_API IoObject *IoObject_setProto(IoObject *self, IoObject *locals, IoMessage *m);
60 IOVM_API IoObject *IoObject_setProtos(IoObject *self, IoObject *locals, IoMessage *m);
61 IOVM_API IoObject *IoObject_appendProto(IoObject *self, IoObject *locals, IoMessage *m);
62 IOVM_API IoObject *IoObject_prependProto(IoObject *self, IoObject *locals, IoMessage *m);
63 IOVM_API IoObject *IoObject_removeProto(IoObject *self, IoObject *locals, IoMessage *m);
64 IOVM_API IoObject *IoObject_removeAllProtos(IoObject *self, IoObject *locals, IoMessage *m);
65 IOVM_API IoObject *IoObject_protosMethod(IoObject *self, IoObject *locals, IoMessage *m);
66 IOVM_API unsigned int IoObject_rawHasProto_(IoObject *self, IoObject *p);
68 // slots
70 IOVM_API void IoObject_createSlots(IoObject *self);
71 IOVM_API void IoObject_setSlot_to_(IoObject *self, IoSymbol *slotName, IoObject *value);
73 IOVM_API IoObject *IoObject_getSlot_(IoObject *self, IoSymbol *slotName);
74 IOVM_API IoObject *IoObject_symbolGetSlot_(IoObject *self, IoSymbol *slotName);
75 IOVM_API IoObject *IoObject_seqGetSlot_(IoObject *self, IoSymbol *slotName);
76 IOVM_API double IoObject_doubleGetSlot_(IoObject *self, IoSymbol *slotName);
78 //IoObject *IoObject_objectWithSlotValue_(IoObject *self, IoObject *slotValue);
79 IOVM_API void IoObject_removeSlot_(IoObject *self, IoSymbol *slotName);
81 // perform and activate
83 IOVM_API IoObject *IoObject_activate(IoObject *self, IoObject *target, IoObject *locals, IoMessage *m, IoObject *slotContext);
84 IOVM_API IoObject *IoObject_perform(IoObject *self, IoObject *locals, IoMessage *m);
85 //IoObject *IoObject_forward(IoObject *self, IoObject *locals, IoMessage *m);
86 IOVM_API IoObject *IoObject_localsForward(IoObject *self, IoObject *locals, IoMessage *m);
88 // tag functions
90 IOVM_API int IoObject_compare(IoObject *self, IoObject *v);
91 IOVM_API int IoObject_defaultCompare(IoObject *self, IoObject *v);
92 IOVM_API const char *IoObject_name(IoObject *self);
93 IOVM_API void IoObject_print(IoObject *self);
95 // memory
97 IOVM_API size_t IoObject_memorySize(IoObject *self);
98 IOVM_API void IoObject_compact(IoObject *self);
100 IOVM_API char *IoObject_markColorName(IoObject *self);
101 IOVM_API void IoObject_show(IoObject *self);
103 // proto
105 IOVM_API IoObject *IoObject_clone(IoObject *self, IoObject *locals, IoMessage *m);
106 IOVM_API IoObject *IoObject_cloneWithoutInit(IoObject *self, IoObject *locals, IoMessage *m);
107 IOVM_API IoObject *IoObject_shallowCopy(IoObject *self, IoObject *locals, IoMessage *m);
108 IOVM_API IoObject *IoObject_duplicate(IoObject *self, IoObject *locals, IoMessage *m);
109 IOVM_API IoObject *IoObject_initClone_(IoObject *self, IoObject *locals, IoMessage *m, IoObject *newObject);
111 // printing
113 IOVM_API IoObject *IoObject_protoPrint(IoObject *self, IoObject *locals, IoMessage *m);
114 IOVM_API IoObject *IoObject_protoWrite(IoObject *self, IoObject *locals, IoMessage *m);
115 IOVM_API IoObject *IoObject_protoWriteLn(IoObject *self, IoObject *locals, IoMessage *m);
117 // reflection
119 IOVM_API IoObject *IoObject_protoPerform(IoObject *self, IoObject *locals, IoMessage *m);
120 IOVM_API IoObject *IoObject_protoPerformWithArgList(IoObject *self, IoObject *locals, IoMessage *m);
122 IOVM_API IoObject *IoObject_protoSet_to_(IoObject *self, IoObject *locals, IoMessage *m);
123 IOVM_API IoObject *IoObject_protoSetSlotWithType(IoObject *self, IoObject *locals, IoMessage *m);
124 IOVM_API IoObject *IoObject_localsUpdateSlot(IoObject *self, IoObject *locals, IoMessage *m);
125 IOVM_API IoObject *IoObject_protoUpdateSlot_to_(IoObject *self, IoObject *locals, IoMessage *m);
127 IOVM_API IoObject *IoObject_protoGetSlot_(IoObject *self, IoObject *locals, IoMessage *m);
128 IOVM_API IoObject *IoObject_protoGetLocalSlot_(IoObject *self, IoObject *locals, IoMessage *m);
130 IOVM_API IoObject *IoObject_protoHasLocalSlot(IoObject *self, IoObject *locals, IoMessage *m);
131 IOVM_API IoObject *IoObject_protoHasProto_(IoObject *self, IoObject *locals, IoMessage *m);
133 IOVM_API IoObject *IoObject_protoRemoveSlot(IoObject *self, IoObject *locals, IoMessage *m);
134 IOVM_API IoObject *IoObject_protoRemoveAllSlots(IoObject *self, IoObject *locals, IoMessage *m);
135 IOVM_API IoObject *IoObject_protoSlotNames(IoObject *self, IoObject *locals, IoMessage *m);
136 IOVM_API IoObject *IoObject_protoSlotValues(IoObject *self, IoObject *locals, IoMessage *m);
138 //IoObject *IoObject_forward_(IoObject *self, IoObject *locals, IoMessage *m);
139 IOVM_API IoObject *IoObject_super(IoObject *self, IoObject *locals, IoMessage *m);
140 IOVM_API IoObject *IoObject_contextWithSlot(IoObject *self, IoObject *locals, IoMessage *m);
141 IOVM_API IoObject *IoObject_ancestorWithSlot(IoObject *self, IoObject *locals, IoMessage *m);
143 IOVM_API IoObject *IoObject_doMessage(IoObject *self, IoObject *locals, IoMessage *m);
144 IOVM_API IoObject *IoObject_self(IoObject *self, IoObject *locals, IoMessage *m);
145 IOVM_API IoObject *IoObject_locals(IoObject *self, IoObject *locals, IoMessage *m);
146 IOVM_API IoObject *IoObject_thisMessage(IoObject *self, IoObject *locals, IoMessage *m);
148 // memory
150 IOVM_API IoObject *IoObject_memorySizeMethod(IoObject *self, IoObject *locals, IoMessage *m);
151 IOVM_API IoObject *IoObject_compactMethod(IoObject *self, IoObject *locals, IoMessage *m);
153 // description
155 IOVM_API void IoObject_defaultPrint(IoObject *self);
157 IOVM_API IoObject *IoObject_type(IoObject *self, IoObject *locals, IoMessage *m);
158 IOVM_API IoObject *IoObject_lobbyPrint(IoObject *self, IoObject *locals, IoMessage *m);
160 // logic
162 IOVM_API IoObject *IoObject_and(IoObject *self, IoObject *locals, IoMessage *m);
164 // math
166 IOVM_API IoObject *IoObject_subtract(IoObject *self, IoObject *locals, IoMessage *m);
168 // comparison
170 IOVM_API int IoObject_sortCompare(IoObject **self, IoObject **v);
172 IOVM_API IoObject *IoObject_isIdenticalTo(IoObject *self, IoObject *locals, IoMessage *m);
173 IOVM_API IoObject *IoObject_equals(IoObject *self, IoObject *locals, IoMessage *m);
174 IOVM_API IoObject *IoObject_notEquals(IoObject *self, IoObject *locals, IoMessage *m);
175 IOVM_API IoObject *IoObject_protoCompare(IoObject *self, IoObject *locals, IoMessage *m);
176 IOVM_API IoObject *IoObject_isLessThan_(IoObject *self, IoObject *locals, IoMessage *m);
177 IOVM_API IoObject *IoObject_isLessThanOrEqualTo_(IoObject *self, IoObject *locals, IoMessage *m);
178 IOVM_API IoObject *IoObject_isGreaterThan_(IoObject *self, IoObject *locals, IoMessage *m);
179 IOVM_API IoObject *IoObject_isGreaterThanOrEqualTo_(IoObject *self, IoObject *locals, IoMessage *m);
181 // meta
183 IOVM_API IoObject *IoObject_evalArg(IoObject *self, IoObject *locals, IoMessage *m);
184 IOVM_API IoObject *IoObject_evalArgAndReturnNil(IoObject *self, IoObject *locals, IoMessage *m);
185 IOVM_API IoObject *IoObject_evalArgAndReturnSelf(IoObject *self, IoObject *locals, IoMessage *m);
186 IOVM_API IoObject *IoObject_uniqueId(IoObject *self, IoObject *locals, IoMessage *m);
187 IOVM_API IoObject *IoObject_do(IoObject *self, IoObject *locals, IoMessage *m);
188 IOVM_API IoObject *IoObject_message(IoObject *self, IoObject *locals, IoMessage *m);
190 // compiler
192 IOVM_API IoObject *IoObject_rawDoString_label_(IoObject *self, IoSymbol *string, IoSymbol *label);
193 IOVM_API IoObject *IoObject_doString(IoObject *self, IoObject *locals, IoMessage *m);
194 IOVM_API IoObject *IoObject_doFile(IoObject *self, IoObject *locals, IoMessage *m);
195 //IoObject *IoObject_unpack(IoObject *self, IoObject *locals, IoMessage *m);
197 // activatable
199 IOVM_API IoObject *IoObject_setIsActivatableMethod(IoObject *self, IoObject *locals, IoMessage *m);
200 IOVM_API IoObject *IoObject_isActivatableMethod(IoObject *self, IoObject *locals, IoMessage *m);
202 // eval
204 IOVM_API IoObject *IoObject_rawDoMessage(IoObject *self, IoMessage *m);
205 IOVM_API IoObject *IoObject_eval(IoObject *self, IoMessage *m, IoObject *locals);
207 IOVM_API IoObject *IoObject_argIsActivationRecord(IoObject *self, IoMessage *m, IoObject *locals);
208 IOVM_API IoObject *IoObject_argIsCall(IoObject *self, IoMessage *m, IoObject *locals);
210 IOVM_API UArray *IoObject_rawGetUArraySlot(IoObject *self,
211 IoObject *locals,
212 IoMessage *m,
213 IoSymbol *slotName);
215 IOVM_API UArray *IoObject_rawGetMutableUArraySlot(IoObject *self,
216 IoObject *locals,
217 IoMessage *m,
218 IoSymbol *slotName);
220 IOVM_API IoObject *IoObject_become(IoObject *self, IoObject *locals, IoMessage *m);
222 // io_free listeners ---------------------------------------------
224 IOVM_API void IoObject_addListener_(IoObject *self, void *listener);
225 IOVM_API void IoObject_removeListener_(IoObject *self, void *listener);
227 // persistence
229 IOVM_API PID_TYPE IoObject_pid(IoObject *self);
231 // asString helper
233 IOVM_API IoSeq *IoObject_asString_(IoObject *self, IoMessage *m);
235 #include "IoObject_flow.h"
236 #include "IoObject_inline.h"
238 #ifdef __cplusplus
240 #endif
241 #endif