Ruby: ext/fiddle/function.c File Reference

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

Data Structures | Macros | Functions | Variables
function.c File Reference
`#include <fiddle.h>`
`#include <ruby/thread.h>`
`#include <stdbool.h>`

Go to the source code of this file.

## Data Structures
struct | nogvl_ffi_call_args

## Macros
#define | PRIsVALUE "s"
#define | RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
#define | RB_OBJ_STRING(obj) StringValueCStr(obj)
#define | MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
#define | Check_Max_Args(name, len) Check_Max_Args_(name, len, "")
#define | Check_Max_Args_Long(name, len) Check_Max_Args_(name, len, "l")
#define | Check_Max_Args_(name, len, fmt)

## Functions
VALUE | rb_fiddle_new_function (VALUE address, VALUE arg_types, VALUE ret_type)
void | Init_fiddle_function (void)

## Variables
VALUE | cFiddleFunction
const rb_data_type_t | function_data_type

## Macro Definition Documentation

## ◆ Check_Max_Args

#define Check_Max_Args | ( |  | name,
|  |  | len
| ) |  | Check_Max_Args_(name, len, "")

Definition at line 19 of file function.c.

## ◆ Check_Max_Args_

#define Check_Max_Args_ | ( |  | name,
|  |  | len,
|  |  | fmt
| ) |  |

Value:
do { \
if ((size_t)(len) >= MAX_ARGS) { \
rb_raise(rb_eTypeError, \
"%s is so large " \
"that it can cause integer overflow (%"fmt"d)", \
(name), (len)); \
} \
} while (0)
len
uint8_t len
Definition: escape.c:17
MAX_ARGS
#define MAX_ARGS
Definition: function.c:17
rb_eTypeError
VALUE rb_eTypeError
Definition: error.c:1057
name
const char * name
Definition: nkf.c:208

Definition at line 23 of file function.c.

## ◆ Check_Max_Args_Long

#define Check_Max_Args_Long | ( |  | name,
|  |  | len
| ) |  | Check_Max_Args_(name, len, "l")

Definition at line 21 of file function.c.

## ◆ MAX_ARGS

#define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)

Definition at line 17 of file function.c.

## ◆ PRIsVALUE

#define PRIsVALUE "s"

Definition at line 10 of file function.c.

## ◆ RB_OBJ_CLASSNAME

#define RB_OBJ_CLASSNAME | ( |  | obj | ) | rb_obj_classname(obj)

Definition at line 11 of file function.c.

## ◆ RB_OBJ_STRING

#define RB_OBJ_STRING | ( |  | obj | ) | StringValueCStr(obj)

Definition at line 12 of file function.c.

## Function Documentation

## ◆ Init_fiddle_function()

void Init_fiddle_function | ( | void |  | ) |

Definition at line 396 of file function.c.

References cFiddleFunction, FFI_DEFAULT_ABI, FFI_STDCALL, INT2NUM, mFiddle, rb_cObject, rb_define_alloc_func(), rb_define_class_under(), rb_define_const(), and rb_define_method.

Referenced by Init_fiddle().

## ◆ rb_fiddle_new_function()

VALUE rb_fiddle_new_function | ( | VALUE | address,
|  | VALUE | arg_types,
|  | VALUE | ret_type
| ) |  |

Definition at line 69 of file function.c.

References argv, cFiddleFunction, and rb_class_new_instance().

## Variable Documentation

## ◆ cFiddleFunction

VALUE cFiddleFunction

Definition at line 15 of file function.c.

Referenced by Init_fiddle_function(), and rb_fiddle_new_function().

## ◆ function_data_type

const rb_data_type_t function_data_type

Initial value:
= {
"fiddle/function",
{0, deallocate, function_memsize,},
}

Definition at line 55 of file function.c.