From bf8522625f55fa2657dee3b9356b20fa0dba725f Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 26 May 2021 13:28:07 +0200 Subject: treewide: move ressource type registry into vm instance Signed-off-by: Jo-Philipp Wich --- types.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'types.h') diff --git a/types.h b/types.h index a4377ad..710f6fc 100644 --- a/types.h +++ b/types.h @@ -184,19 +184,19 @@ typedef struct { char name[]; } uc_cfunction_t; -typedef struct { - uc_value_t header; - size_t type; - void *data; -} uc_ressource_t; - typedef struct { const char *name; uc_value_t *proto; void (*free)(void *); } uc_ressource_type_t; -uc_declare_vector(uc_ressource_types_t, uc_ressource_type_t); +typedef struct { + uc_value_t header; + uc_ressource_type_t *type; + void *data; +} uc_ressource_t; + +uc_declare_vector(uc_ressource_types_t, uc_ressource_type_t *); /* Parser definitions */ @@ -249,6 +249,7 @@ struct uc_vm { uc_value_t *globals; uc_source *sources; uc_weakref_t values; + uc_ressource_types_t restypes; union { uint32_t u32; int32_t s32; @@ -339,8 +340,8 @@ uc_value_t *ucv_cfunction_new(const char *, uc_cfn_ptr_t); uc_value_t *ucv_closure_new(uc_vm *, uc_function_t *, bool); -uc_ressource_type_t *ucv_ressource_type_add(const char *, uc_value_t *, void (*)(void *)); -uc_ressource_type_t *ucv_ressource_type_lookup(const char *); +uc_ressource_type_t *ucv_ressource_type_add(uc_vm *, const char *, uc_value_t *, void (*)(void *)); +uc_ressource_type_t *ucv_ressource_type_lookup(uc_vm *, const char *); uc_value_t *ucv_ressource_new(uc_ressource_type_t *, void *); void **ucv_ressource_dataptr(uc_value_t *, const char *); -- cgit v1.2.3