Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Functions | Variables
function.c File Reference
#include <fiddle.h>
#include <ruby/thread.h>
Include dependency graph for function.c:

Go to the source code of this file.

Data Structures

struct  nogvl_ffi_call_args
 

Macros

#define RB_OBJ_CLASSNAME(obj)   rb_obj_class(obj)
 
#define RB_OBJ_STRING(obj)   (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

static void deallocate (void *p)
 
static size_t function_memsize (const void *p)
 
static VALUE allocate (VALUE klass)
 
VALUE rb_fiddle_new_function (VALUE address, VALUE arg_types, VALUE ret_type)
 
static int parse_keyword_arg_i (VALUE key, VALUE value, VALUE self)
 
static VALUE initialize (int argc, VALUE argv[], VALUE self)
 
static void * nogvl_ffi_call (void *ptr)
 
static VALUE function_call (int argc, VALUE argv[], VALUE self)
 
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 17 of file function.c.

Referenced by function_call(), and initialize().

◆ Check_Max_Args_

#define Check_Max_Args_ (   name,
  len,
  fmt 
)
Value:
if ((size_t)(len) < MAX_ARGS) { \
/* OK */ \
} \
else { \
rb_raise(rb_eTypeError, \
name" is so large that it can cause integer overflow (%"fmt"d)", \
(len)); \
}
VALUE rb_eTypeError
Definition: error.c:762
#define MAX_ARGS
Definition: function.c:15
register unsigned int len
Definition: zonetab.h:51
const char * name
Definition: nkf.c:208

Definition at line 21 of file function.c.

◆ Check_Max_Args_Long

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

Definition at line 19 of file function.c.

◆ MAX_ARGS

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

Definition at line 15 of file function.c.

Referenced by main().

◆ RB_OBJ_CLASSNAME

#define RB_OBJ_CLASSNAME (   obj)    rb_obj_class(obj)

Definition at line 5 of file function.c.

◆ RB_OBJ_STRING

#define RB_OBJ_STRING (   obj)    (obj)

Definition at line 6 of file function.c.

Referenced by parse_keyword_arg_i().

Function Documentation

◆ allocate()

static VALUE allocate ( VALUE  klass)
static

Definition at line 59 of file function.c.

References callback_args::cif, and TypedData_Make_Struct.

Referenced by Init_fiddle_function().

◆ deallocate()

static void deallocate ( void *  p)
static

Definition at line 32 of file function.c.

References xfree().

◆ function_call()

static VALUE function_call ( int  argc,
VALUE  argv[],
VALUE  self 
)
static

◆ function_memsize()

static size_t function_memsize ( const void *  p)
static

Definition at line 40 of file function.c.

References ffi_raw_size(), and size.

◆ Init_fiddle_function()

void Init_fiddle_function ( void  )

◆ initialize()

static VALUE initialize ( int  argc,
VALUE  argv[],
VALUE  self 
)
static

◆ nogvl_ffi_call()

static void* nogvl_ffi_call ( void *  ptr)
static

◆ parse_keyword_arg_i()

static int parse_keyword_arg_i ( VALUE  key,
VALUE  value,
VALUE  self 
)
static

Definition at line 79 of file function.c.

References ID2SYM, PRIsVALUE, rb_eArgError, rb_intern, rb_iv_set(), RB_OBJ_STRING, rb_raise(), and ST_CONTINUE.

Referenced by initialize().

◆ rb_fiddle_new_function()

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

Definition at line 67 of file function.c.

References argv, cFiddleFunction, and rb_class_new_instance().

Referenced by rb_fiddle_ptr_free_get().

Variable Documentation

◆ cFiddleFunction

VALUE cFiddleFunction

Definition at line 13 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",
}
static void deallocate(void *p)
Definition: function.c:32
static size_t function_memsize(const void *p)
Definition: function.c:40

Definition at line 53 of file function.c.