class GirFFI::Builder::Type::Callback

Implements the creation of a callback type. The type will be attached to the appropriate namespace module, and will be defined as a callback for FFI.

Public Instance Methods

argument_types() click to toggle source
# File lib/gir_ffi/builder/type/callback.rb, line 28
def argument_types
  Builder.ffi_function_argument_types info
end
callback_sym() click to toggle source
# File lib/gir_ffi/builder/type/callback.rb, line 24
def callback_sym
  @classname.to_sym
end
instantiate_class() click to toggle source
# File lib/gir_ffi/builder/type/callback.rb, line 10
def instantiate_class
  @klass = optionally_define_constant namespace_module, @classname do
    lib.callback callback_sym, argument_types, return_type
  end
end
pretty_print() click to toggle source
# File lib/gir_ffi/builder/type/callback.rb, line 16
def pretty_print
  args = argument_types.map do |arg|
    arg.is_a?(FFI::Enum) ? arg.tag : arg.inspect
  end
  return "#{@classname} = Lib.callback #{callback_sym.inspect}, " +
    "[#{args.join(', ')}], #{return_type.inspect}"
end
return_type() click to toggle source
# File lib/gir_ffi/builder/type/callback.rb, line 32
def return_type
  Builder.ffi_function_return_type info
end