2 ** mruby/istruct.h - Inline structures
4 ** See Copyright Notice in mruby.h
7 #ifndef MRUBY_ISTRUCT_H
8 #define MRUBY_ISTRUCT_H
14 * Inline structures that fit in RVALUE
16 * They cannot have finalizer, and cannot have instance variables.
20 #define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
24 char inline_data[ISTRUCT_DATA_SIZE];
27 #define RISTRUCT(obj) ((struct RIstruct*)(mrb_ptr(obj)))
28 #define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
30 MRB_INLINE mrb_int mrb_istruct_size()
32 return ISTRUCT_DATA_SIZE;
35 MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
37 return ISTRUCT_PTR(object);
40 MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
42 memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
47 #endif /* MRUBY_ISTRUCT_H */