39 lines
947 B
C
39 lines
947 B
C
#ifndef BLUELIB_OBJECT_H_
|
|
#define BLUELIB_OBJECT_H_
|
|
|
|
#include <blue/object/type.h>
|
|
|
|
#define B_OBJECT(p) ((b_object *)(p))
|
|
|
|
#define B_TYPEOF(object) ((struct b_object *)(object)->ob_type)
|
|
#define B_TYPEID(object) (b_typeid(B_OBJECT(object)))
|
|
|
|
#define B_RV(p) (b_make_rvalue(B_OBJECT(p)))
|
|
#define B_RVT(t, p) ((t *)(b_make_rvalue(B_OBJECT(p))))
|
|
|
|
struct b_string;
|
|
struct b_stream;
|
|
|
|
typedef enum b_comparison_result {
|
|
B_LESS = -1,
|
|
B_EQUAL = 0,
|
|
B_GREATER = 1,
|
|
} b_comparison_result_t;
|
|
|
|
typedef struct b_object {
|
|
unsigned int ob_ref;
|
|
const struct b_object_type *ob_type;
|
|
} b_object;
|
|
|
|
BLUE_API b_object *b_make_rvalue(b_object *obj);
|
|
|
|
BLUE_API b_object *b_retain(b_object *obj);
|
|
BLUE_API void b_release(b_object *obj);
|
|
|
|
BLUE_API void b_to_string(b_object *obj, struct b_stream *out);
|
|
BLUE_API b_object_type_id b_typeid(const b_object *obj);
|
|
|
|
BLUE_API b_comparison_result_t b_compare(const b_object *a, const b_object *b);
|
|
|
|
#endif
|