BlitzMax Extended  0.8.11
Pushing Blitz to the Max.
blitz_class.h
Go to the documentation of this file.
00001 
00017 #ifndef BLITZ_CLASS_H
00018 #define BLITZ_CLASS_H
00019 
00020 #include "_common.h"
00021 
00022 #include "blitz_debug.h"
00023 #include "blitz_gc.h"
00024 
00025 BB_BEGIN_DECLS
00026 
00034 #define BBCLASS_MAX_INSTANCESIZE    BBSIZE_MAX
00035 
00036 #define BBCLASS_NUM_VFNS            32
00037 
00055 struct BBClass
00056 {
00062     BBClass         *super;
00063     
00068     void            (*free)(BBObject *obj);
00069     
00078     BBDebugScope    *debug_scope;
00079 
00091     BBSize          instance_size;
00092     
00099     void            (*ctor)(BBObject *obj);
00100     
00110     void            (*dtor)(BBObject *obj);
00111     
00124     BBString*       (*ToString)(BBObject *obj);
00125     
00134     BBInt           (*Compare)(BBObject *obj, BBObject *rhs);
00135     
00143     BBObject*       (*SendMessage)(BBObject *msg, BBObject *src);
00144     
00165     BBObject*       (*Clone)(BBObject *obj);
00166 
00167     void            (*_reserved1_)();
00168     void            (*_reserved2_)();
00169     
00174     void*           vfns[BBCLASS_NUM_VFNS];
00175 };
00176 
00177 //  The offset of the BBClass member 'vfns' 
00178 #define BBCLASS_VFN_OFFSET          offsetof(struct BBClass, vfns)
00179 
00180 //  Gives the offset of a virtual function pointer at the given index
00181 #define BBCLASS_VFN_OFFSETOF(key)   ( BBCLASS_VFN_OFFSET + (key) * sizeof (void*) )
00182 
00190 #define BBCLASS_ABSTRACT_METHOD     bbNullMethodError
00191 
00199 #define BBCLASS_ABSTRACT_FUNCTION   bbNullFunctionError
00200 
00201 //  Intern
00202 
00203 typedef BBString*   (*BBClassToStringFunc)(BBObject*);
00204 typedef BBInt       (*BBClassCompareFunc)(BBObject*, BBObject*);
00205 typedef BBObject*   (*BBClassSendMessageFunc)(BBObject*, BBObject*);
00206 typedef BBObject*   (*BBClassCloneFunc)(BBObject*);
00207 
00212 void bb_class_register_multiple(unsigned int count, ...);
00213 
00214 //  API
00215 
00216 //  Needed for binary compatibility since the compiler depends on them.
00217 //  Everywhere else the new function names, which follow the naming scheme
00218 //  better, should be used instead of the old ones.
00219 
00220 #define bbClassRegister             bbObjectRegisterType
00221 #define bbClassAllRegistered        bbObjectRegisteredTypes
00222 
00223 
00239 void bbClassRegister(const BBClass *clas);
00240 
00246 BBClass** bbClassAllRegistered(BBInt *count);
00247 
00248 BB_END_DECLS
00249 
00250 #endif  // BLITZ_OBJECT_H