Class: Fiddle::Closure
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | ext/fiddle/closure.c, ext/fiddle/pinned.c, ext/fiddle/lib/fiddle/closure.rb |
Overview
Description
An FFI closure wrapper, for handling callbacks.
Example
closure = Class.new(Fiddle::Closure) {
def call
10
end
}.new(Fiddle::TYPE_INT, [])
#=> #<#<Class:0x0000000150d308>:0x0000000150d240>
func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT)
#=> #<Fiddle::Function:0x00000001516e58>
func.call
#=> 10
Class Method Summary
-
.new(object) ⇒ Pinned
constructor
Alias for Pinned.new.
Instance Attribute Summary
Instance Method Summary
-
#to_i
Returns the memory address for this closure.
Constructor Details
.new(object) ⇒ Pinned
Alias for Pinned.new.
Instance Attribute Details
#args (readonly)
arguments of the FFI closure
# File 'ext/fiddle/lib/fiddle/closure.rb', line 9
attr_reader :args
#ctype (readonly)
the C type of the return of the FFI closure
# File 'ext/fiddle/lib/fiddle/closure.rb', line 6
attr_reader :ctype
Instance Method Details
#to_i
Returns the memory address for this closure
# File 'ext/fiddle/closure.c', line 293
static VALUE to_i(VALUE self) { fiddle_closure * cl; void *code; TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, cl); code = cl->code; return PTR2NUM(code); }