From f572573c195a41b4c3aa47b1c5f6c0dc9213b17a Mon Sep 17 00:00:00 2001 From: realtradam Date: Sun, 6 Feb 2022 05:42:14 -0500 Subject: working structs across files and new macros for struct wrapping --- include/raylib/core.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'include/raylib') diff --git a/include/raylib/core.h b/include/raylib/core.h index bd44465..c98c80d 100644 --- a/include/raylib/core.h +++ b/include/raylib/core.h @@ -11,9 +11,19 @@ #endif -static const struct mrb_data_type Color_type = { - "Color", mrb_free -}; +#define PREWRAPSTRUCT(var_name, type, target) type *var_name = (type *)DATA_PTR(target) + +#define WRAPSTRUCT(type, mrb_type, target, var_name) \ + PREWRAPSTRUCT(var_name, type, target);\ + if(var_name) { mrb_free(mrb, var_name); }\ + mrb_data_init(target, NULL, &mrb_type);\ + var_name = (type *)mrb_malloc(mrb, sizeof(type));\ + +#define UNWRAPSTRUCT(type, mrb_type, target, var_name) type *var_name = DATA_GET_PTR(mrb, target, &mrb_type, type) + + + +extern const struct mrb_data_type Color_type; void mrb_init_raylib_core(mrb_state*); -- cgit v1.2.3