00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _OBJECTS_H
00025 #define _OBJECTS_H
00026 #include "types.h"
00027
00033 #define OBJECT_OK 0
00034 #define OBJECT_ERR_OUT_OF_MEMORY 1
00035 #define OBJECT_ERR_CLASS_REGISTERED 2
00036 #define OBJECT_ERR_CLASS_NOT_FOUND 3
00041 typedef void (*ObjectDestructor_t)(void *ptr);
00042
00047 int ObjectInit(void);
00052 int ObjectDeinit(void);
00053
00063 int ObjectRegisterClass(char *classname, unsigned int size, ObjectDestructor_t destructor);
00064
00069 #define ObjectRegisterType(_type) ObjectRegisterClass(TOSTRING(_type), sizeof(_type), NULL)
00070
00077 #define ObjectRegisterTypeDestructor(_type, _destructor) ObjectRegisterClass(TOSTRING(_type), sizeof(_type), _destructor)
00078
00085 #define ObjectCreate(_classname) ObjectCreateImpl(_classname, __FILE__, __LINE__)
00086
00098 void *ObjectCreateImpl(char *classname, char *file, int line);
00099
00104 #define ObjectCreateType(_type) ObjectCreate(TOSTRING(_type))
00105
00110 #define ObjectRefInc(_ptr) ObjectRefIncImpl(_ptr, __FILE__, __LINE__)
00111
00119 void ObjectRefIncImpl(void *ptr, char *file, int line);
00120
00127 #define ObjectRefDec(_ptr) ObjectRefDecImpl(_ptr, __FILE__, __LINE__)
00128
00136 bool ObjectRefDecImpl(void *ptr, char *file, int line);
00137
00143 int ObjectRefCount(void *ptr);
00144
00150 bool ObjectIsObject(void *ptr);
00151
00157 char *ObjectGetObjectClass(void * ptr);
00158
00164 #define ObjectAlloc(_size) ObjectAllocImpl(_size, __FILE__, __LINE__)
00165
00174 void *ObjectAllocImpl(int size, char * file, int line);
00175
00180 #define ObjectFree(_ptr) ObjectFreeImpl(_ptr, __FILE__, __LINE__)
00181
00189 void ObjectFreeImpl(void * ptr, char * file, int line);
00190
00195 void ObjectDump(void *ptr);
00196
00198 #endif