Refactor the internal symbols
This commit is contained in:
@@ -34,7 +34,6 @@
|
||||
|
||||
#define abs(v) _Generic((v), ldbl_t: fabsl, dbl_t: fabs, fl_t: fabsf)(v)
|
||||
|
||||
|
||||
typedef vtype_uint8 u8_t;
|
||||
typedef vtype_uint16 u16_t;
|
||||
typedef vtype_uint32 u32_t;
|
||||
@@ -59,12 +58,11 @@ typedef vtype_dict dict_t;
|
||||
typedef vtype_hash hash_t;
|
||||
|
||||
|
||||
extern const size_t LIBCDSB_VTYPE_SIZES[19];
|
||||
|
||||
extern int libcdsb_vtype_compare_values (const void* s0, vtype t0, const void* s1, vtype t1) pure__ wur__;
|
||||
extern int libcdsb_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) pure__ wur__;
|
||||
extern hash_t libcdsb_vtype_hash (const void* value, vtype type) pure__ wur__;
|
||||
extern const size_t LIBCDSB_BUILTIN_VTYPE_SIZES[19];
|
||||
|
||||
extern int libcdsb_builtin_vtype_compare_values (const void* s0, vtype t0, const void* s1, vtype t1) pure__ wur__;
|
||||
extern int libcdsb_builtin_vtype_compare_values_eq(const void* s0, const void* s1, vtype t) pure__ wur__;
|
||||
extern hash_t libcdsb_builtin_vtype_hash (const void* value, vtype type) pure__ wur__;
|
||||
|
||||
#define aligned_alloc libcdsb_aalloc
|
||||
#define malloc libcdsb_malloc
|
||||
@@ -84,32 +82,9 @@ extern hash_t libcdsb_vtype_hash (const void* value, vtype type)
|
||||
|
||||
#define vtype_stringify libcdsb_vtype_stringify
|
||||
#define vtype_name libcdsb_vtype_name
|
||||
#define vtype_compare libcdsb_vtype_compare_values
|
||||
#define vtype_compare_eq libcdsb_vtype_compare_values_eq
|
||||
#define vtype_hash libcdsb_vtype_hash
|
||||
#define vtype_size(type) (LIBCDSB_VTYPE_SIZES[type])
|
||||
|
||||
|
||||
#define vtypeof(x) (vtype)(_Generic((x),\
|
||||
const void**: VTYPE_POINTER, void**: VTYPE_POINTER, const void*: VTYPE_POINTER, void*: VTYPE_POINTER,\
|
||||
const char**: VTYPE_STRING, char**: VTYPE_STRING, const char*: VTYPE_STRING, char*: VTYPE_STRING,\
|
||||
const str_t*: VTYPE_STRING, str_t*: VTYPE_STRING, str_t: VTYPE_STRING,\
|
||||
const arr_t*: VTYPE_ARRAY, arr_t*: VTYPE_ARRAY, arr_t: VTYPE_ARRAY,\
|
||||
const list_t*: VTYPE_LIST, list_t*: VTYPE_LIST, list_t: VTYPE_LIST,\
|
||||
const map_t*: VTYPE_MAP, map_t*: VTYPE_MAP, map_t: VTYPE_MAP,\
|
||||
const set_t*: VTYPE_SET, set_t*: VTYPE_SET, set_t: VTYPE_SET,\
|
||||
const dict_t*: VTYPE_DICT, dict_t*: VTYPE_DICT, dict_t: VTYPE_DICT,\
|
||||
const vtype_bool*: VTYPE_BOOLEAN, vtype_bool*: VTYPE_BOOLEAN, vtype_bool: VTYPE_BOOLEAN,\
|
||||
const vtype_uint8*: VTYPE_UINT8, vtype_uint8*: VTYPE_UINT8, vtype_uint8: VTYPE_UINT8,\
|
||||
const vtype_uint16*: VTYPE_UINT16, vtype_uint16*: VTYPE_UINT16, vtype_uint16: VTYPE_UINT16,\
|
||||
const vtype_uint32*: VTYPE_UINT32, vtype_uint32*: VTYPE_UINT32, vtype_uint32: VTYPE_UINT32,\
|
||||
const vtype_uint64*: VTYPE_UINT64, vtype_uint64*: VTYPE_UINT64, vtype_uint64: VTYPE_UINT64,\
|
||||
const vtype_int8*: VTYPE_INT8, vtype_int8*: VTYPE_INT8, vtype_int8: VTYPE_INT8,\
|
||||
const vtype_int16*: VTYPE_INT16, vtype_int16*: VTYPE_INT16, vtype_int16: VTYPE_INT16,\
|
||||
const vtype_int32*: VTYPE_INT32, vtype_int32*: VTYPE_INT32, vtype_int32: VTYPE_INT32,\
|
||||
const vtype_int64*: VTYPE_INT64, vtype_int64*: VTYPE_INT64, vtype_int64: VTYPE_INT64,\
|
||||
const vtype_float*: VTYPE_FLOAT, vtype_float*: VTYPE_FLOAT, vtype_float: VTYPE_FLOAT,\
|
||||
const vtype_double*: VTYPE_DOUBLE, vtype_double*: VTYPE_DOUBLE, vtype_double: VTYPE_DOUBLE,\
|
||||
const vtype_ldouble*: VTYPE_LDOUBLE, vtype_ldouble*: VTYPE_LDOUBLE, vtype_ldouble: VTYPE_LDOUBLE))
|
||||
#define vtype_compare libcdsb_builtin_vtype_compare_values
|
||||
#define vtype_compare_eq libcdsb_builtin_vtype_compare_values_eq
|
||||
#define vtype_hash libcdsb_builtin_vtype_hash
|
||||
#define vtype_size(type) (LIBCDSB_BUILTIN_VTYPE_SIZES[type])
|
||||
|
||||
#endif /* LIBCDSB_SRC_INTERNAL_INCLUDE */
|
||||
|
||||
+12
-8
@@ -15,16 +15,20 @@ typedef struct libcdsb_rbtree_node {
|
||||
short colored;
|
||||
} rbnode_t;
|
||||
|
||||
extern rbnode_t LIBCDSB_RBTREE_NODE_EMPTY[1];
|
||||
extern rbnode_t LIBCDSB_BUILTIN_RBTREE_NODE_EMPTY[1];
|
||||
|
||||
extern void* libcdsb_rbtree_node_create(void* value, rbnode_t* parent, int colored, int size) Nonnull__( 2);
|
||||
extern void libcdsb_rbtree_node_fixup (rbnode_t** root, rbnode_t* node) Nonnull__(1,2);
|
||||
extern rbnode_t* libcdsb_rbtree_node_delete(rbnode_t** root, rbnode_t* node) Nonnull__(1,2);
|
||||
extern void* libcdsb_builtin_rbtree_node_create(void* value, rbnode_t* parent, int colored, int size) Nonnull__( 2);
|
||||
extern void libcdsb_builtin_rbtree_node_fixup (rbnode_t** root, rbnode_t* node) Nonnull__(1,2);
|
||||
extern rbnode_t* libcdsb_builtin_rbtree_node_delete(rbnode_t** root, rbnode_t* node) Nonnull__(1,2);
|
||||
|
||||
#define rbnode_empty ((rbnode_t*)LIBCDSB_RBTREE_NODE_EMPTY)
|
||||
#define rbnode_create(v, p, c) ((rbnode_t*)libcdsb_rbtree_node_create(v, p, c, sizeof(rbnode_t)))
|
||||
#define rbnode_fixup libcdsb_rbtree_node_fixup
|
||||
#define rbnode_delete libcdsb_rbtree_node_delete
|
||||
extern rbnode_t* libcdsb_builtin_rbtree_next_inorder (rbnode_t** root, rbnode_t* prev, bool reverse);
|
||||
extern rbnode_t* libcdsb_builtin_rbtree_next_preorder (rbnode_t** root, rbnode_t* prev, bool reverse);
|
||||
extern rbnode_t* libcdsb_builtin_rbtree_next_postorder(rbnode_t** root, rbnode_t* prev, bool reverse);
|
||||
|
||||
#define rbnode_empty ((rbnode_t*)LIBCDSB_BUILTIN_RBTREE_NODE_EMPTY)
|
||||
#define rbnode_create(v, p, c) ((rbnode_t*)libcdsb_builtin_rbtree_node_create(v, p, c, sizeof(rbnode_t)))
|
||||
#define rbnode_fixup libcdsb_builtin_rbtree_node_fixup
|
||||
#define rbnode_delete libcdsb_builtin_rbtree_node_delete
|
||||
|
||||
#define rbnode_is_empty(n) ((n) == rbnode_empty)
|
||||
#define rbnode_is_root(n) rbnode_is_empty((n)->parent)
|
||||
|
||||
+16
-14
@@ -19,15 +19,15 @@ typedef union {
|
||||
|
||||
typedef void* vnode_t;
|
||||
|
||||
extern vnode_t libcdsb_vnode_create (const void* value, vtype type) wur__;
|
||||
extern vnode_t libcdsb_vnode_create_target(vtype target_type, const void* value, vtype type) wur__;
|
||||
extern vnode_t libcdsb_builtin_vnode_create (const void* value, vtype type) wur__;
|
||||
extern vnode_t libcdsb_builtin_vnode_create_target(vtype target_type, const void* value, vtype type) wur__;
|
||||
|
||||
extern void libcdsb_vnode_free(vnode_t* x, vtype type) Nonnull__(1);
|
||||
extern void* libcdsb_vnode_peek(const vnode_t* x, vtype type) pure__ wur__ Nonnull__(1);
|
||||
extern void libcdsb_builtin_vnode_free(vnode_t* x, vtype type) Nonnull__(1);
|
||||
extern void* libcdsb_builtin_vnode_peek(const vnode_t* x, vtype type) pure__ wur__ Nonnull__(1);
|
||||
|
||||
ainline(void vnode_attach(vnode_t* node, const void* value, vtype type)) {
|
||||
ainline(void libcdsb_builtin_vnode_attach(vnode_t* node, const void* value, vtype type)) {
|
||||
if (type < VTYPE_STRING) {
|
||||
*node = libcdsb_vnode_create(value, type);
|
||||
*node = libcdsb_builtin_vnode_create(value, type);
|
||||
} else if (sizeof(str_t) == sizeof(void*) && type == VTYPE_STRING) {
|
||||
*node = *(char**)value;
|
||||
} else {
|
||||
@@ -36,9 +36,9 @@ ainline(void vnode_attach(vnode_t* node, const void* value, vtype type)) {
|
||||
}
|
||||
}
|
||||
|
||||
ainline(void vnode_tattach(vnode_t* node, vtype target_type, const void* value, vtype type)) {
|
||||
ainline(void libcdsb_builtin_vnode_tattach(vnode_t* node, vtype target_type, const void* value, vtype type)) {
|
||||
if (type < VTYPE_STRING) {
|
||||
*node = libcdsb_vnode_create_target(target_type, value, type);
|
||||
*node = libcdsb_builtin_vnode_create_target(target_type, value, type);
|
||||
} else {
|
||||
type_assert(target_type, type);
|
||||
|
||||
@@ -51,16 +51,18 @@ ainline(void vnode_tattach(vnode_t* node, vtype target_type, const void* value,
|
||||
}
|
||||
}
|
||||
|
||||
#define vnode_create libcdsb_vnode_create
|
||||
#define vnode_tcreate libcdsb_vnode_create_target
|
||||
#define vnode_peek libcdsb_vnode_peek
|
||||
#define vnode_free libcdsb_vnode_free
|
||||
#define vnode_create libcdsb_builtin_vnode_create
|
||||
#define vnode_tcreate libcdsb_builtin_vnode_create_target
|
||||
#define vnode_attach libcdsb_builtin_vnode_attach
|
||||
#define vnode_tattach libcdsb_builtin_vnode_tattach
|
||||
#define vnode_peek libcdsb_builtin_vnode_peek
|
||||
#define vnode_free libcdsb_builtin_vnode_free
|
||||
|
||||
#define vnode_hash(vnode, type) vtype_hash(vnode_peek(vnode, type), type)
|
||||
#define vnode_compare(s0, t0, s1, t1) vtype_compare(vnode_peek(s0, t0), t0, vnode_peek(s1, t1), t1)
|
||||
#define vnode_compare_eq(s0, s1, t) vtype_compare_eq(vnode_peek(s0, t), vnode_peek(s1, t), t)
|
||||
#define vnode_duplicate(vnode, type) libcdsb_vnode_create(vnode_peek(vnode, type), type)
|
||||
#define vnode_tduplicate(target_type, vnode, type) libcdsb_vnode_create_target(target_type, vnode_peek(vnode, type), type)
|
||||
#define vnode_duplicate(vnode, type) vnode_create(vnode_peek(vnode, type), type)
|
||||
#define vnode_tduplicate(target_type, vnode, type) vnode_tcreate(target_type, vnode_peek(vnode, type), type)
|
||||
|
||||
#define vnode_stringify(n, t) vtype_stringify(vnode_peek(n, t), t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user