mruby 3.3.0
mruby is the lightweight implementation of the Ruby language
Loading...
Searching...
No Matches
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
22struct RIStruct {
23 MRB_OBJECT_HEADER;
24 union {
25 intptr_t inline_alignment[3];
26 char inline_data[ISTRUCT_DATA_SIZE];
27 };
28};
29
30#define RISTRUCT(obj) ((struct RIStruct*)(mrb_ptr(obj)))
31#define ISTRUCT_PTR(obj) (RISTRUCT(obj)->inline_data)
32
33MRB_INLINE mrb_int mrb_istruct_size()
34{
35 return ISTRUCT_DATA_SIZE;
36}
37
38MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
39{
40 return ISTRUCT_PTR(object);
41}
42
43MRB_INLINE void mrb_istruct_copy(mrb_value dest, mrb_value src)
44{
45 memcpy(ISTRUCT_PTR(dest), ISTRUCT_PTR(src), ISTRUCT_DATA_SIZE);
46}
47
49
50#endif /* MRUBY_ISTRUCT_H */
mruby common platform definition"
#define MRB_INLINE
Declare a function as always inlined.
Definition common.h:68
#define MRB_END_DECL
End declarations in C mode.
Definition common.h:28
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition common.h:26
#define ISTRUCT_DATA_SIZE
Inline structures that fit in RVALUE.
Definition istruct.h:20
String class
Definition istruct.h:22
Definition boxing_nan.h:40