Add vtype_variable

This commit is contained in:
Gregory Lirent 2023-03-23 12:31:15 +03:00
parent 6dc339f0f2
commit 554ea487cc

View File

@ -36,6 +36,11 @@ typedef enum libcdsb_value_types {
/*#####################################################################################################################*/
struct libcdsb_variable {
void* pointer;
vtype type;
};
struct libcdsb_string { char* buffer; };
struct libcdsb_array { void* mem; size_t size; vtype type; };
@ -72,11 +77,14 @@ typedef struct libcdsb_set vtype_set;
typedef struct libcdsb_list vtype_list;
typedef struct libcdsb_dict vtype_dict;
typedef struct libcdsb_string vtype_string;
typedef struct libcdsb_variable vtype_variable;
extern const char* libcdsb_vtype_name (vtype t) Warn_unused_result__;
extern const char* libcdsb_vtype_stringify(const void* value, vtype t) Warn_unused_result__;
inline vtype_variable libcdsb_variable_build(void* value, vtype t) Always_inline__;
/*#####################################################################################################################*/
extern size_t string_size (const vtype_string* x) Pure__ Warn_unused_result__ Nonnull__(1);
@ -161,4 +169,13 @@ inline void string_copy_init(vtype_string* x, const vtype_string* s) {
x->buffer = libcdsb_strdup(s->buffer);
}
inline vtype_variable libcdsb_variable_build(void* value, vtype t) {
vtype_variable var;
var.pointer = value;
var.type = t;
return var;
}
#endif /* LIBCDSB_VTYPE_H */