diff options
| author | realtradam <[email protected]> | 2022-02-06 05:42:14 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-02-06 05:42:14 -0500 |
| commit | f572573c195a41b4c3aa47b1c5f6c0dc9213b17a (patch) | |
| tree | 71b79c678aae428cd8333c0b925714ec84aa30fd /include/raylib/core.h | |
| parent | 2e283dd01b5dc80e9606add4819a15d8803c167c (diff) | |
| download | mruby-raylib-f572573c195a41b4c3aa47b1c5f6c0dc9213b17a.tar.gz mruby-raylib-f572573c195a41b4c3aa47b1c5f6c0dc9213b17a.zip | |
working structs across files and new macros for struct wrapping
Diffstat (limited to 'include/raylib/core.h')
| -rw-r--r-- | include/raylib/core.h | 16 |
1 files changed, 13 insertions, 3 deletions
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*); |
