source: EcnlProtoTool/trunk/mruby-2.1.1/include/mruby/istruct.h@ 439

Last change on this file since 439 was 439, checked in by coas-nagasima, 4 years ago

mrubyを2.1.1に更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr
File size: 904 bytes
Line 
1/**
2** @file mruby/istruct.h - Inline structures
3**
4** See Copyright Notice in mruby.h
5*/
6
7#ifndef MRUBY_ISTRUCT_H
8#define MRUBY_ISTRUCT_H
9
10#include "common.h"
11#include <string.h>
12
13/**
14 * Inline structures that fit in RVALUE
15 *
16 * They cannot have finalizer, and cannot have instance variables.
17 */
18MRB_BEGIN_DECL
19
20#define ISTRUCT_DATA_SIZE (sizeof(void*) * 3)
21
22struct 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
30MRB_INLINE mrb_int mrb_istruct_size()
31{
32 return ISTRUCT_DATA_SIZE;
33}
34
35MRB_INLINE void* mrb_istruct_ptr(mrb_value object)
36{
37 return ISTRUCT_PTR(object);
38}
39
40MRB_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
45MRB_END_DECL
46
47#endif /* MRUBY_ISTRUCT_H */
Note: See TracBrowser for help on using the repository browser.