#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
Go to the source code of this file.
|
|
#define | CBool unsigned char |
| |
|
#define | CTRUE 1 |
| |
|
#define | CFALSE !CTRUE |
| |
|
#define | C_DEBUG_DIAG_LEVEL 2 |
| |
|
#define | CDefaultFree free |
| |
|
#define | CFree CDefaultFree |
| |
|
#define | CMalloc malloc |
| |
| #define | C_CLASS _cc |
| |
| #define | C_ROOT _rt |
| |
| #define | C_VTABLE _vt |
| |
| #define | C_VTABLE_OFFSET _vo |
| |
|
#define | C_PRINT(...) printf( __VA_ARGS__ ) |
| |
|
#define | C_FAILED_ASSERT_HANDLE() for( ;; ) |
| |
| #define | C_ASSERT_VIRTUAL_MESSAGE |
| |
|
#define | C_ASSERT_OBJECT_MESSAGE "NULL pointer used as input\n" |
| |
| #define | C_ASSERT_CAST_MESSAGE |
| |
| #define | CAssert(exp, msg, file, line) |
| |
|
#define | C_ASSERT_VIRTUAL(method) CAssert( ((method)==NULL), CAssertVirtualMessage_, __FILE__, __LINE__ ) |
| |
|
#define | C_ASSERT_OBJECT(object) CAssert( ((object)==NULL), CAssertObjectMessage_, __FILE__, __LINE__ ) |
| |
|
#define | C_ASSERT_CAST(object, file, line) CAssert( (object) == NULL, CAssertCastMessage_, file, line ) |
| |
|
#define | CObject(self) CObject_Constructor(self) |
| |
|
#define | CDestroy(mem) CObject_Destroy((void*) (mem)) |
| |
|
#define | CDynamic(obj) CObject_SetFree(((struct CClass*) (obj))->C_ROOT, CDefaultFree) |
| |
|
#define | CFreeWith(obj, freep) CObject_SetFree(((struct CClass*) (obj))->C_ROOT, (freep)) |
| |
|
#define | CAssertVirtual(func) C_ASSERT_VIRTUAL(func) |
| |
|
#define | CAssertObject(object) C_ASSERT_OBJECT((object)) |
| |
|
#define | CCast(self_) CObjectCast_( self_, __FILE__, __LINE__ ) |
| |
|
|
typedef void(* | CFreeType) (void *) |
| |
|
| void * | CObjectCast_ (void *super_reference, const char *file_name, int line_num) |
| |
| void | CVTable (void *self, const void *vtable) |
| |
| const void * | CGetVTable (void *self_) |
| |
|
|
const char * | CAssertVirtualMessage_ |
| |
|
const char * | CAssertObjectMessage_ |
| |
|
const char * | CAssertCastMessage_ |
| |
| #define C_ASSERT_CAST_MESSAGE |
Value:"Failure to cast object. Possible causes:\n"\
"\t* [C0] Did not call interface constructor, CInterface( )\n"\
"\t* [C1] Did not call super's constructor.\n"
| #define C_ASSERT_VIRTUAL_MESSAGE |
Value:"Virtual method not linked. Possible causes:\n"\
"\t* [A0] Class constructor did not link virtual table with CVTable\n"\
"\t* [A1] Constructor was never called on object\n"\
"\t* [A2] Constructor was called, but super's constructor was not called\n"\
"\t* [A3] Virtual table function assignment is incomplete\n"
Used to provide consistent interface for finding virtual functions when dealing with object and interface references.
Used to back track from a pointer to an interface, to its implementing class' vtable, and the offset into that vtable where the implemented methods are located.
This contains a pointer to the top of an objects memory. It is used to back track to the top of an objects memory regardless of what super class reference is used. Using the above example, with a reference to Interface0 (pointer to 5'th row in memory layout table above), the C_ROOT variable can resolve the top of the memory block.
Pointer to an objects vtable.
This is used to find the offset into the virtual table where a classes virtual methods are. Using the above example, with a reference to Interface0 (pointer to 5'th row in memory layout table above), the C_ROOT variable can resolve the top of the memory block and an offset into vtable (in this case, the offset is 2). With the top of the memory block known, a pointer to the virtual table can be obtained. Moving two rows down the virtual table (third row), as specified by the offset value, we find method0.
| #define CAssert |
( |
|
exp, |
|
|
|
msg, |
|
|
|
file, |
|
|
|
line |
|
) |
| |
Value:do { \
(void) (exp); \
(void) (file); \
(void) (line); \
} while( 0 )