summaryrefslogtreecommitdiffhomepage
path: root/include/raylib
diff options
context:
space:
mode:
Diffstat (limited to 'include/raylib')
-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*);