Module: GirFFI::InfoExt::ISignalInfo
- Defined in:
- lib/gir_ffi/info_ext/i_signal_info.rb
Overview
Extensions for GObjectIntrospection::ISignalInfo needed by GirFFI
Instance Method Summary collapse
-
#arguments_to_gvalue_array_pointer(object, args) ⇒ Object
TODO: Use argument info to convert out arguments and array lengths.
- #arguments_to_gvalues(instance, arguments) ⇒ Object
-
#create_callback(&block) ⇒ FFI::Function
Create a signal hander callback.
-
#ffi_callback_argument_types ⇒ Object
TODO: Rename and clarify relation to argument_ffi_types: The types returned by ffi_callback_argument_types are more basic than those returned by argument_ffi_types.
- #gvalue_for_return_value ⇒ Object
- #return_ffi_type ⇒ Object
Instance Method Details
#arguments_to_gvalue_array_pointer(object, args) ⇒ Object
TODO: Use argument info to convert out arguments and array lengths.
23 24 25 26 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 23 def arguments_to_gvalue_array_pointer object, args arr = arguments_to_gvalues object, args GirFFI::InPointer.from_array GObject::Value, arr end |
#arguments_to_gvalues(instance, arguments) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 28 def arguments_to_gvalues instance, arguments arg_values = self.args.zip(arguments).map do |info, arg| info.argument_type.make_g_value.set_value(arg) end arg_values.unshift GObject::Value.wrap_instance(instance) end |
#create_callback(&block) ⇒ FFI::Function
Create a signal hander callback. Wraps the given block in such a way that arguments and return value are cast correctly to the ruby world and back.
12 13 14 15 16 17 18 19 20 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 12 def create_callback &block raise ArgumentError, "Block needed" unless block # TODO: Find the signal module directly, then retrieve the info # from that, instead of vice versa. bldr = Builders::SignalBuilder.new(self) wrapped = bldr.build_class.from(block) FFI::Function.new return_ffi_type, ffi_callback_argument_types, &wrapped end |
#ffi_callback_argument_types ⇒ Object
TODO: Rename and clarify relation to argument_ffi_types: The types returned by ffi_callback_argument_types are more basic than those returned by argument_ffi_types. Is there a way to make these methods more related? Perhaps argument_ffi_types can return more basic types as well?
45 46 47 48 49 50 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 45 def ffi_callback_argument_types types = args.map do |arg| arg.argument_type.to_callback_ffitype end types.unshift(:pointer).push(:pointer) end |
#gvalue_for_return_value ⇒ Object
36 37 38 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 36 def gvalue_for_return_value return_type.make_g_value end |