Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions
conversions.h File Reference
`#include <fiddle.h>`

Go to the source code of this file.

## Data Structures
union | fiddle_generic

## Macros
#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))
#define | PTR2NUM(x) (LONG2NUM((long)(x)))
#define | NUM2PTR(x) ((void*)(NUM2ULONG(x)))

## Functions
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)

## Macro Definition Documentation

## ◆ GENERIC2VALUE

#define GENERIC2VALUE | ( |  | _type,
|  |  | _retval
| ) |  | generic_to_value((_type), (_retval))

Definition at line 33 of file conversions.h.

## ◆ INT2FFI_TYPE

#define INT2FFI_TYPE | ( |  | _type | ) | int_to_ffi_type(_type)

Definition at line 32 of file conversions.h.

## ◆ NUM2PTR

#define NUM2PTR | ( |  | x | ) | ((void*)(NUM2ULONG(x)))

Definition at line 37 of file conversions.h.

## ◆ PTR2NUM

#define PTR2NUM | ( |  | x | ) | (LONG2NUM((long)(x)))

Definition at line 36 of file conversions.h.

## ◆ VALUE2GENERIC

#define VALUE2GENERIC | ( |  | _type,
|  |  | _src,
|  |  | _dst
| ) |  | value_to_generic((_type), (_src), (_dst))

Definition at line 31 of file conversions.h.

## Function Documentation

## ◆ generic_to_value()

VALUE generic_to_value | ( | VALUE | rettype,
|  | fiddle_generic | retval
| ) |  |

Definition at line 95 of file conversions.c.

References fiddle_generic::ddouble, fiddle_generic::fffi_arg, fiddle_generic::fffi_sarg, fiddle_generic::ffloat, INT2NUM, LL2NUM, LONG2NUM, mFiddle, NUM2INT, fiddle_generic::pointer, PTR2NUM, Qnil, rb_const_get(), rb_eRuntimeError, rb_float_new, rb_funcall, rb_intern, rb_raise(), fiddle_generic::slong, TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_SHORT, TYPE_VOID, TYPE_VOIDP, UINT2NUM, ULL2NUM, fiddle_generic::ulong, ULONG2NUM, and UNREACHABLE.

## ◆ int_to_ffi_type()

ffi_type* int_to_ffi_type | ( | int | type | ) |

Definition at line 4 of file conversions.c.

References ffi_type_void, rb_eRuntimeError, rb_ffi_type_of, rb_raise(), TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_SHORT, TYPE_VOID, and TYPE_VOIDP.

## ◆ value_to_generic()

void value_to_generic | ( | int | type,
|  | VALUE | src,
|  | fiddle_generic * | dst
| ) |  |

Definition at line 43 of file conversions.c.

References char, fiddle_generic::ddouble, fiddle_generic::ffloat, NUM2DBL, NUM2INT, NUM2LL, NUM2LONG, NUM2PTR, NUM2UINT, NUM2ULL, NUM2ULONG, fiddle_generic::pointer, rb_eRuntimeError, rb_Integer(), rb_raise(), fiddle_generic::schar, short, fiddle_generic::sint, fiddle_generic::slong, src, fiddle_generic::sshort, TYPE_CHAR, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_SHORT, TYPE_VOID, TYPE_VOIDP, fiddle_generic::uchar, fiddle_generic::uint, and fiddle_generic::ulong.