blob: d0a08d6bc013477e8bef1e19206a9788f6f8f959 (
plain)
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
|
#ifndef FIDDLE_CONVERSIONS_H
#define FIDDLE_CONVERSIONS_H
#include <fiddle.h>
typedef union
{
ffi_arg fffi_arg;
ffi_sarg fffi_sarg;
unsigned char uchar;
signed char schar;
unsigned short ushort;
signed short sshort;
unsigned int uint;
signed int sint;
unsigned long ulong;
signed long slong;
float ffloat;
double ddouble;
#if HAVE_LONG_LONG
unsigned LONG_LONG ulong_long;
signed LONG_LONG slong_long;
#endif
void * pointer;
} fiddle_generic;
ffi_type * int_to_ffi_type(int type);
void value_to_generic(int type, VALUE src, fiddle_generic * dst);
VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
#define VALUE2GENERIC(_type, _src, _dst) value_to_generic((_type), (_src), (_dst))
#define INT2FFI_TYPE(_type) int_to_ffi_type(_type)
#define GENERIC2VALUE(_type, _retval) generic_to_value((_type), (_retval))
#if SIZEOF_VOIDP == SIZEOF_LONG
# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
#else
# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
#endif
#endif
|