2 ** @file 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)
25 intptr_t inline_alignment[3];
26 char inline_data[ISTRUCT_DATA_SIZE];
30 #define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
31 #define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
33 MRB_INLINE mrb_int mrb_istruct_size()
35 return ISTRUCT_DATA_SIZE;
38 MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
40 return ISTRUCT_PTR(object);
43 MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
45 memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
50 #endif /* MRUBY_ISTRUCT_H */