gir_ffi 0.2.2 → 0.2.3

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.
Files changed (69) hide show
  1. data/History.txt +6 -0
  2. data/lib/ffi-glib.rb +1 -0
  3. data/lib/ffi-glib/array.rb +49 -10
  4. data/lib/ffi-glib/hash_table.rb +19 -5
  5. data/lib/ffi-glib/list.rb +4 -1
  6. data/lib/ffi-glib/list_methods.rb +8 -1
  7. data/lib/ffi-glib/s_list.rb +4 -1
  8. data/lib/ffi-glib/strv.rb +31 -0
  9. data/lib/ffi-gobject.rb +2 -35
  10. data/lib/ffi-gobject/base.rb +38 -0
  11. data/lib/ffi-gobject/object.rb +28 -30
  12. data/lib/ffi-gobject/value.rb +72 -56
  13. data/lib/ffi-gobject_introspection/i_struct_info.rb +11 -1
  14. data/lib/ffi-gobject_introspection/lib.rb +3 -1
  15. data/lib/gir_ffi/arg_helper.rb +2 -19
  16. data/lib/gir_ffi/builder/argument.rb +239 -305
  17. data/lib/gir_ffi/builder/argument/base.rb +12 -9
  18. data/lib/gir_ffi/builder/argument/in_base.rb +2 -6
  19. data/lib/gir_ffi/builder/argument/in_out_base.rb +2 -5
  20. data/lib/gir_ffi/builder/argument/out_base.rb +0 -11
  21. data/lib/gir_ffi/builder/field.rb +55 -0
  22. data/lib/gir_ffi/builder/function.rb +7 -7
  23. data/lib/gir_ffi/builder/module.rb +5 -7
  24. data/lib/gir_ffi/builder/type/object.rb +0 -33
  25. data/lib/gir_ffi/builder/type/registered_type.rb +0 -16
  26. data/lib/gir_ffi/builder/type/struct_based.rb +3 -3
  27. data/lib/gir_ffi/builder/type/unintrospectable.rb +1 -1
  28. data/lib/gir_ffi/builder/type/with_layout.rb +26 -58
  29. data/lib/gir_ffi/builder/type/with_methods.rb +9 -11
  30. data/lib/gir_ffi/class_base.rb +24 -6
  31. data/lib/gir_ffi/ffi_ext/pointer.rb +15 -0
  32. data/lib/gir_ffi/in_pointer.rb +10 -5
  33. data/lib/gir_ffi/info_ext/i_field_info.rb +15 -0
  34. data/lib/gir_ffi/info_ext/i_type_info.rb +26 -0
  35. data/lib/gir_ffi/method_stubber.rb +18 -0
  36. data/lib/gir_ffi/type_map.rb +1 -0
  37. data/lib/gir_ffi/variable_name_generator.rb +2 -0
  38. data/lib/gir_ffi/version.rb +1 -1
  39. data/test/builder_test.rb +6 -5
  40. data/test/ffi-glib/array_test.rb +40 -5
  41. data/test/ffi-glib/hash_table_test.rb +27 -3
  42. data/test/ffi-glib/list_test.rb +23 -0
  43. data/test/ffi-glib/strv_test.rb +41 -0
  44. data/test/ffi-gobject/gobject_test.rb +26 -22
  45. data/test/ffi-gobject/value_test.rb +26 -1
  46. data/test/ffi-gobject_introspection/lib_test.rb +10 -0
  47. data/test/gir_ffi_test_helper.rb +1 -1
  48. data/test/integration/derived_classes_test.rb +31 -0
  49. data/test/integration/generated_gimarshallingtests_test.rb +29 -15
  50. data/test/integration/generated_gio_test.rb +5 -6
  51. data/test/integration/generated_regress_test.rb +11 -7
  52. data/test/integration/method_lookup_test.rb +32 -0
  53. data/test/interface_type_builder_test.rb +1 -1
  54. data/test/test_helper.rb +38 -0
  55. data/test/unit/argument_builder_test.rb +16 -4
  56. data/test/unit/class_base_test.rb +48 -0
  57. data/test/unit/function_builder_test.rb +144 -4
  58. data/test/unit/hash_table_element_type_provider_test.rb +16 -0
  59. data/test/unit/i_field_info_test.rb +39 -0
  60. data/test/unit/i_type_info_test.rb +23 -0
  61. data/test/unit/list_element_type_provider_test.rb +13 -0
  62. data/test/unit/module_builder_test.rb +1 -1
  63. data/test/unit/object_type_builder_test.rb +0 -17
  64. data/test/unit/struct_builder_test.rb +27 -39
  65. metadata +118 -60
  66. data/lib/gir_ffi/builder/argument/hash_table_base.rb +0 -20
  67. data/lib/gir_ffi/builder/argument/list_base.rb +0 -16
  68. data/test/class_base_test.rb +0 -10
  69. data/test/function_definition_builder_test.rb +0 -130
@@ -21,28 +21,32 @@ describe GObject do
21
21
 
22
22
  it "has constants for the fundamental GTypes" do
23
23
  assert_equal GObject.type_from_name("invalid"), GObject::TYPE_INVALID
24
- assert_equal GObject.type_from_name("void"), GObject::TYPE_NONE
25
- assert_equal GObject.type_from_name("GInterface"), GObject::TYPE_INTERFACE
26
- assert_equal GObject.type_from_name("gchar"), GObject::TYPE_CHAR
27
- assert_equal GObject.type_from_name("guchar"), GObject::TYPE_UCHAR
28
- assert_equal GObject.type_from_name("gboolean"), GObject::TYPE_BOOLEAN
29
- assert_equal GObject.type_from_name("gint"), GObject::TYPE_INT
30
- assert_equal GObject.type_from_name("guint"), GObject::TYPE_UINT
31
- assert_equal GObject.type_from_name("glong"), GObject::TYPE_LONG
32
- assert_equal GObject.type_from_name("gulong"), GObject::TYPE_ULONG
33
- assert_equal GObject.type_from_name("gint64"), GObject::TYPE_INT64
34
- assert_equal GObject.type_from_name("guint64"), GObject::TYPE_UINT64
35
- assert_equal GObject.type_from_name("GEnum"), GObject::TYPE_ENUM
36
- assert_equal GObject.type_from_name("GFlags"), GObject::TYPE_FLAGS
37
- assert_equal GObject.type_from_name("gfloat"), GObject::TYPE_FLOAT
38
- assert_equal GObject.type_from_name("gdouble"), GObject::TYPE_DOUBLE
39
- assert_equal GObject.type_from_name("gchararray"), GObject::TYPE_STRING
40
- assert_equal GObject.type_from_name("gpointer"), GObject::TYPE_POINTER
41
- assert_equal GObject.type_from_name("GBoxed"), GObject::TYPE_BOXED
42
- assert_equal GObject.type_from_name("GParam"), GObject::TYPE_PARAM
43
- assert_equal GObject.type_from_name("GObject"), GObject::TYPE_OBJECT
44
- assert_equal GObject.type_from_name("GType"), GObject::TYPE_GTYPE
45
- assert_equal GObject.type_from_name("GVariant"), GObject::TYPE_VARIANT
24
+ assert_equal nil, GObject.type_name(GObject::TYPE_INVALID)
25
+
26
+ assert_equal "void", GObject.type_name(GObject::TYPE_NONE)
27
+ assert_equal "GInterface", GObject.type_name(GObject::TYPE_INTERFACE)
28
+ assert_equal "gchar", GObject.type_name(GObject::TYPE_CHAR)
29
+ assert_equal "guchar", GObject.type_name(GObject::TYPE_UCHAR)
30
+ assert_equal "gboolean", GObject.type_name(GObject::TYPE_BOOLEAN)
31
+ assert_equal "gint", GObject.type_name(GObject::TYPE_INT)
32
+ assert_equal "guint", GObject.type_name(GObject::TYPE_UINT)
33
+ assert_equal "glong", GObject.type_name(GObject::TYPE_LONG)
34
+ assert_equal "gulong", GObject.type_name(GObject::TYPE_ULONG)
35
+ assert_equal "gint64", GObject.type_name(GObject::TYPE_INT64)
36
+ assert_equal "guint64", GObject.type_name(GObject::TYPE_UINT64)
37
+ assert_equal "GEnum", GObject.type_name(GObject::TYPE_ENUM)
38
+ assert_equal "GFlags", GObject.type_name(GObject::TYPE_FLAGS)
39
+ assert_equal "gfloat", GObject.type_name(GObject::TYPE_FLOAT)
40
+ assert_equal "gdouble", GObject.type_name(GObject::TYPE_DOUBLE)
41
+ assert_equal "gchararray", GObject.type_name(GObject::TYPE_STRING)
42
+ assert_equal "gpointer", GObject.type_name(GObject::TYPE_POINTER)
43
+ assert_equal "GBoxed", GObject.type_name(GObject::TYPE_BOXED)
44
+ assert_equal "GParam", GObject.type_name(GObject::TYPE_PARAM)
45
+ assert_equal "GObject", GObject.type_name(GObject::TYPE_OBJECT)
46
+ assert_equal "GType", GObject.type_name(GObject::TYPE_GTYPE)
47
+ assert_equal "GVariant", GObject.type_name(GObject::TYPE_VARIANT)
48
+ assert_equal "GStrv", GObject.type_name(GObject::TYPE_STRV)
49
+ assert_equal "GHashTable", GObject.type_name(GObject::TYPE_HASH_TABLE)
46
50
  end
47
51
  end
48
52
 
@@ -3,7 +3,7 @@ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
3
3
  require 'ffi-gobject'
4
4
 
5
5
  describe GObject::Value do
6
- describe "::wrap_ruby_value class" do
6
+ describe "::wrap_ruby_value" do
7
7
  it "wraps a boolean false" do
8
8
  gv = GObject::Value.wrap_ruby_value false
9
9
  assert_instance_of GObject::Value, gv
@@ -15,6 +15,16 @@ describe GObject::Value do
15
15
  assert_instance_of GObject::Value, gv
16
16
  assert_equal true, gv.get_boolean
17
17
  end
18
+
19
+ it "wraps an Integer" do
20
+ gv = GObject::Value.wrap_ruby_value 42
21
+ assert_equal 42, gv.get_int
22
+ end
23
+
24
+ it "wraps a String" do
25
+ gv = GObject::Value.wrap_ruby_value "Some Random String"
26
+ assert_equal "Some Random String", gv.get_string
27
+ end
18
28
  end
19
29
 
20
30
  describe "#ruby_value" do
@@ -30,5 +40,20 @@ describe GObject::Value do
30
40
  assert_equal true, result
31
41
  end
32
42
  end
43
+
44
+ describe "::from" do
45
+ it "creates a gint GValue from a Ruby Integer" do
46
+ gv = GObject::Value.from 21
47
+ gv.current_gtype_name.must_equal "gint"
48
+ gv.ruby_value.must_equal 21
49
+ end
50
+
51
+ it "returns its argument if given a GValue" do
52
+ gv = GObject::Value.from 21
53
+ gv2 = GObject::Value.from gv
54
+ gv2.current_gtype_name.must_equal "gint"
55
+ gv2.ruby_value.must_equal 21
56
+ end
57
+ end
33
58
  end
34
59
 
@@ -54,3 +54,13 @@ describe "loading the shared library" do
54
54
  end
55
55
  end
56
56
  end
57
+
58
+ describe GObjectIntrospection::Lib::GIArgument do
59
+ describe "its member :v_ssize" do
60
+ it "is signed" do
61
+ gia = GObjectIntrospection::Lib::GIArgument.new
62
+ gia[:v_int64] = -1
63
+ assert_equal(-1, gia[:v_ssize])
64
+ end
65
+ end
66
+ end
@@ -26,7 +26,7 @@ gir = GObjectIntrospection::IRepository.default
26
26
  gir.require "Gtk", "2.0"
27
27
 
28
28
  # Need a dummy module for some tests.
29
- module Lib
29
+ module DummyLib
30
30
  end
31
31
 
32
32
  class MiniTest::Unit::TestCase
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
+
3
+ # Tests deriving Ruby classes from GObject classes.
4
+ describe "Class derivation" do
5
+ before do
6
+ save_module :GIMarshallingTests
7
+ GirFFI.setup :GIMarshallingTests
8
+ end
9
+
10
+ describe "with an interface mixed in" do
11
+ before do
12
+ @klass = Class.new GIMarshallingTests::OverridesObject
13
+ @klass.send :include, GIMarshallingTests::Interface
14
+ end
15
+
16
+ it "finds class methods in the superclass" do
17
+ @klass.returnv
18
+ end
19
+
20
+ it "finds instance methods in the superclass" do
21
+ obj = @klass.new
22
+ result = obj.method
23
+ result.must_equal 42
24
+ end
25
+ end
26
+
27
+ after do
28
+ restore_module :GIMarshallingTests
29
+ end
30
+ end
31
+
@@ -31,9 +31,9 @@ describe "GIMarshallingTests" do
31
31
  end
32
32
 
33
33
  it "has a writable field g_strv" do
34
- assert_equal [], @bx.g_strv
34
+ assert_equal [], @bx.g_strv.to_a
35
35
  @bx.g_strv = ["foo", "bar"]
36
- assert_equal ["foo", "bar"], @bx.g_strv
36
+ assert_equal ["foo", "bar"], @bx.g_strv.to_a
37
37
  end
38
38
  end
39
39
 
@@ -54,7 +54,7 @@ describe "GIMarshallingTests" do
54
54
  it "has a working function #returnv" do
55
55
  res = GIMarshallingTests::BoxedStruct.returnv
56
56
  assert_equal 42, res.long_
57
- assert_equal ["0", "1", "2"], res.g_strv
57
+ assert_equal ["0", "1", "2"], res.g_strv.to_a
58
58
  end
59
59
  end
60
60
 
@@ -541,12 +541,12 @@ describe "GIMarshallingTests" do
541
541
 
542
542
  it "has a working function #array_zero_terminated_out" do
543
543
  res = GIMarshallingTests.array_zero_terminated_out
544
- assert_equal ["0", "1", "2"], res
544
+ assert_equal ["0", "1", "2"], res.to_a
545
545
  end
546
546
 
547
547
  it "has a working function #array_zero_terminated_return" do
548
548
  res = GIMarshallingTests.array_zero_terminated_return
549
- assert_equal ["0", "1", "2"], res
549
+ assert_equal ["0", "1", "2"], res.to_a
550
550
  end
551
551
 
552
552
  it "has a working function #boolean_in_false" do
@@ -604,7 +604,7 @@ describe "GIMarshallingTests" do
604
604
  it "has a working function #boxed_struct_returnv" do
605
605
  res = GIMarshallingTests.boxed_struct_returnv
606
606
  assert_equal 42, res.long_
607
- assert_equal ["0", "1", "2"], res.g_strv
607
+ assert_equal ["0", "1", "2"], res.g_strv.to_a
608
608
  end
609
609
 
610
610
  it "has a working function #bytearray_full_return" do
@@ -1043,17 +1043,17 @@ describe "GIMarshallingTests" do
1043
1043
 
1044
1044
  it "has a working function #gstrv_inout" do
1045
1045
  res = GIMarshallingTests.gstrv_inout ["0", "1", "2"]
1046
- assert_equal ["-1", "0", "1", "2"], res
1046
+ assert_equal ["-1", "0", "1", "2"], res.to_a
1047
1047
  end
1048
1048
 
1049
1049
  it "has a working function #gstrv_out" do
1050
1050
  res = GIMarshallingTests.gstrv_out
1051
- assert_equal ["0", "1", "2"], res
1051
+ assert_equal ["0", "1", "2"], res.to_a
1052
1052
  end
1053
1053
 
1054
1054
  it "has a working function #gstrv_return" do
1055
1055
  res = GIMarshallingTests.gstrv_return
1056
- assert_equal ["0", "1", "2"], res
1056
+ assert_equal ["0", "1", "2"], res.to_a
1057
1057
  end
1058
1058
 
1059
1059
  it "has a working function #gtype_inout" do
@@ -1075,9 +1075,16 @@ describe "GIMarshallingTests" do
1075
1075
  assert_equal "void", name
1076
1076
  end
1077
1077
 
1078
- it "has a working function #gvalue_in" do
1079
- GIMarshallingTests.gvalue_in GObject::Value.wrap_ruby_value(42)
1080
- pass
1078
+ describe "#gvalue_in" do
1079
+ it "works when passed a GObject::Value object" do
1080
+ GIMarshallingTests.gvalue_in GObject::Value.wrap_ruby_value(42)
1081
+ pass
1082
+ end
1083
+
1084
+ it "automatically converts a non-GValue object to a GValue" do
1085
+ GIMarshallingTests.gvalue_in 42
1086
+ pass
1087
+ end
1081
1088
  end
1082
1089
 
1083
1090
  it "has a working function #gvalue_in_enum" do
@@ -1088,9 +1095,16 @@ describe "GIMarshallingTests" do
1088
1095
  pass
1089
1096
  end
1090
1097
 
1091
- it "has a working function #gvalue_inout" do
1092
- res = GIMarshallingTests.gvalue_inout GObject::Value.wrap_ruby_value(42)
1093
- assert_equal "42", res.ruby_value
1098
+ describe "#gvalue_inout" do
1099
+ it "works when passed a GObject::Value object" do
1100
+ res = GIMarshallingTests.gvalue_inout GObject::Value.wrap_ruby_value(42)
1101
+ assert_equal "42", res.ruby_value
1102
+ end
1103
+
1104
+ it "automatically converts a non-GValue input to a GValue" do
1105
+ res = GIMarshallingTests.gvalue_inout 42
1106
+ assert_equal "42", res.ruby_value
1107
+ end
1094
1108
  end
1095
1109
 
1096
1110
  it "has a working function #gvalue_out" do
@@ -27,12 +27,11 @@ describe "The generated Gio module" do
27
27
 
28
28
  it "is able to set up a method in a class that is not the first ancestor" do
29
29
  anc = @it.class.ancestors
30
- assert_equal Gio::File, anc[1]
31
- assert_equal GObject::Object, anc[2]
32
- refute_includes Gio::File.instance_methods.map(&:to_s),
33
- 'get_qdata'
34
- assert_includes GObject::Object.instance_methods.map(&:to_s),
35
- 'get_qdata'
30
+ assert_equal [Gio::File, GObject::Object], anc[1, 2]
31
+
32
+ refute_defines_instance_method Gio::File, :get_qdata
33
+ assert_defines_instance_method GObject::Object, :get_qdata
34
+
36
35
  @it.setup_and_call :get_qdata, 1
37
36
  end
38
37
  end
@@ -278,8 +278,12 @@ class GeneratedRegressTest < MiniTest::Spec
278
278
 
279
279
  it "sets the 'hash-table' property" do
280
280
  @o.set_property("hash-table", {"foo" => 34, "bar" => 83})
281
- assert_equal({"foo" => 34, "bar" => 83},
282
- GLib::HashTable.wrap(:utf8, :gint32, @o.hash_table.to_ptr).to_hash)
281
+
282
+ ht = @o.hash_table
283
+ ht.key_type = :utf8
284
+ ht.value_type = :gint32
285
+
286
+ assert_equal({"foo" => 34, "bar" => 83}, ht.to_hash)
283
287
  end
284
288
 
285
289
  it "sets the 'float' property" do
@@ -1083,27 +1087,27 @@ class GeneratedRegressTest < MiniTest::Spec
1083
1087
 
1084
1088
  it "has correct #test_strv_in_gvalue" do
1085
1089
  gv = Regress.test_strv_in_gvalue
1086
- assert_equal ['one', 'two', 'three'], gv.ruby_value
1090
+ assert_equal ['one', 'two', 'three'], gv.ruby_value.to_a
1087
1091
  end
1088
1092
 
1089
1093
  it "has correct #test_strv_out" do
1090
1094
  arr = Regress.test_strv_out
1091
- assert_equal ["thanks", "for", "all", "the", "fish"], arr
1095
+ assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
1092
1096
  end
1093
1097
 
1094
1098
  it "has correct #test_strv_out_c" do
1095
1099
  arr = Regress.test_strv_out_c
1096
- assert_equal ["thanks", "for", "all", "the", "fish"], arr
1100
+ assert_equal ["thanks", "for", "all", "the", "fish"], arr.to_a
1097
1101
  end
1098
1102
 
1099
1103
  it "has correct #test_strv_out_container" do
1100
1104
  arr = Regress.test_strv_out_container
1101
- assert_equal ['1', '2', '3'], arr
1105
+ assert_equal ['1', '2', '3'], arr.to_a
1102
1106
  end
1103
1107
 
1104
1108
  it "has correct #test_strv_outarg" do
1105
1109
  arr = Regress.test_strv_outarg
1106
- assert_equal ['1', '2', '3'], arr
1110
+ assert_equal ['1', '2', '3'], arr.to_a
1107
1111
  end
1108
1112
 
1109
1113
  should "have correct test_timet" do
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
+
3
+ # Tests how methods are looked up and generated on first use.
4
+ describe "Looking up methods" do
5
+ before do
6
+ save_module :Regress
7
+ GirFFI.setup :Regress
8
+ end
9
+
10
+ describe "an instance method" do
11
+ it "is found from a subclass" do
12
+ assert_defines_instance_method Regress::TestObj, :forced_method
13
+ refute_defines_instance_method Regress::TestSubObj, :forced_method
14
+
15
+ sub_object = Regress::TestSubObj.new
16
+ sub_object.forced_method
17
+ end
18
+ end
19
+
20
+ describe "a class method" do
21
+ it "is found from a subclass" do
22
+ assert_defines_singleton_method Regress::TestObj, :static_method
23
+ refute_defines_singleton_method Regress::TestSubObj, :static_method
24
+
25
+ Regress::TestSubObj.static_method 42
26
+ end
27
+ end
28
+
29
+ after do
30
+ restore_module :Regress
31
+ end
32
+ end
@@ -12,6 +12,6 @@ describe GirFFI::Builder::Type::Interface do
12
12
  end
13
13
 
14
14
  it "creates methods on the interface" do
15
- assert_includes @iface.instance_methods.map(&:to_s), 'complete_interface_info'
15
+ assert_defines_instance_method @iface, :complete_interface_info
16
16
  end
17
17
  end
data/test/test_helper.rb CHANGED
@@ -32,6 +32,44 @@ class MiniTest::Unit::TestCase
32
32
  def assert_not_nil it
33
33
  refute_nil it
34
34
  end
35
+
36
+ def assert_defines_singleton_method klass, method, msg = nil
37
+ method = method.to_sym
38
+ methods = klass.singleton_methods(false).map { |name| name.to_sym }
39
+ msg = message(msg) {
40
+ "Expected #{mu_pp(klass)} to define singleton method #{mu_pp(method)}, " +
41
+ "but only found #{mu_pp(methods)}"
42
+ }
43
+ assert_includes methods, method, msg
44
+ end
45
+
46
+ def refute_defines_singleton_method klass, method, msg = nil
47
+ method = method.to_sym
48
+ methods = klass.singleton_methods(false).map { |name| name.to_sym }
49
+ msg = message(msg) {
50
+ "Expected #{mu_pp(klass)} not to define singleton method #{mu_pp(method)}"
51
+ }
52
+ refute_includes methods, method, msg
53
+ end
54
+
55
+ def assert_defines_instance_method klass, method, msg = nil
56
+ method = method.to_sym
57
+ methods = klass.instance_methods(false).map { |name| name.to_sym }
58
+ msg = message(msg) {
59
+ "Expected #{mu_pp(klass)} to define instance method #{mu_pp(method)}, " +
60
+ "but only found #{mu_pp(methods)}"
61
+ }
62
+ assert_includes methods, method, msg
63
+ end
64
+
65
+ def refute_defines_instance_method klass, method, msg = nil
66
+ method = method.to_sym
67
+ methods = klass.instance_methods(false).map { |name| name.to_sym }
68
+ msg = message(msg) {
69
+ "Expected #{mu_pp(klass)} not to define instance method #{mu_pp(method)}"
70
+ }
71
+ refute_includes methods, method, msg
72
+ end
35
73
  end
36
74
 
37
75
  class MiniTest::Spec
@@ -1,6 +1,18 @@
1
1
  require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  describe GirFFI::Builder::Argument::Base do
4
+ describe "#subtype_tag" do
5
+ it "returns :gpointer if the param_type is a pointer with tag :void" do
6
+ stub(subtype0 = Object.new).tag { :void }
7
+ stub(subtype0).pointer? { true }
8
+ stub(type = Object.new).param_type(0) { subtype0 }
9
+
10
+ provider = GirFFI::Builder::Argument::Base.new nil, nil, type
11
+
12
+ assert_equal :gpointer, provider.subtype_tag
13
+ end
14
+ end
15
+
4
16
  describe "#subtype_tag_or_class_name" do
5
17
  describe "for a simple type" do
6
18
  it "returns the string ':void'" do
@@ -9,7 +21,7 @@ describe GirFFI::Builder::Argument::Base do
9
21
 
10
22
  mock(info = Object.new).param_type(0) { subtype }
11
23
 
12
- builder = GirFFI::Builder::Argument::Base.new nil, 'foo', info, nil
24
+ builder = GirFFI::Builder::Argument::Base.new nil, 'foo', info
13
25
  assert_equal ":void", builder.subtype_tag_or_class_name
14
26
  end
15
27
  end
@@ -21,7 +33,7 @@ describe GirFFI::Builder::Argument::Base do
21
33
 
22
34
  mock(info = Object.new).param_type(0) { subtype }
23
35
 
24
- builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info, nil
36
+ builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info
25
37
  assert_equal ":foo", builder.subtype_tag_or_class_name
26
38
  end
27
39
  end
@@ -37,7 +49,7 @@ describe GirFFI::Builder::Argument::Base do
37
49
 
38
50
  mock(info = Object.new).param_type(0) { subtype }
39
51
 
40
- builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info, nil
52
+ builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info
41
53
  assert_equal "::Foo::Bar", builder.subtype_tag_or_class_name
42
54
  end
43
55
  end
@@ -49,7 +61,7 @@ describe GirFFI::Builder::Argument::Base do
49
61
 
50
62
  mock(info = Object.new).param_type(0) { subtype }
51
63
 
52
- builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info, nil
64
+ builder = GirFFI::Builder::Argument::Base.new nil, 'bar', info
53
65
  assert_equal "[:pointer, :foo]", builder.subtype_tag_or_class_name
54
66
  end
55
67
  end