Ruby
2.7.1p83(2020-03-31revisiona0c7c23c9cec0d0ffcba012279cd652d28ad5bf3)
|
Go to the documentation of this file.
5 # define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
6 # define RB_OBJ_STRING(obj) (obj)
9 # define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
10 # define RB_OBJ_STRING(obj) StringValueCStr(obj)
15 #define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
17 #define Check_Max_Args(name, len) \
18 Check_Max_Args_(name, len, "")
19 #define Check_Max_Args_Long(name, len) \
20 Check_Max_Args_(name, len, "l")
21 #define Check_Max_Args_(name, len, fmt) \
22 if ((size_t)(len) < MAX_ARGS) { \
26 rb_raise(rb_eTypeError, \
27 name" is so large that it can cause integer overflow (%"fmt"d)", \
40 function_memsize(
const void *p)
42 ffi_cif *
ptr = (ffi_cif *)p;
46 #if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
55 {0, deallocate, function_memsize,},
94 ffi_type **arg_types, *rtype;
127 rb_iv_set(
self,
"@return_type", ret_type);
134 arg_types =
xcalloc(
len + 1,
sizeof(ffi_type *));
158 nogvl_ffi_call(
void *
ptr)
174 VALUE alloc_buffer = 0;
187 generic_args =
ALLOCV(alloc_buffer,
189 args.
values = (
void **)((
char *)generic_args +
207 args.
values[
i] = (
void *)&generic_args[
i];
271 #ifdef HAVE_CONST_FFI_STDCALL
#define TypedData_Make_Struct(klass, type, data_type, sval)
#define GENERIC2VALUE(_type, _retval)
#define VALUE2GENERIC(_type, _src, _dst)
void rb_ary_store(VALUE ary, long idx, VALUE val)
VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_Integer(VALUE)
Equivalent to Kernel#Integer in Ruby.
#define RARRAY_LENINT(ary)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_iv_get(VALUE, const char *)
#define INT2FFI_TYPE(_type)
#define rb_ary_subseq(ary, beg, len)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
#define RARRAY_AREF(a, i)
void rb_hash_foreach(VALUE hash, rb_foreach_func *func, VALUE farg)
MJIT_STATIC void rb_error_arity(int argc, int min, int max)
size_t ffi_raw_size(ffi_cif *cif)
#define RB_OBJ_STRING(obj)
RUBY_EXTERN VALUE rb_cObject
#define TypedData_Get_Struct(obj, type, data_type, sval)
void Init_fiddle_function(void)
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs, ffi_type *rtype, ffi_type **atypes)
void rb_define_const(VALUE, const char *, VALUE)
#define Check_Max_Args(name, len)
void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
Allocates and initializes an instance of klass.
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
const rb_data_type_t function_data_type
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE type(ANYARGS)
ANYARGS-ed function type.
VALUE rb_iv_set(VALUE, const char *, VALUE)
VALUE rb_const_get(VALUE, ID)