mruby  2.0.1
mruby is the lightweight implementation of the Ruby language
istruct.h
Go to the documentation of this file.
1 
7 #ifndef MRUBY_ISTRUCT_H
8 #define MRUBY_ISTRUCT_H
9 
10 #include "common.h"
11 #include <string.h>
12 
19 
20 #define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
21 
22 struct RIStruct {
23  MRB_OBJECT_HEADER;
24  char inline_data[ISTRUCT_DATA_SIZE];
25 };
26 
27 #define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
28 #define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
29 
30 MRB_INLINE mrb_int mrb_istruct_size()
31 {
32  return ISTRUCT_DATA_SIZE;
33 }
34 
35 MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
36 {
37  return ISTRUCT_PTR(object);
38 }
39 
40 MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
41 {
42  memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
43 }
44 
46 
47 #endif /* MRUBY_ISTRUCT_H */
String class
Definition: istruct.h:22
#define ISTRUCT_DATA_SIZE
Inline structures that fit in RVALUE.
Definition: istruct.h:20
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition: common.h:26
#define MRB_END_DECL
End declarations in C mode.
Definition: common.h:28
mruby common platform definition"
Definition: boxing_nan.h:39
#define MRB_INLINE
Declare a function as always inlined.
Definition: common.h:62