-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcfunc_type.h
51 lines (41 loc) · 1.22 KB
/
cfunc_type.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// CFunc Basic types
//
// See Copyright Notice in cfunc.h
//
#ifndef cfunc_type_h
#define cfunc_type_h
#include "cfunc.h"
#include "ffi.h"
#define CFUNC_TYPE_HEADER \
union { \
void *_pointer; \
int8_t _sint8; \
uint8_t _uint8; \
int16_t _sint16; \
uint16_t _uint16; \
int32_t _sint32; \
uint32_t _uint32; \
int64_t _sint64; \
uint64_t _uint64; \
double _double; \
float _float; \
} value; \
uint8_t refer: 1; \
uint8_t autofree: 1;
struct cfunc_type_data {
CFUNC_TYPE_HEADER
};
struct mrb_ffi_type {
const char* name;
ffi_type* ffi_type_value;
mrb_value (*data_to_mrb)(mrb_state *mrb, struct cfunc_type_data *data);
void (*mrb_to_data)(mrb_state *mrb, mrb_value val, struct cfunc_type_data *data);
mrb_value (*c_to_mrb)(mrb_state *mrb, void *p);
void (*mrb_to_c)(mrb_state *mrb, mrb_value val, void *p);
};
struct mrb_ffi_type* rclass_to_mrb_ffi_type(mrb_state *mrb, struct RClass *cls);
struct mrb_ffi_type* mrb_value_to_mrb_ffi_type(mrb_state *mrb, mrb_value value);
mrb_value cfunc_type_class(mrb_state *mrb, const char* name);
void init_cfunc_type(mrb_state *mrb, struct RClass* module);
#endif