gir_ffi 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  class FunctionDefinitionBuilderTest < Test::Unit::TestCase
5
4
  context "The FunctionDefinition builder" do
@@ -48,10 +47,10 @@ class FunctionDefinitionBuilderTest < Test::Unit::TestCase
48
47
  "def signal_connect_data instance, detailed_signal, c_handler, data, destroy_data, connect_flags
49
48
  _v1 = GirFFI::ArgHelper.object_to_inptr instance
50
49
  _v2 = GirFFI::ArgHelper.utf8_to_inptr detailed_signal
51
- _v3 = GirFFI::ArgHelper.mapped_callback_args c_handler
50
+ _v3 = GirFFI::ArgHelper.wrap_in_callback_args_mapper \"GObject\", \"Callback\", c_handler
52
51
  ::Lib::CALLBACKS << _v3
53
52
  _v4 = GirFFI::ArgHelper.object_to_inptr data
54
- _v5 = GirFFI::ArgHelper.mapped_callback_args destroy_data
53
+ _v5 = GirFFI::ArgHelper.wrap_in_callback_args_mapper \"GObject\", \"ClosureNotify\", destroy_data
55
54
  ::Lib::CALLBACKS << _v5
56
55
  _v6 = connect_flags
57
56
  _v7 = ::Lib.g_signal_connect_data _v1, _v2, _v3, _v4, _v5, _v6
@@ -73,7 +72,6 @@ class FunctionDefinitionBuilderTest < Test::Unit::TestCase
73
72
  _v2 = ::Lib.test_obj_new_from_file _v1, _v4
74
73
  GirFFI::ArgHelper.check_error(_v4)
75
74
  _v3 = ::Everything::TestObj.wrap(_v2)
76
- GirFFI::ArgHelper.sink_if_floating(_v3)
77
75
  return _v3
78
76
  end"
79
77
 
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  class GObjectOverridesTest < Test::Unit::TestCase
5
4
  context "In the GObject module with overridden functions" do
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi/g_object'
3
2
 
4
3
  class GObjectTest < Test::Unit::TestCase
5
4
  context "The GirFFI::GObject helper module" do
@@ -1,16 +1,7 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  # Tests generated methods and functions in the Everything namespace.
5
- class EverythingTest < Test::Unit::TestCase
6
- def ref_count object
7
- GObject::Object::Struct.new(object.to_ptr)[:ref_count]
8
- end
9
-
10
- def is_floating? object
11
- (GObject::Object::Struct.new(object.to_ptr)[:qdata].address & 2) == 2
12
- end
13
-
4
+ class GeneratedEverythingTest < Test::Unit::TestCase
14
5
  context "The generated Everything module" do
15
6
  setup do
16
7
  GirFFI.setup :Everything
@@ -117,10 +108,18 @@ class EverythingTest < Test::Unit::TestCase
117
108
  assert_equal 623.0, rv
118
109
  end
119
110
 
120
- should "have a working #static_method_callback" do
121
- a = 1
122
- Everything::TestObj.static_method_callback Proc.new { a = 2 }
123
- assert_equal 2, a
111
+ context "#static_method_callback" do
112
+ should "work when called with a Proc" do
113
+ a = 1
114
+ Everything::TestObj.static_method_callback Proc.new { a = 2 }
115
+ assert_equal 2, a
116
+ end
117
+
118
+ should "work when called with nil" do
119
+ assert_nothing_raised do
120
+ Everything::TestObj.static_method_callback nil
121
+ end
122
+ end
124
123
  end
125
124
 
126
125
  context "an instance" do
@@ -0,0 +1,32 @@
1
+ require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
+
3
+ # Tests generated methods and functions in the Gio namespace.
4
+ class GeneratedGioTest < Test::Unit::TestCase
5
+ context "In the generated Gio module" do
6
+ setup do
7
+ GirFFI.setup :Gio
8
+ end
9
+
10
+ should "create a GFile with #file_new_from_path" do
11
+ assert_nothing_raised {
12
+ Gio.file_new_for_path('/')
13
+ }
14
+ end
15
+
16
+ context "the FileInfo class" do
17
+ context "an instance" do
18
+ setup do
19
+ file = Gio.file_new_for_path('/')
20
+ @fileinfo = file.query_info "*", :none, nil
21
+ end
22
+
23
+ should "hava a working #get_attribute_type method" do
24
+ assert_nothing_raised {
25
+ @fileinfo.get_attribute_type "standard::displayname"
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,65 @@
1
+ require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
+
3
+ # Tests generated methods and functions in the Gtk namespace.
4
+ class GeneratedGtkTest < Test::Unit::TestCase
5
+ context "In the generated Gtk module" do
6
+ setup do
7
+ GirFFI.setup :Gtk
8
+ end
9
+
10
+ context "a Gtk::Builder instance" do
11
+ setup do
12
+ @builder = Gtk::Builder.new
13
+ @spec = '
14
+ <interface>
15
+ <object class="GtkButton" id="foo">
16
+ <signal handler="on_button_clicked" name="clicked"/>
17
+ </object>
18
+ </interface>
19
+ '
20
+ end
21
+
22
+ should "load spec" do
23
+ assert_nothing_raised { @builder.add_from_string @spec, @spec.length }
24
+ end
25
+
26
+ context "its #get_object method" do
27
+ should "return objects of the proper class" do
28
+ @builder.add_from_string @spec, @spec.length
29
+ o = @builder.get_object "foo"
30
+ assert_instance_of Gtk::Button, o
31
+ end
32
+ end
33
+
34
+ context "its #connect_signals_full method" do
35
+ setup do
36
+ @builder.add_from_string @spec, @spec.length
37
+ end
38
+ should "pass arguments correctly" do
39
+ aa = nil
40
+ @builder.connect_signals_full Proc.new {|*args| aa = args}, nil
41
+ b, o, sn, hn, co, f, ud = aa
42
+ assert_instance_of Gtk::Builder, b
43
+ assert_equal b.to_ptr, @builder.to_ptr
44
+ assert_instance_of Gtk::Button, o
45
+ assert_equal "clicked", sn
46
+ assert_equal "on_button_clicked", hn
47
+ assert_equal nil, co
48
+ assert_equal :after, f
49
+ assert_equal nil, ud
50
+ end
51
+ end
52
+ end
53
+
54
+ context "a Gtk::Window instance" do
55
+ setup do
56
+ @w = Gtk::Window.new :toplevel
57
+ end
58
+
59
+ should "start with a refcount of 2 (one for us, one for GTK+)" do
60
+ assert_equal 2, ref_count(@w)
61
+ end
62
+ end
63
+ end
64
+ end
65
+
data/test/girffi_test.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  class GirFFITest < Test::Unit::TestCase
5
4
  context "GirFFI" do
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  class GtkOverridesTest < Test::Unit::TestCase
5
4
  context "The Gtk.init function" do
@@ -10,6 +9,7 @@ class GtkOverridesTest < Test::Unit::TestCase
10
9
 
11
10
  should "not take any arguments" do
12
11
  assert_raises(ArgumentError) { Gtk.init 1, ["foo"] }
12
+ assert_raises(ArgumentError) { Gtk.init ["foo"] }
13
13
  assert_nothing_raised { Gtk.init }
14
14
  end
15
15
 
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  module GirFFI
5
4
  class IObjectInfoTest < Test::Unit::TestCase
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi/i_repository'
3
2
 
4
3
  module GirFFI
5
4
  class IRepositoryTest < Test::Unit::TestCase
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require 'gir_ffi'
3
2
 
4
3
  class ModuleBuilderTest < Test::Unit::TestCase
5
4
  context "The ModuleBuilder" do
data/test/test_helper.rb CHANGED
@@ -1,8 +1,11 @@
1
1
  require 'shoulda'
2
2
  require 'rr'
3
3
  require 'ffi'
4
+
4
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
6
 
7
+ require 'gir_ffi'
8
+
6
9
  if RUBY_PLATFORM == 'java'
7
10
  require 'java'
8
11
  JRuby.objectspace = true
@@ -51,4 +54,12 @@ class Test::Unit::TestCase
51
54
  Object.send(:remove_const, name)
52
55
  end
53
56
  end
57
+
58
+ def ref_count object
59
+ GObject::Object::Struct.new(object.to_ptr)[:ref_count]
60
+ end
61
+
62
+ def is_floating? object
63
+ (GObject::Object::Struct.new(object.to_ptr)[:qdata].address & 2) == 2
64
+ end
54
65
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gir_ffi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matijs van Zuijlen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-30 00:00:00 +01:00
18
+ date: 2011-03-01 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -111,6 +111,7 @@ files:
111
111
  - lib/gir_ffi/i_base_info.rb
112
112
  - lib/gir_ffi/module_builder.rb
113
113
  - lib/gir_ffi/arg_helper.rb
114
+ - lib/gir_ffi/argument_builder.rb
114
115
  - lib/gir_ffi/g_object.rb
115
116
  - lib/gir_ffi/i_union_info.rb
116
117
  - lib/gir_ffi/class_builder.rb
@@ -121,16 +122,18 @@ files:
121
122
  - test/function_definition_builder_test.rb
122
123
  - test/g_object_test.rb
123
124
  - test/arg_helper_test.rb
124
- - test/gobject_overrides_test.rb
125
125
  - test/class_base_test.rb
126
126
  - test/test_helper.rb
127
127
  - test/class_builder_test.rb
128
128
  - test/girffi_test.rb
129
129
  - test/module_builder_test.rb
130
130
  - test/i_object_info_test.rb
131
- - test/everything_test.rb
131
+ - test/generated_everything_test.rb
132
+ - test/g_object_overrides_test.rb
133
+ - test/generated_gtk_test.rb
132
134
  - test/builder_test.rb
133
135
  - test/gtk_overrides_test.rb
136
+ - test/generated_gio_test.rb
134
137
  - tasks/test.rake
135
138
  - tasks/setup.rb
136
139
  - tasks/notes.rake
@@ -186,11 +189,13 @@ test_files:
186
189
  - test/builder_test.rb
187
190
  - test/class_base_test.rb
188
191
  - test/class_builder_test.rb
189
- - test/everything_test.rb
190
192
  - test/function_definition_builder_test.rb
193
+ - test/g_object_overrides_test.rb
191
194
  - test/g_object_test.rb
195
+ - test/generated_everything_test.rb
196
+ - test/generated_gio_test.rb
197
+ - test/generated_gtk_test.rb
192
198
  - test/girffi_test.rb
193
- - test/gobject_overrides_test.rb
194
199
  - test/gtk_overrides_test.rb
195
200
  - test/i_object_info_test.rb
196
201
  - test/i_repository_test.rb