41 lines
1.0 KiB
C
41 lines
1.0 KiB
C
#ifndef BLUELIB_DSREF_H_
|
|
#define BLUELIB_DSREF_H_
|
|
|
|
#include <blue/ds/type.h>
|
|
|
|
#define B_DSREF(p) ((b_dsref *)(p))
|
|
|
|
#define B_TYPEOF(object) ((struct b_dsref *)(object)->ob_type)
|
|
#define B_TYPEID(object) (b_typeid(B_DSREF(object)))
|
|
|
|
#define B_RV(p) (b_make_rvalue(B_DSREF(p)))
|
|
#define B_RVT(t, p) ((t *)(b_make_rvalue(B_DSREF(p))))
|
|
|
|
#define B_DSREF_IS(object, type) (B_TYPEID(object) == B_DSREF_TYPE_##type)
|
|
|
|
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_dsref {
|
|
unsigned int ob_ref;
|
|
const struct b_dsref_type *ob_type;
|
|
} b_dsref;
|
|
|
|
BLUE_API b_dsref *b_make_rvalue(b_dsref *obj);
|
|
|
|
BLUE_API b_dsref *b_retain(b_dsref *obj);
|
|
BLUE_API void b_release(b_dsref *obj);
|
|
|
|
BLUE_API void b_to_string(const b_dsref *obj, struct b_stream *out);
|
|
BLUE_API b_dsref_type_id b_typeid(const b_dsref *obj);
|
|
|
|
BLUE_API b_comparison_result_t b_compare(const b_dsref *a, const b_dsref *b);
|
|
|
|
#endif
|