gir_ffi 0.0.14 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/History.txt +6 -0
  2. data/README.rdoc +36 -12
  3. data/examples/01_empty_window.rb +1 -3
  4. data/examples/02_hello_world.rb +1 -3
  5. data/examples/03_upgraded_hello_world.rb +1 -3
  6. data/examples/04_webkit.rb +2 -2
  7. data/examples/05_notification.rb +1 -2
  8. data/examples/print_class.rb +6 -4
  9. data/lib/ffi-glib.rb +107 -0
  10. data/lib/ffi-glib/array.rb +14 -0
  11. data/lib/ffi-glib/byte_array.rb +10 -0
  12. data/lib/ffi-glib/hash_table.rb +55 -0
  13. data/lib/ffi-glib/list.rb +9 -0
  14. data/lib/ffi-glib/list_methods.rb +31 -0
  15. data/lib/ffi-glib/s_list.rb +9 -0
  16. data/lib/ffi-gobject.rb +94 -0
  17. data/lib/ffi-gobject/closure.rb +12 -0
  18. data/lib/ffi-gobject/helper.rb +119 -0
  19. data/lib/ffi-gobject/initially_unowned.rb +10 -0
  20. data/lib/ffi-gobject/ruby_closure.rb +47 -0
  21. data/lib/ffi-gobject/value.rb +65 -0
  22. data/lib/ffi-gobject_introspection.rb +3 -0
  23. data/lib/{gir_ffi → ffi-gobject_introspection}/g_error.rb +1 -1
  24. data/lib/ffi-gobject_introspection/gobject_lib.rb +7 -0
  25. data/lib/{gir_ffi → ffi-gobject_introspection}/i_arg_info.rb +2 -2
  26. data/lib/{gir_ffi → ffi-gobject_introspection}/i_base_info.rb +1 -1
  27. data/lib/{gir_ffi → ffi-gobject_introspection}/i_callable_info.rb +4 -4
  28. data/lib/{gir_ffi → ffi-gobject_introspection}/i_callback_info.rb +1 -1
  29. data/lib/{gir_ffi → ffi-gobject_introspection}/i_constant_info.rb +2 -3
  30. data/lib/{gir_ffi → ffi-gobject_introspection}/i_enum_info.rb +1 -1
  31. data/lib/{gir_ffi → ffi-gobject_introspection}/i_field_info.rb +1 -1
  32. data/lib/{gir_ffi → ffi-gobject_introspection}/i_flags_info.rb +1 -1
  33. data/lib/{gir_ffi → ffi-gobject_introspection}/i_function_info.rb +1 -1
  34. data/lib/{gir_ffi → ffi-gobject_introspection}/i_interface_info.rb +1 -1
  35. data/lib/{gir_ffi → ffi-gobject_introspection}/i_object_info.rb +1 -1
  36. data/lib/{gir_ffi → ffi-gobject_introspection}/i_property_info.rb +1 -1
  37. data/lib/{gir_ffi → ffi-gobject_introspection}/i_registered_type_info.rb +1 -1
  38. data/lib/{gir_ffi → ffi-gobject_introspection}/i_repository.rb +37 -23
  39. data/lib/{gir_ffi → ffi-gobject_introspection}/i_signal_info.rb +1 -1
  40. data/lib/{gir_ffi → ffi-gobject_introspection}/i_struct_info.rb +1 -1
  41. data/lib/{gir_ffi → ffi-gobject_introspection}/i_type_info.rb +2 -2
  42. data/lib/{gir_ffi → ffi-gobject_introspection}/i_union_info.rb +1 -1
  43. data/lib/{gir_ffi → ffi-gobject_introspection}/i_value_info.rb +1 -1
  44. data/lib/{gir_ffi → ffi-gobject_introspection}/i_vfunc_info.rb +1 -1
  45. data/lib/{gir_ffi → ffi-gobject_introspection}/lib.rb +1 -1
  46. data/lib/ffi-gtk/base.rb +17 -0
  47. data/lib/ffi-gtk2.rb +5 -0
  48. data/lib/ffi-gtk3.rb +5 -0
  49. data/lib/gir_ffi.rb +11 -4
  50. data/lib/gir_ffi/arg_helper.rb +5 -4
  51. data/lib/gir_ffi/builder.rb +3 -25
  52. data/lib/gir_ffi/builder/argument.rb +0 -2
  53. data/lib/gir_ffi/builder/argument/hash_table_base.rb +1 -1
  54. data/lib/gir_ffi/builder/argument/list_base.rb +1 -1
  55. data/lib/gir_ffi/builder/module.rb +1 -6
  56. data/lib/gir_ffi/builder/type/unintrospectable.rb +1 -1
  57. data/lib/gir_ffi/callback_helper.rb +14 -7
  58. data/lib/gir_ffi/in_out_pointer.rb +1 -1
  59. data/lib/gir_ffi/in_pointer.rb +1 -1
  60. data/lib/gir_ffi/module_base.rb +4 -0
  61. data/lib/gir_ffi/type_map.rb +29 -0
  62. data/lib/gir_ffi/version.rb +1 -1
  63. data/tasks/test.rake +20 -1
  64. data/test/arg_helper_test.rb +10 -13
  65. data/test/builder_test.rb +2 -2
  66. data/test/class_base_test.rb +1 -1
  67. data/test/{glib_overrides_test.rb → ffi-glib/glib_overrides_test.rb} +3 -5
  68. data/test/{g_object_overrides_test.rb → ffi-gobject/g_object_overrides_test.rb} +7 -37
  69. data/test/ffi-gobject/gobject_test.rb +22 -0
  70. data/test/ffi-gobject/value_test.rb +34 -0
  71. data/test/{unit → ffi-gobject_introspection}/i_base_info_test.rb +2 -2
  72. data/test/{unit → ffi-gobject_introspection}/i_constant_info_test.rb +1 -1
  73. data/test/ffi-gobject_introspection/i_object_info_test.rb +20 -0
  74. data/test/{unit → ffi-gobject_introspection}/i_repository_test.rb +11 -11
  75. data/test/function_definition_builder_test.rb +1 -1
  76. data/test/gir_ffi_test_helper.rb +114 -0
  77. data/test/girffi_test.rb +2 -2
  78. data/test/gtk_overrides_test.rb +15 -12
  79. data/test/integration/generated_gimarshallingtests_test.rb +10 -5
  80. data/test/integration/generated_gio_test.rb +1 -1
  81. data/test/integration/generated_gobject_test.rb +1 -1
  82. data/test/integration/generated_gtk_test.rb +3 -3
  83. data/test/integration/generated_regress_test.rb +11 -3
  84. data/test/interface_type_builder_test.rb +1 -1
  85. data/test/module_builder_test.rb +1 -1
  86. data/test/test_helper.rb +2 -111
  87. data/test/type_builder_test.rb +2 -2
  88. data/test/unintrospectable_type_builder_test.rb +1 -1
  89. data/test/unit/builder_test.rb +1 -1
  90. data/test/unit/callback_helper_test.rb +13 -10
  91. data/test/unit/constant_builder_test.rb +1 -1
  92. data/test/unit/in_out_pointer_test.rb +1 -1
  93. data/test/unit/in_pointer_test.rb +1 -1
  94. data/test/unit/object_type_builder_test.rb +1 -1
  95. metadata +62 -43
  96. data/lib/gir_ffi/g_object.rb +0 -38
  97. data/lib/gir_ffi/overrides/glib.rb +0 -225
  98. data/lib/gir_ffi/overrides/gobject.rb +0 -330
  99. data/lib/gir_ffi/overrides/gtk.rb +0 -29
  100. data/test/g_object_test.rb +0 -21
  101. data/test/i_object_info_test.rb +0 -20
@@ -1,3 +1,9 @@
1
+ == 0.1.0 / 2011-10-28
2
+
3
+ * Put bindings for GObjectIntrospection in their own namespace.
4
+ * GirFFI.setup no longer loads overrides.
5
+ * Add ffi-gtk2 and ffi-gtk3 files for loading Gtk+ overrides.
6
+
1
7
  == 0.0.14 / 2011-10-28
2
8
 
3
9
  * Support GObject Introspection version 1.30:
@@ -8,18 +8,48 @@ http://www.github.com/mvz/ruby-gir-ffi
8
8
 
9
9
  Ruby bindings for GNOME using the GObject Introspection Repository.
10
10
 
11
- == Features/Problems
11
+ == Features/Notes
12
12
 
13
- * Create bindings to GObject-based libraries at runtime
14
- * Almost, but not entirely done yet
13
+ * Create bindings to any GObject-based library.
14
+ * Supports both Gtk+ 2 and Gtk+ 3.
15
+ * Bindings generated at runtime.
16
+ * Provides overridden bindings for selected methods.
17
+ * Require 'ffi-gtk2' or 'ffi-gtk3' to load overrides for Gtk2 or Gtk3.
18
+
19
+ == Install
20
+
21
+ * sudo gem install gir_ffi
15
22
 
16
23
  == Synopsis
17
24
 
25
+ Basic usage:
26
+
18
27
  require 'gir_ffi'
19
28
 
20
- GirFFI.setup :Gtk
29
+ GirFFI.setup :TheNamespace
30
+
31
+ TheNamespace.some_function
32
+
33
+ obj = TheNamespace::SomeClass.new
34
+ obj.some_method with, some, args
35
+
36
+ Gtk2:
37
+
38
+ require 'ffi-gtk2'
21
39
  Gtk.init
22
40
  win = Gtk::Window.new :toplevel
41
+ win.show
42
+ GObject.signal_connect(win, "destroy") { Gtk.main_quit }
43
+ Gtk.main
44
+
45
+ Gtk3:
46
+
47
+ require 'ffi-gtk3'
48
+ Gtk.init
49
+ win = Gtk::Window.new :toplevel
50
+ win.show
51
+ GObject.signal_connect(win, "destroy") { Gtk.main_quit }
52
+ Gtk.main
23
53
 
24
54
  See the `examples/` directory for more, well, examples.
25
55
 
@@ -40,10 +70,8 @@ On Debian and Ubuntu, the following set of packages should be enough to get
40
70
 
41
71
  == Hacking and contributing
42
72
 
43
- This is still very much a work in progress. You can start exploring by
44
- running the example programs in the `examples/` folder. Some illustrate
45
- what works, some are a test bed for how things should work. Have a look at
46
- the output of `rake notes`. Feel free to file bugs or send pull requests.
73
+ If you want to help out, have a look at TODO.rdoc, and the output of `rake
74
+ notes`. Feel free to file bugs or send pull requests.
47
75
 
48
76
  If you want to send pull requests or patches, please:
49
77
 
@@ -56,10 +84,6 @@ If you want to send pull requests or patches, please:
56
84
  * Try not to include changes that are irrelevant to your feature in the
57
85
  same commit.
58
86
 
59
- == Install
60
-
61
- * sudo gem install gir_ffi
62
-
63
87
  == License
64
88
 
65
89
  Copyright (c) 2009--2011 Matijs van Zuijlen
@@ -3,9 +3,7 @@
3
3
  # http://library.gnome.org/devel/gtk-tutorial/2.90/c39.html
4
4
  #
5
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
- require 'gir_ffi'
7
-
8
- GirFFI.setup :Gtk, '2.0'
6
+ require 'ffi-gtk3'
9
7
 
10
8
  Gtk.init
11
9
  win = Gtk::Window.new :toplevel
@@ -3,9 +3,7 @@
3
3
  # http://library.gnome.org/devel/gtk-tutorial/2.90/c39.html#SEC-HELLOWORLD
4
4
  #
5
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
- require 'gir_ffi'
7
-
8
- GirFFI.setup :Gtk, '2.0'
6
+ require 'ffi-gtk3'
9
7
 
10
8
  Gtk.init
11
9
 
@@ -3,9 +3,7 @@
3
3
  # http://library.gnome.org/devel/gtk-tutorial/2.90/x344.html
4
4
  #
5
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
- require 'gir_ffi'
7
-
8
- GirFFI.setup :Gtk, '2.0'
6
+ require 'ffi-gtk3'
9
7
 
10
8
  callback = lambda { |widget, data|
11
9
  puts "Hello again - #{data} was pressed"
@@ -1,8 +1,8 @@
1
1
  # Based on http://www.idle-hacking.com/2010/02/webkit-ruby-and-gtk/
2
2
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
- require 'gir_ffi'
3
+ require 'ffi-gtk3'
4
4
 
5
- GirFFI.setup :WebKit, '1.0'
5
+ GirFFI.setup :WebKit, '3.0'
6
6
 
7
7
  Gtk.init
8
8
 
@@ -2,9 +2,8 @@
2
2
  # Simple notification example.
3
3
  #
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
5
- require 'gir_ffi'
5
+ require 'ffi-gtk3'
6
6
 
7
- GirFFI.setup :Gtk
8
7
  GirFFI.setup :Notify
9
8
 
10
9
  # Both Gtk and Notify need to be init'ed.
@@ -1,3 +1,4 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
1
2
  require 'gir_ffi'
2
3
 
3
4
  # File activesupport/lib/active_support/inflector/methods.rb, line 48
@@ -11,10 +12,11 @@ def underscore(camel_cased_word)
11
12
  word
12
13
  end
13
14
 
14
- namespace = 'Tracker'
15
+ namespace = 'GObject'
15
16
  GirFFI.setup namespace
17
+ modul = Kernel.const_get(namespace)
16
18
 
17
- gir = GirFFI::IRepository.default
19
+ gir = GObjectIntrospection::IRepository.default
18
20
  gir.require namespace, nil
19
21
  infos = gir.infos namespace
20
22
 
@@ -25,7 +27,7 @@ main_file.write "module #{namespace}\n"
25
27
  infos.each do |info|
26
28
  case info.info_type
27
29
  when :function
28
- fbuilder = GirFFI::Builder::Function.new info, Tracker::Lib
30
+ fbuilder = GirFFI::Builder::Function.new info, modul::Lib
29
31
  main_file.write "\n"
30
32
  main_file.write fbuilder.generate
31
33
  main_file.write "\n"
@@ -41,7 +43,7 @@ infos.each do |info|
41
43
  end
42
44
  main_file.write "# @return [#{minfo.return_type.tag}]\n"
43
45
 
44
- fbuilder = GirFFI::Builder::Function.new minfo, Tracker::Lib
46
+ fbuilder = GirFFI::Builder::Function.new minfo, modul::Lib
45
47
  main_file.write fbuilder.generate
46
48
  unless minfo.method?
47
49
  main_file.write "end\n"
@@ -0,0 +1,107 @@
1
+ GirFFI.setup :GLib
2
+
3
+ require 'ffi-glib/s_list'
4
+ require 'ffi-glib/list'
5
+ require 'ffi-glib/hash_table'
6
+ require 'ffi-glib/byte_array'
7
+ require 'ffi-glib/array'
8
+
9
+ module GLib
10
+ # FIXME: Turn into real constructor
11
+ def self.slist_new elmttype
12
+ ::GLib::List._real_new(FFI::Pointer.new(0)).tap {|it|
13
+ it.element_type = elmttype}
14
+ end
15
+
16
+ # FIXME: Turn into instance method; Use element type.
17
+ def self.slist_prepend slist, data
18
+ ::GLib::SList.wrap(slist.element_type, ::GLib::Lib.g_slist_prepend(slist, data))
19
+ end
20
+
21
+ # FIXME: Turn into real constructor
22
+ def self.list_new elmttype
23
+ ::GLib::List._real_new(FFI::Pointer.new(0)).tap {|it|
24
+ it.element_type = elmttype}
25
+ end
26
+
27
+ # FIXME: Turn into instance method; Use element type.
28
+ def self.list_append list, data
29
+ ::GLib::List.wrap(list.element_type, ::GLib::Lib.g_list_append(list, data))
30
+ end
31
+
32
+ # FIXME: Turn into real constructor
33
+ def self.hash_table_new keytype, valtype
34
+ hash_fn, eq_fn = case keytype
35
+ when :utf8
36
+ lib = ::GLib::Lib.ffi_libraries.first
37
+ [ FFI::Function.new(:uint, [:pointer], lib.find_function("g_str_hash")),
38
+ FFI::Function.new(:int, [:pointer, :pointer], lib.find_function("g_str_equal"))]
39
+ else
40
+ [nil, nil]
41
+ end
42
+
43
+ ::GLib::HashTable.wrap(keytype, valtype, ::GLib::Lib.g_hash_table_new(hash_fn, eq_fn))
44
+ end
45
+
46
+ # FIXME: Turn into real constructor
47
+ def self.byte_array_new
48
+ ::GLib::ByteArray.wrap(::GLib::Lib.g_byte_array_new)
49
+ end
50
+
51
+ # FIXME: Turn into instance method
52
+ def self.byte_array_append arr, data
53
+ bytes = GirFFI::InPointer.from :utf8, data
54
+ len = data.bytesize
55
+ ::GLib::ByteArray.wrap(::GLib::Lib.g_byte_array_append arr.to_ptr, bytes, len)
56
+ end
57
+
58
+ # FIXME: Turn into real constructor
59
+ def self.array_new type
60
+ ffi_type = type == :utf8 ? :pointer : type
61
+ arr = ::GLib::Array.wrap(
62
+ ::GLib::Lib.g_array_new(0, 0, FFI.type_size(ffi_type)))
63
+ arr.element_type = type
64
+ arr
65
+ end
66
+
67
+ # FIXME: Turn into instance method
68
+ def self.array_append_vals arr, data
69
+ bytes = GirFFI::InPointer.from_array arr.element_type, data
70
+ len = data.length
71
+ res = ::GLib::Array.wrap(
72
+ ::GLib::Lib.g_array_append_vals(arr.to_ptr, bytes, len))
73
+ res.element_type = arr.element_type
74
+ res
75
+ end
76
+
77
+ # FIXME: Turn into real constructor?
78
+ def self.main_loop_new context, is_running
79
+ ::GLib::MainLoop.wrap(::GLib::Lib.g_main_loop_new context, is_running)
80
+ end
81
+
82
+ load_class :HFunc
83
+ load_class :HashFunc
84
+ load_class :EqualFunc
85
+ module Lib
86
+ attach_function :g_slist_prepend, [:pointer, :pointer], :pointer
87
+
88
+ attach_function :g_list_append, [:pointer, :pointer], :pointer
89
+
90
+ attach_function :g_hash_table_foreach,
91
+ [:pointer, HFunc, :pointer], :void
92
+ attach_function :g_hash_table_new,
93
+ [HashFunc, EqualFunc], :pointer
94
+ attach_function :g_hash_table_insert,
95
+ [:pointer, :pointer, :pointer], :void
96
+
97
+ attach_function :g_byte_array_new, [], :pointer
98
+ attach_function :g_byte_array_append,
99
+ [:pointer, :pointer, :uint], :pointer
100
+
101
+ attach_function :g_array_new, [:int, :int, :uint], :pointer
102
+ attach_function :g_array_append_vals,
103
+ [:pointer, :pointer, :uint], :pointer
104
+
105
+ attach_function :g_main_loop_new, [:pointer, :bool], :pointer
106
+ end
107
+ end
@@ -0,0 +1,14 @@
1
+ module GLib
2
+ load_class :Array
3
+
4
+ class Array
5
+ attr_accessor :element_type
6
+
7
+ def to_a
8
+ GirFFI::ArgHelper.ptr_to_typed_array(self.element_type,
9
+ self[:data], self[:len])
10
+ end
11
+ end
12
+ end
13
+
14
+
@@ -0,0 +1,10 @@
1
+ module GLib
2
+ load_class :ByteArray
3
+
4
+ class ByteArray
5
+ def to_string
6
+ GirFFI::ArgHelper.ptr_to_utf8_length self[:data], self[:len]
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,55 @@
1
+ module GLib
2
+ load_class :HashTable
3
+
4
+ class HashTable
5
+ include Enumerable
6
+ attr_accessor :key_type
7
+ attr_accessor :value_type
8
+
9
+ def each
10
+ prc = Proc.new {|keyptr, valptr, userdata|
11
+ key = cast_from_pointer key_type, keyptr
12
+ val = cast_from_pointer value_type, valptr
13
+ yield key, val
14
+ }
15
+ ::GLib::Lib.g_hash_table_foreach self.to_ptr, prc, nil
16
+ end
17
+
18
+ def to_hash
19
+ Hash[self.to_a]
20
+ end
21
+
22
+ def insert key, value
23
+ keyptr = cast_to_pointer key_type, key
24
+ valptr = cast_to_pointer value_type, value
25
+ ::GLib::Lib.g_hash_table_insert self.to_ptr, keyptr, valptr
26
+ end
27
+
28
+ def cast_to_pointer type, it
29
+ if type == :utf8
30
+ GirFFI::InPointer.from :utf8, it
31
+ else
32
+ FFI::Pointer.new(it)
33
+ end
34
+ end
35
+
36
+ def cast_from_pointer type, it
37
+ case type
38
+ when :utf8
39
+ GirFFI::ArgHelper.ptr_to_utf8 it
40
+ when :gint32
41
+ GirFFI::ArgHelper.cast_pointer_to_int32 it
42
+ else
43
+ it.address
44
+ end
45
+ end
46
+
47
+ def self.wrap keytype, valtype, ptr
48
+ super(ptr).tap do |it|
49
+ break if it.nil?
50
+ it.key_type = keytype
51
+ it.value_type = valtype
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,9 @@
1
+ require 'ffi-glib/list_methods'
2
+
3
+ module GLib
4
+ load_class :List
5
+
6
+ class List
7
+ include ListMethods
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ module GLib
2
+ module ListMethods
3
+ include Enumerable
4
+ attr_accessor :element_type
5
+
6
+ def self.included base
7
+ base.extend ClassMethods
8
+ end
9
+
10
+ def each
11
+ list = self
12
+ rval = nil
13
+ until list.nil?
14
+ rval = yield GirFFI::ArgHelper.cast_from_pointer(element_type, list[:data])
15
+ list = self.class.wrap(element_type, list[:next])
16
+ end
17
+ rval
18
+ end
19
+
20
+ module ClassMethods
21
+ def wrap elmttype, ptr
22
+ super(ptr).tap do |it|
23
+ break if it.nil?
24
+ it.element_type = elmttype
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+
@@ -0,0 +1,9 @@
1
+ require 'ffi-glib/list_methods'
2
+
3
+ module GLib
4
+ load_class :SList
5
+
6
+ class SList
7
+ include ListMethods
8
+ end
9
+ end
@@ -0,0 +1,94 @@
1
+ GirFFI.setup :GObject
2
+
3
+ require 'ffi-gobject/value'
4
+ require 'ffi-gobject/initially_unowned'
5
+ require 'ffi-gobject/closure'
6
+ require 'ffi-gobject/ruby_closure'
7
+ require 'ffi-gobject/helper'
8
+
9
+ module GObject
10
+ def self.type_init
11
+ Lib::g_type_init
12
+ end
13
+
14
+ def self.object_ref obj
15
+ Lib::g_object_ref obj.to_ptr
16
+ end
17
+
18
+ def self.object_ref_sink obj
19
+ Lib::g_object_ref_sink obj.to_ptr
20
+ end
21
+
22
+ def self.object_unref obj
23
+ Lib::g_object_unref obj.to_ptr
24
+ end
25
+
26
+ def self.object_is_floating obj
27
+ Lib::g_object_is_floating obj.to_ptr
28
+ end
29
+
30
+ def self.type_from_instance_pointer inst_ptr
31
+ klsptr = inst_ptr.get_pointer 0
32
+ klsptr.send "get_#{GirFFI::TypeMap::TAG_TYPE_MAP[:gtype]}", 0
33
+ end
34
+
35
+ def self.type_from_instance instance
36
+ type_from_instance_pointer instance.to_ptr
37
+ end
38
+
39
+ _setup_method :signal_emitv
40
+
41
+ def self.signal_emit object, signal, *args
42
+ type = type_from_instance object
43
+ id = signal_lookup signal, type
44
+
45
+ arr = Helper.signal_arguments_to_gvalue_array signal, object, *args
46
+ rval = Helper.gvalue_for_signal_return_value signal, object
47
+
48
+ ::GObject::Lib.g_signal_emitv arr[:values], id, 0, rval
49
+
50
+ rval
51
+ end
52
+
53
+ def self.signal_connect object, signal, data=nil, &block
54
+ sig = object.class._find_signal signal
55
+ if sig.nil?
56
+ raise "Signal #{signal} is invalid for #{object}"
57
+ end
58
+ if block.nil?
59
+ raise ArgumentError, "Block needed"
60
+ end
61
+
62
+ rettype = GirFFI::Builder.itypeinfo_to_ffitype sig.return_type
63
+
64
+ argtypes = GirFFI::Builder.ffi_argument_types_for_signal sig
65
+
66
+ callback = FFI::Function.new rettype, argtypes,
67
+ &(Helper.signal_callback_args(sig, object.class, &block))
68
+ ::GObject::Lib::CALLBACKS << callback
69
+
70
+ data_ptr = GirFFI::ArgHelper.object_to_inptr data
71
+
72
+ ::GObject::Lib.g_signal_connect_data object, signal, callback, data_ptr, nil, 0
73
+ end
74
+
75
+ load_class :Callback
76
+ load_class :ClosureNotify
77
+ load_class :ConnectFlags
78
+ load_class :ClosureMarshal
79
+
80
+ module Lib
81
+ attach_function :g_type_init, [], :void
82
+ attach_function :g_object_ref, [:pointer], :void
83
+ attach_function :g_object_ref_sink, [:pointer], :void
84
+ attach_function :g_object_unref, [:pointer], :void
85
+ attach_function :g_object_is_floating, [:pointer], :bool
86
+
87
+ attach_function :g_signal_connect_data,
88
+ [:pointer, :string, Callback, :pointer, ClosureNotify,
89
+ ConnectFlags],
90
+ :ulong
91
+ attach_function :g_closure_set_marshal,
92
+ [:pointer, ClosureMarshal], :void
93
+ end
94
+ end