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.
24 25 26 27 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 24 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
29 30 31 32 33 34 35 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 29 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 21 |
# 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) # FIXME: Logically, this should use CallbackBase#to_native 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?
46 47 48 49 50 51 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 46 def ffi_callback_argument_types types = args.map do |arg| arg.to_callback_ffitype end types.unshift(:pointer).push(:pointer) end |
#gvalue_for_return_value ⇒ Object
37 38 39 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 37 def gvalue_for_return_value return_type.make_g_value end |
#return_ffi_type ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/gir_ffi/info_ext/i_signal_info.rb', line 53 def return_ffi_type result = return_type.to_ffitype if result == GLib::Boolean :bool else result end end |