Ruby: ext/fiddle/conversions.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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

Go to the source code of this file.

## Macros
#define | rb_ffi_type_of(t) (signed_p ? &ffi_type_s##t : &ffi_type_u##t)

## Functions
VALUE | rb_fiddle_type_ensure (VALUE type)
ffi_type * | rb_fiddle_int_to_ffi_type (int type)
ffi_type * | int_to_ffi_type (int type)
void | rb_fiddle_value_to_generic (int type, VALUE *src, fiddle_generic *dst)
void | value_to_generic (int type, VALUE src, fiddle_generic *dst)
VALUE | rb_fiddle_generic_to_value (VALUE rettype, fiddle_generic retval)
VALUE | generic_to_value (VALUE rettype, fiddle_generic retval)

## Macro Definition Documentation

## ◆ rb_ffi_type_of

#define rb_ffi_type_of | ( |  | t | ) | (signed_p ? &ffi_type_s##t : &ffi_type_u##t)

## Function Documentation

## ◆ generic_to_value()

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

Definition at line 325 of file conversions.c.

References rb_fiddle_generic_to_value().

## ◆ int_to_ffi_type()

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

Definition at line 197 of file conversions.c.

References rb_fiddle_int_to_ffi_type().

## ◆ rb_fiddle_generic_to_value()

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

Definition at line 271 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(), rb_str_new_cstr, fiddle_generic::slong, TYPE_CHAR, TYPE_CONST_STRING, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_SHORT, TYPE_VOID, TYPE_VOIDP, UINT2NUM, ULL2NUM, fiddle_generic::ulong, ULONG2NUM, and UNREACHABLE.

Referenced by generic_to_value().

## ◆ rb_fiddle_int_to_ffi_type()

ffi_type * rb_fiddle_int_to_ffi_type | ( | int | type | ) |

Definition at line 156 of file conversions.c.

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

Referenced by int_to_ffi_type().

## ◆ rb_fiddle_type_ensure()

VALUE rb_fiddle_type_ensure | ( | VALUE | type | ) |

Definition at line 4 of file conversions.c.

References INT2NUM, NIL_P, rb_check_string_type(), rb_sym2id(), rb_to_int(), rb_to_symbol(), RUBY_CONST_ID, TYPE_CHAR, TYPE_CONST_STRING, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_INT8_T, TYPE_INTPTR_T, TYPE_LONG, TYPE_PTRDIFF_T, TYPE_SHORT, TYPE_SIZE_T, TYPE_SSIZE_T, TYPE_UINTPTR_T, TYPE_VARIADIC, TYPE_VOID, and TYPE_VOIDP.

## ◆ rb_fiddle_value_to_generic()

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

Definition at line 203 of file conversions.c.

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

Referenced by value_to_generic().

## ◆ value_to_generic()

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

Definition at line 263 of file conversions.c.

References rb_fiddle_value_to_generic().