Type:
Class
Constants:
DEFAULT : Document-const

DEFAULT

Default ABI

STDCALL : Document-const

STDCALL

FFI implementation of WIN32 stdcall convention

Description

A representation of a C function

Examples

'strcpy'

1
2
3
4
5
6
7
8
9
10
11
12
13
@libc = Fiddle.dlopen "/lib/libc.so.6"
   #=> #<Fiddle::Handle:0x00000001d7a8d8>
f = Fiddle::Function.new(
  @libc['strcpy'],
  [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
  Fiddle::TYPE_VOIDP)
   #=> #<Fiddle::Function:0x00000001d8ee00>
buff = "000"
   #=> "000"
str = f.call(buff, "123")
   #=> #<Fiddle::Pointer:0x00000001d0c380 ptr=0x000000018a21b8 size=0 free=0x00000000000000>
str.to_s
=> "123"

ABI check

1
2
3
4
5
6
@libc = DL.dlopen "/lib/libc.so.6"
   #=> #<Fiddle::Handle:0x00000001d7a8d8>
f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
   #=> #<Fiddle::Function:0x00000001d8ee00>
f.abi == Fiddle::Function::DEFAULT
   #=> true
to_i
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Function

to_i() Instance Public methods The integer memory location of this function

2025-01-10 15:47:30
call
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Function

call(*args) Instance Public methods Calls the constructed

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Fiddle/Fiddle::Function

new(ptr, args, ret_type, abi = DEFAULT) Class Public methods Constructs a

2025-01-10 15:47:30