![]() |
BlitzMax Extended
0.8.16
Pushing Blitz to the Max.
|
Contains critical information and functionality for object instances. More...
#include <blitz_class.h>
Data Fields | |
BBClass * | super |
The class' parent class. | |
void(* | free )(BBObject *obj) |
The function used to free an instance from memory. | |
BBDebugScope * | debug_scope |
The debug scope containing additional information about the class. | |
BBSize | instance_size |
The amount of memory an instance of the class takes. | |
void(* | ctor )(BBObject *obj) |
The class constructor. | |
void(* | dtor )(BBObject *obj) |
The class destructor. | |
BBString *(* | ToString )(BBObject *obj) |
Gives a string representation of the class instance. | |
BBInt(* | Compare )(BBObject *obj, BBObject *rhs) |
Compares two instances of a class. | |
BBObject *(* | SendMessage )(BBObject *msg, BBObject *src) |
Sends a message to an object. | |
BBObject *(* | Clone )(BBObject *obj) |
Creates an exact copy of the object. | |
void * | vfns [BBCLASS_NUM_VFNS] |
The virtual function table. |
Contains critical information and functionality for object instances.
A class is a structure which contains all necessary information to allocate and initialize an new instance of it with the GC.
It also contains all functions that the user can call to work with the class' instances that hold the data of an object.
Every class has a basic set of named function pointers: free, ctor, dtor, ToString, Compare, SendMessage and Clone. These provide some often used funtionality and should be defined in every class available to users.
In contrast to the named function pointers, the class specific functionality is contained in the virtual function table (vfns). Extending classes copy these functions from their parent class and overwrite them if necessary.
Creates an exact copy of the object.
This should take the given object and create a new instance of the same class with the values set to be equal to the ones in the given object.
If cloning is not desirable (static class) or impossible in a certain situation, a pointer to bbNullObject should be returned.
obj | The class instance to be cloned |
Compares two instances of a class.
obj | The object to compare against |
rhs | The right-hand side object which is compared to the first one |
0 | If both objects are equal. |
>0 | If the object is greater than the one on the right-hand side |
<0 | If the object is lesser than the one on the right-hand side |
Referenced by bbArrayEndsWith(), bbArrayFindObject(), and bbArrayStartsWith().
void(* BBClass::ctor)(BBObject *obj) |
The class constructor.
This initializes the instance's data.
obj | The class instance to be initialized |
Referenced by bbObjectNew().
BBDebugScope* BBClass::debug_scope |
The debug scope containing additional information about the class.
An often used property of this structure is the name of the class. Also the reflection functionality depends on the information in this property to be complete and correct.
Referenced by bbObjectClone().
void(* BBClass::dtor)(BBObject *obj) |
The class destructor.
This deinitializes any data if necessary.
obj | The class instance to be deinitialized |
Referenced by bbObjectFree(), and bbObjectNew().
void(* BBClass::free)(BBObject *obj) |
The function used to free an instance from memory.
obj | The instance to be freed |
BBSize BBClass::instance_size |
The amount of memory an instance of the class takes.
This information is used to allocate a new instance with the GC. Usually this is automatically set by BlitzMax' compiler.
Referenced by bbClassRegister(), bbObjectFree(), and bbObjectNew().
Sends a message to an object.
msg | The action or notice that should be processed |
src | The object that send the message and is associated with it |
BBClass* BBClass::super |
The class' parent class.
Gives a string representation of the class instance.
The actual format of the returned string is not specified. By default the bbObjectToString function – which only returns a string containing the memory address of the instance – is called.
But especially for debugging purposes it can be usefull to actually return information which have a higher descriptive value.
obj | The instance to get a description of |
void* BBClass::vfns[BBCLASS_NUM_VFNS] |
The virtual function table.
This contains all additional (user-defined) functions.