From 554ea487cca00a7c7b257f4977c8e18552a1c9a1 Mon Sep 17 00:00:00 2001 From: Gregory Lirent Date: Thu, 23 Mar 2023 12:31:15 +0300 Subject: [PATCH] Add vtype_variable --- include/vtype.h | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/include/vtype.h b/include/vtype.h index d807f6d..465e988 100644 --- a/include/vtype.h +++ b/include/vtype.h @@ -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; }; @@ -66,17 +71,20 @@ typedef long double vtype_ldouble; typedef size_t vtype_hash; -typedef struct libcdsb_array vtype_array; -typedef struct libcdsb_map vtype_map; -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_array vtype_array; +typedef struct libcdsb_map vtype_map; +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 */