BlitzMax Extended  0.8.16
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 
41 #define BBCLASS_MAX_NUM_REGISTERED BBSIZE_MAX
42 
43 
44 #define BBCLASS_NUM_VFNS 32
45 
63 struct BBClass
64 {
71 
76  void (*free)(BBObject *obj);
77 
87 
99  BBSize instance_size;
100 
107  void (*ctor)(BBObject *obj);
108 
118  void (*dtor)(BBObject *obj);
119 
132  BBString* (*ToString)(BBObject *obj);
133 
142  BBInt (*Compare)(BBObject *obj, BBObject *rhs);
143 
151  BBObject* (*SendMessage)(BBObject *msg, BBObject *src);
152 
173  BBObject* (*Clone)(BBObject *obj);
174 
175  void (*_reserved1_)();
176  void (*_reserved2_)();
177 
182  void* vfns[BBCLASS_NUM_VFNS];
183 };
184 
185 // The offset of the BBClass member 'vfns'
186 #define BBCLASS_VFN_OFFSET offsetof(struct BBClass, vfns)
187 
188 // Gives the offset of a virtual function pointer at the given index
189 #define BBCLASS_VFN_OFFSETOF(key) ( BBCLASS_VFN_OFFSET + (key) * sizeof (void*) )
190 
198 #define BBCLASS_ABSTRACT_METHOD bbNullMethodError
199 
207 #define BBCLASS_ABSTRACT_FUNCTION bbNullFunctionError
208 
209 // Intern
210 
211 typedef BBString* (*BBClassToStringFunc)(BBObject*);
212 typedef BBInt (*BBClassCompareFunc)(BBObject*, BBObject*);
213 typedef BBObject* (*BBClassSendMessageFunc)(BBObject*, BBObject*);
214 typedef BBObject* (*BBClassCloneFunc)(BBObject*);
215 
222 void bb_class_register_multiple(BBSize count, ...);
223 
224 // API
225 
226 // Needed for binary compatibility since the compiler depends on them.
227 // Everywhere else the new function names, which follow the naming scheme
228 // better, should be used instead of the old ones.
229 
230 #define bbClassRegister bbObjectRegisterType
231 #define bbClassAllRegistered bbObjectRegisteredTypes
232 
233 
249 void bbClassRegister(const BBClass *clas);
250 
256 BBClass** bbClassAllRegistered(BBInt *count);
257 
258 BB_END_DECLS
259 
260 #endif // BLITZ_OBJECT_H