Module: Libvirt::FFI::Helpers

Included in:
Common, Domain, Error, Event, Host, Interface, Network, Storage, Stream
Defined in:
lib/libvirt/ffi/helpers.rb

Instance Method Summary collapse

Instance Method Details

#callback_function(callback, *args) { ... } ⇒ FFI::Function

Creates function by provided callback or callback name

Parameters:

  • callback (Symbol, FFI::CallbackInfo)

    callback name registered in current module

  • args (Array)

    extra arguments for FFI::Function

Yields:

  • when function is called

Returns:

  • (FFI::Function)


11
12
13
14
# File 'lib/libvirt/ffi/helpers.rb', line 11

def callback_function(callback, *args, &block)
  callback_info = callback.is_a?(Symbol) ? find_type(callback) : callback
  ::FFI::Function.new(callback_info.result_type, callback_info.param_types, *args, &block)
end