summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-02-06 05:42:14 -0500
committerrealtradam <[email protected]>2022-02-06 05:42:14 -0500
commitf572573c195a41b4c3aa47b1c5f6c0dc9213b17a (patch)
tree71b79c678aae428cd8333c0b925714ec84aa30fd /include
parent2e283dd01b5dc80e9606add4819a15d8803c167c (diff)
downloadmruby-raylib-f572573c195a41b4c3aa47b1c5f6c0dc9213b17a.tar.gz
mruby-raylib-f572573c195a41b4c3aa47b1c5f6c0dc9213b17a.zip
working structs across files and new macros for struct wrapping
Diffstat (limited to 'include')
-rw-r--r--include/raylib/core.h16
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*);