BlitzMax Extended  0.8.18
Pushing Blitz to the Max.
blitz_class.h
Go to the documentation of this file.
1 
17 #ifndef BLITZ_CLASS_H
18 #define BLITZ_CLASS_H
19 
20 #include "_common.h"
21 
22 #include "blitz_debug.h"
23 #include "blitz_gc.h"
24 
25 BB_BEGIN_DECLS
26 
34 #define BBCLASS_MAX_INSTANCESIZE BBSIZE_MAX
35 
43 #define BBCLASS_MAX_NUM_REGISTERED BBSIZE_MAX
44 
49 #define BBCLASS_NUM_VFNS 32
50 
68 struct BBClass
69 {
76 
81  void (*free)(BBObject *obj);
82 
92 
105 
112  void (*ctor)(BBObject *obj);
113 
123  void (*dtor)(BBObject *obj);
124 
137  BBString* (*ToString)(BBObject *obj);
138 
147  BBInt (*Compare)(BBObject *obj, BBObject *rhs);
148 
156  BBObject* (*SendMessage)(BBObject *msg, BBObject *src);
157 
178  BBObject* (*Clone)(BBObject *obj);
179 
180  void (*_reserved1_)();
181  void (*_reserved2_)();
182 
188 };
189 
190 // The offset of the BBClass member 'vfns'
191 #define BBCLASS_VFN_OFFSET offsetof(struct BBClass, vfns)
192 
193 // Gives the offset of a virtual function pointer at the given index
194 #define BBCLASS_VFN_OFFSETOF(key) ( BBCLASS_VFN_OFFSET + (key) * sizeof (void*) )
195 
203 #define BBCLASS_ABSTRACT_METHOD bbNullMethodError
204 
212 #define BBCLASS_ABSTRACT_FUNCTION bbNullFunctionError
213 
214 
215 // INTERNAL //
216 
217 typedef BBString* (*BBClassToStringFunc)(BBObject*);
218 typedef BBInt (*BBClassCompareFunc)(BBObject*, BBObject*);
219 typedef BBObject* (*BBClassSendMessageFunc)(BBObject*, BBObject*);
220 typedef BBObject* (*BBClassCloneFunc)(BBObject*);
221 
228 void bb_class_register_multiple(BBSize count, ...);
229 
230 
231 // API //
232 
233 // Needed for binary compatibility since the compiler depends on them.
234 // Everywhere else the new function names, which follow the naming scheme
235 // better, should be used instead of the old ones.
236 
237 #define bbClassRegister bbObjectRegisterType
238 #define bbClassAllRegistered bbObjectRegisteredTypes
239 
240 
256 void bbClassRegister(const BBClass *clas);
257 
263 BBClass** bbClassAllRegistered(BBInt *count);
264 
265 BB_END_DECLS
266 
267 #endif // BLITZ_OBJECT_H