summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mruby/inline.h47
-rw-r--r--include/mruby/value.h3
2 files changed, 49 insertions, 1 deletions
diff --git a/include/mruby/inline.h b/include/mruby/inline.h
new file mode 100644
index 000000000..e773aa118
--- /dev/null
+++ b/include/mruby/inline.h
@@ -0,0 +1,47 @@
+/*
+** mruby/inline.h - Inline structures
+**
+** See Copyright Notice in mruby.h
+*/
+
+#ifndef MRUBY_INLINE_H
+#define MRUBY_INLINE_H
+
+#include "common.h"
+#include <string.h>
+
+/**
+ * Inline structures that fit in RVALUE
+ *
+ * They cannot have finalizer, and cannot have instance variables.
+ */
+MRB_BEGIN_DECL
+
+#define INLINE_DATA_SIZE (sizeof(void*) * 3)
+
+struct RInline {
+ MRB_OBJECT_HEADER;
+ char inline_data[INLINE_DATA_SIZE];
+};
+
+#define RINLINE(obj) ((struct RInline*)(mrb_ptr(obj)))
+#define INLINE_PTR(obj) (RINLINE(obj)->inline_data)
+
+MRB_INLINE mrb_int mrb_inline_size()
+{
+ return INLINE_DATA_SIZE;
+}
+
+MRB_INLINE void* mrb_inline_ptr(mrb_value object)
+{
+ return INLINE_PTR(object);
+}
+
+MRB_INLINE void mrb_inline_copy(mrb_value dest, mrb_value src)
+{
+ memcpy(INLINE_PTR(dest), INLINE_PTR(src), INLINE_DATA_SIZE);
+}
+
+MRB_END_DECL
+
+#endif /* MRUBY_INLINE_H */
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 4330b9441..eb3f931e1 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -116,7 +116,8 @@ enum mrb_vtype {
MRB_TT_ENV, /* 20 */
MRB_TT_DATA, /* 21 */
MRB_TT_FIBER, /* 22 */
- MRB_TT_MAXDEFINE /* 23 */
+ MRB_TT_INLINE, /* 23 */
+ MRB_TT_MAXDEFINE /* 24 */
};
#include <mruby/object.h>