Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
conversions.h
Go to the documentation of this file.
1#ifndef FIDDLE_CONVERSIONS_H
2#define FIDDLE_CONVERSIONS_H
3
4#include <fiddle.h>
5
6typedef union
7{
8 ffi_arg fffi_arg; /* rvalue smaller than unsigned long */
9 ffi_sarg fffi_sarg; /* rvalue smaller than signed long */
10 unsigned char uchar; /* ffi_type_uchar */
11 signed char schar; /* ffi_type_schar */
12 unsigned short ushort; /* ffi_type_sshort */
13 signed short sshort; /* ffi_type_ushort */
14 unsigned int uint; /* ffi_type_uint */
15 signed int sint; /* ffi_type_sint */
16 unsigned long ulong; /* ffi_type_ulong */
17 signed long slong; /* ffi_type_slong */
18 float ffloat; /* ffi_type_float */
19 double ddouble; /* ffi_type_double */
20#if HAVE_LONG_LONG
21 unsigned LONG_LONG ulong_long; /* ffi_type_ulong_long */
22 signed LONG_LONG slong_long; /* ffi_type_ulong_long */
23#endif
24 void * pointer; /* ffi_type_pointer */
26
27ffi_type * int_to_ffi_type(int type);
30
31#define VALUE2GENERIC(_type, _src, _dst) value_to_generic((_type), (_src), (_dst))
32#define INT2FFI_TYPE(_type) int_to_ffi_type(_type)
33#define GENERIC2VALUE(_type, _retval) generic_to_value((_type), (_retval))
34
35#if SIZEOF_VOIDP == SIZEOF_LONG
36# define PTR2NUM(x) (LONG2NUM((long)(x)))
37# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
38#else
39/* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
40# define PTR2NUM(x) (LL2NUM((LONG_LONG)(x)))
41# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
42#endif
43
44#endif
unsigned long ffi_arg
Definition: ffitarget.h:30
signed long ffi_sarg
Definition: ffitarget.h:31
ffi_type * int_to_ffi_type(int type)
Definition: conversions.c:4
void value_to_generic(int type, VALUE src, fiddle_generic *dst)
Definition: conversions.c:43
VALUE generic_to_value(VALUE rettype, fiddle_generic retval)
Definition: conversions.c:95
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
unsigned long VALUE
__inline__ const void *__restrict__ src
#define LONG_LONG
void * pointer
Definition: conversions.h:24
unsigned int uint
Definition: conversions.h:14
double ddouble
Definition: conversions.h:19
ffi_sarg fffi_sarg
Definition: conversions.h:9
unsigned short ushort
Definition: conversions.h:12
signed char schar
Definition: conversions.h:11
unsigned char uchar
Definition: conversions.h:10
ffi_arg fffi_arg
Definition: conversions.h:8
signed long slong
Definition: conversions.h:17
unsigned long ulong
Definition: conversions.h:16
signed short sshort
Definition: conversions.h:13
signed int sint
Definition: conversions.h:15