this will allow a wider range of data structures (e.g. b_error, b_stream, b_stringstream) to make use of the new object system, and other modules and library users can use the object system without depending on the blue-object or blue-ds modules. blue-ds will become a simple library of data structures (string, hashmap, etc), built on top of the core object system.
42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
#ifndef BLUE_CORE_OBJECT_H_
|
|
#define BLUE_CORE_OBJECT_H_
|
|
|
|
#include <blue/core/misc.h>
|
|
#include <blue/core/stringstream.h>
|
|
#include <blue/core/type.h>
|
|
|
|
#define B_OBJECT_MAGIC 0xDECAFC0C0ABEEF13ULL
|
|
|
|
#define B_OBJECT(p) ((b_object *)(p))
|
|
#define B_TYPE_OBJECT (b_object_get_type())
|
|
|
|
struct b_stream;
|
|
|
|
typedef struct _b_object b_object;
|
|
|
|
typedef struct _b_object_class {
|
|
void (*to_string)(b_object *, struct b_stream *);
|
|
} b_object_class;
|
|
|
|
#define b_object_get_private(object, private_struct, type_id) \
|
|
((private_struct *)z__b_object_get_private(B_OBJECT(object), type_id));
|
|
#define b_object_get_protected(object, protected_struct, type_id) \
|
|
((protected_struct *)z__b_object_get_protected(B_OBJECT(object), type_id));
|
|
#define b_object_get_interface(object, interface_struct, interface_id) \
|
|
((interface_struct *)z__b_object_get_interface( \
|
|
B_OBJECT(object), interface_id));
|
|
|
|
BLUE_API b_type b_object_get_type(void);
|
|
|
|
BLUE_API void *z__b_object_get_private(b_object *object, b_type type);
|
|
BLUE_API void *z__b_object_get_protected(b_object *object, b_type type);
|
|
BLUE_API void *z__b_object_get_interface(b_object *object, b_type type);
|
|
|
|
b_object *b_retain(b_object *p);
|
|
BLUE_API void b_release(b_object *p);
|
|
|
|
BLUE_API b_object *b_object_create(b_type type);
|
|
BLUE_API void b_object_to_string(b_object *p, struct b_stream *out);
|
|
|
|
#endif
|