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_string { char* buffer; };
struct libcdsb_array { void* mem; size_t size; vtype type; }; struct libcdsb_array { void* mem; size_t size; vtype type; };
@ -66,17 +71,20 @@ typedef long double vtype_ldouble;
typedef size_t vtype_hash; typedef size_t vtype_hash;
typedef struct libcdsb_array vtype_array; typedef struct libcdsb_array vtype_array;
typedef struct libcdsb_map vtype_map; typedef struct libcdsb_map vtype_map;
typedef struct libcdsb_set vtype_set; typedef struct libcdsb_set vtype_set;
typedef struct libcdsb_list vtype_list; typedef struct libcdsb_list vtype_list;
typedef struct libcdsb_dict vtype_dict; typedef struct libcdsb_dict vtype_dict;
typedef struct libcdsb_string vtype_string; 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_name (vtype t) Warn_unused_result__;
extern const char* libcdsb_vtype_stringify(const void* value, 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); 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); 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 */ #endif /* LIBCDSB_VTYPE_H */