libcdsb/src/__internal/vnode.h

41 lines
1.7 KiB
C
Raw Normal View History

2022-06-02 14:20:55 +03:00
/* This software is licensed by the Apache License 2.0, see LICENSE file */
/* Copyright © 2022 Gregory Lirent */
#include "include.h"
#ifndef LIBCDSB_SRC_INTERNAL_VNODE_H
#define LIBCDSB_SRC_INTERNAL_VNODE_H
#define is_permissible(T) (sizeof(void*) >= sizeof(T) && _Alignof(void*) >= _Alignof(T))
typedef union {
2022-06-09 16:29:10 +03:00
void* ptr; bool b;
2022-06-02 14:20:55 +03:00
str_t s; arr_t a; list_t l;
2022-08-16 18:39:55 +03:00
map_t m; set_t vs; dict_t vd;
2022-06-02 14:20:55 +03:00
u8_t u8; u16_t u16; u32_t u32; u64_t u64;
fl_t f; dbl_t d; ldbl_t ld;
} var_t;
typedef void* vnode_t;
2022-08-16 01:36:37 +03:00
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__;
2022-06-02 14:20:55 +03:00
2022-08-16 01:36:37 +03:00
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);
2022-06-02 14:20:55 +03:00
#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
2022-08-14 18:18:34 +03:00
#define vnode_hash(vnode, type) vtype_hash(vnode_peek(vnode, type), type)
2022-06-02 14:20:55 +03:00
#define vnode_compare(s0, t0, s1, t1) vtype_compare(vnode_peek(s0, t0), t0, vnode_peek(s1, t1), t1)
2022-08-14 18:18:34 +03:00
#define vnode_compare_eq(s0, s1, t) vtype_compare_eq(vnode_peek(s0, t), vnode_peek(s1, t), t)
2022-06-02 14:20:55 +03:00
#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)
2022-06-08 10:54:50 +03:00
#define vnode_stringify(n, t) vtype_stringify(vnode_peek(n, t), t)
2022-06-02 14:20:55 +03:00
#endif /* LIBCDSB_SRC_INTERNAL_VNODE_H */