gir_ffi 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/History.txt +8 -0
  2. data/README.md +1 -1
  3. data/TODO.rdoc +12 -4
  4. data/lib/ffi-glib.rb +0 -5
  5. data/lib/ffi-glib/list.rb +1 -1
  6. data/lib/ffi-glib/s_list.rb +1 -1
  7. data/lib/ffi-gobject.rb +2 -3
  8. data/lib/ffi-gobject/closure.rb +4 -3
  9. data/lib/ffi-gobject_introspection/i_base_info.rb +11 -14
  10. data/lib/ffi-gobject_introspection/i_constant_info.rb +1 -1
  11. data/lib/ffi-gobject_introspection/i_function_info.rb +0 -6
  12. data/lib/ffi-gobject_introspection/lib.rb +8 -2
  13. data/lib/gir_ffi.rb +5 -0
  14. data/lib/gir_ffi/arg_helper.rb +1 -1
  15. data/lib/gir_ffi/argument_builder.rb +161 -0
  16. data/lib/gir_ffi/base_argument_builder.rb +146 -0
  17. data/lib/gir_ffi/builder/field.rb +7 -5
  18. data/lib/gir_ffi/builder/module.rb +3 -14
  19. data/lib/gir_ffi/builder/property.rb +0 -2
  20. data/lib/gir_ffi/builder/type/callback.rb +0 -8
  21. data/lib/gir_ffi/builder/type/constant.rb +0 -4
  22. data/lib/gir_ffi/builder/type/enum.rb +0 -4
  23. data/lib/gir_ffi/builder/type/interface.rb +0 -4
  24. data/lib/gir_ffi/builder/type/object.rb +0 -1
  25. data/lib/gir_ffi/builder/type/struct_based.rb +0 -6
  26. data/lib/gir_ffi/builder/type/union.rb +0 -4
  27. data/lib/gir_ffi/builder/type/with_layout.rb +0 -1
  28. data/lib/gir_ffi/builder/type/with_methods.rb +1 -7
  29. data/lib/gir_ffi/callback.rb +9 -0
  30. data/lib/gir_ffi/callback_helper.rb +8 -1
  31. data/lib/gir_ffi/class_base.rb +6 -26
  32. data/lib/gir_ffi/error_argument_builder.rb +17 -0
  33. data/lib/gir_ffi/{builder/function.rb → function_builder.rb} +14 -11
  34. data/lib/gir_ffi/in_out_pointer.rb +29 -36
  35. data/lib/gir_ffi/in_pointer.rb +1 -1
  36. data/lib/gir_ffi/info_ext.rb +6 -0
  37. data/lib/gir_ffi/info_ext/i_field_info.rb +0 -2
  38. data/lib/gir_ffi/info_ext/i_type_info.rb +29 -10
  39. data/lib/gir_ffi/info_ext/safe_constant_name.rb +21 -0
  40. data/lib/gir_ffi/info_ext/safe_function_name.rb +13 -0
  41. data/lib/gir_ffi/interface_base.rb +1 -11
  42. data/lib/gir_ffi/module_base.rb +0 -10
  43. data/lib/gir_ffi/null_argument_builder.rb +9 -0
  44. data/lib/gir_ffi/return_value_builder.rb +75 -0
  45. data/lib/gir_ffi/setter_argument_info.rb +16 -0
  46. data/lib/gir_ffi/type_map.rb +10 -1
  47. data/lib/gir_ffi/version.rb +1 -1
  48. data/tasks/test.rake +61 -0
  49. data/test/base_test_helper.rb +0 -2
  50. data/test/ffi-gobject/value_test.rb +15 -0
  51. data/test/ffi-gobject_introspection/i_base_info_test.rb +31 -6
  52. data/test/ffi-gobject_introspection/i_function_info_test.rb +0 -17
  53. data/test/ffi-gobject_introspection/lib_test.rb +0 -55
  54. data/test/ffi-gobject_test.rb +2 -1
  55. data/test/gir_ffi/argument_builder_test.rb +414 -0
  56. data/test/gir_ffi/base_argument_builder_test.rb +13 -0
  57. data/test/gir_ffi/builder/module_test.rb +4 -40
  58. data/test/gir_ffi/builder/type/callback_test.rb +0 -27
  59. data/test/gir_ffi/builder/type/constant_test.rb +0 -12
  60. data/test/gir_ffi/builder/type/enum_test.rb +0 -20
  61. data/test/gir_ffi/builder/type/interface_test.rb +0 -11
  62. data/test/gir_ffi/builder/type/object_test.rb +2 -2
  63. data/test/gir_ffi/builder/type/struct_test.rb +0 -39
  64. data/test/gir_ffi/builder/type/unintrospectable_test.rb +1 -1
  65. data/test/gir_ffi/builder/type/union_test.rb +0 -11
  66. data/test/gir_ffi/builder_test.rb +3 -11
  67. data/test/gir_ffi/callback_helper_test.rb +7 -0
  68. data/test/gir_ffi/{builder/function_test.rb → function_builder_test.rb} +16 -28
  69. data/test/gir_ffi/in_out_pointer_test.rb +0 -20
  70. data/test/gir_ffi/info_ext/i_type_info_test.rb +112 -26
  71. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +16 -0
  72. data/test/gir_ffi/info_ext/safe_function_name_test.rb +22 -0
  73. data/test/gir_ffi/return_value_builder_test.rb +355 -0
  74. data/test/integration/generated_gimarshallingtests_test.rb +608 -296
  75. data/test/integration/generated_regress_test.rb +879 -494
  76. metadata +35 -24
  77. data/lib/gir_ffi/builder/argument.rb +0 -569
  78. data/lib/gir_ffi/builder/argument/base.rb +0 -151
  79. data/lib/gir_ffi/builder/argument/in_base.rb +0 -14
  80. data/lib/gir_ffi/builder/argument/in_out_base.rb +0 -18
  81. data/lib/gir_ffi/builder/argument/out_base.rb +0 -15
  82. data/test/gir_ffi/builder/argument/base_test.rb +0 -55
  83. data/test/integration/pretty_print_test.rb +0 -33
@@ -0,0 +1,13 @@
1
+ require 'gir_ffi_test_helper'
2
+
3
+ describe GirFFI::BaseArgumentBuilder do
4
+ describe "#subtype_tag_or_class_name" do
5
+ it "delegates to the type" do
6
+ mock(info = Object.new).subtype_tag_or_class_name { 'foo' }
7
+
8
+ builder = GirFFI::BaseArgumentBuilder.new nil, 'bar', info, :direction
9
+ assert_equal "foo", builder.subtype_tag_or_class_name
10
+ end
11
+ end
12
+ end
13
+
@@ -1,48 +1,12 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builder::Module do
4
- describe "#pretty_print" do
5
- describe "for a module with no members" do
6
- it "returns just a module block" do
7
- gir = GObjectIntrospection::IRepository.default
8
- stub(gir).require("Foo", nil) { }
9
- mock(gir).infos("Foo") { [] }
10
-
11
- builder = GirFFI::Builder::Module.new "Foo"
12
- res = builder.pretty_print
13
- expected = "module Foo\nend"
14
-
15
- assert_equal expected, res
16
- end
17
- end
18
-
19
- describe "for a module with a function member" do
20
- it "returns a module block with pretty printed function inside" do
21
- stub(info = Object.new).info_type { :function }
22
- mock(subbuilder = Object.new).pretty_print { "def foo\n function_body\nend" }
23
-
24
- gir = GObjectIntrospection::IRepository.default
25
- stub(gir).require("Foo", nil) { }
26
- mock(gir).infos("Foo") { [info] }
27
-
28
- builder = GirFFI::Builder::Module.new "Foo"
29
- stub(builder).libmodule { :bla }
30
- mock(GirFFI::Builder::Function).new(info, :bla) { subbuilder }
31
-
32
- res = builder.pretty_print
33
- expected = "module Foo\n def foo\n function_body\n end\nend"
34
-
35
- assert_equal expected, res
36
- end
37
- end
38
- end
39
-
40
4
  describe "#function_definition" do
41
- it "delegates to GirFFI::Builder::Function#generate" do
5
+ it "delegates to GirFFI::FunctionBuilder#generate" do
42
6
  builder = GirFFI::Builder::Module.new "Foo"
43
7
 
44
8
  mock(fb = Object.new).generate { "function body" }
45
- mock(GirFFI::Builder::Function).new("info", "lib") { fb }
9
+ mock(GirFFI::FunctionBuilder).new("info", "lib") { fb }
46
10
 
47
11
  result = builder.send :function_definition, "info", "lib"
48
12
 
@@ -52,14 +16,14 @@ describe GirFFI::Builder::Module do
52
16
 
53
17
  describe "#sub_builder" do
54
18
  describe "for a :function argument" do
55
- it "creates a GirFFI::Builder::Function object" do
19
+ it "creates a GirFFI::FunctionBuilder object" do
56
20
  builder = GirFFI::Builder::Module.new "Foo"
57
21
  mock(builder).libmodule { DummyLib }
58
22
 
59
23
  stub(info = Object.new).info_type { :function }
60
24
 
61
25
  result = builder.send :sub_builder, info
62
- assert_instance_of GirFFI::Builder::Function, result
26
+ assert_instance_of GirFFI::FunctionBuilder, result
63
27
  end
64
28
  end
65
29
 
@@ -1,33 +1,6 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builder::Type::Callback do
4
- describe "#pretty_print" do
5
- it "returns a statement assigning the callback to a constant" do
6
- mock(info = Object.new).safe_name { "TheCallback" }
7
- stub(info).namespace { "Foo" }
8
- mock(GirFFI::Builder).ffi_function_return_type(info) { :ret_type }
9
- mock(GirFFI::Builder).ffi_function_argument_types(info) { [ :baz, :qux ] }
10
-
11
- builder = GirFFI::Builder::Type::Callback.new(info)
12
-
13
- assert_equal "TheCallback = Lib.callback :TheCallback, [:baz, :qux], :ret_type",
14
- builder.pretty_print
15
- end
16
-
17
- it "renders enum argument types by their tags" do
18
- stub(enum = FFI::Enum.new([])).tag { :EnumTag }
19
-
20
- mock(info = Object.new).safe_name { "TheCallback" }
21
- stub(info).namespace { "Foo" }
22
- mock(GirFFI::Builder).ffi_function_return_type(info) { :ret_type }
23
- mock(GirFFI::Builder).ffi_function_argument_types(info) { [ enum ] }
24
-
25
- builder = GirFFI::Builder::Type::Callback.new(info)
26
-
27
- assert_equal "TheCallback = Lib.callback :TheCallback, [EnumTag], :ret_type",
28
- builder.pretty_print
29
- end
30
- end
31
4
  end
32
5
 
33
6
 
@@ -1,16 +1,4 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builder::Type::Constant do
4
- describe "#pretty_print" do
5
- it "returns the correct assignment statement" do
6
- mock(info = Object.new).value { "bar" }
7
- mock(info).safe_name { "FOO_CONSTANT" }
8
- stub(info).namespace { "Foo" }
9
-
10
- builder = GirFFI::Builder::Type::Constant.new(info)
11
-
12
- assert_equal "FOO_CONSTANT = \"bar\"", builder.pretty_print
13
- end
14
- end
15
4
  end
16
-
@@ -1,25 +1,5 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builder::Type::Enum do
4
- describe "#pretty_print" do
5
- it "returns a statement assigning the enum to a constant" do
6
- mock(info = Object.new).safe_name { "TheEnum" }
7
- stub(info).namespace { "Foo" }
8
-
9
- mock(val1 = Object.new).name { "value1" }
10
- mock(val1).value { 1 }
11
- mock(val2 = Object.new).name { "value2" }
12
- mock(val2).value { 2 }
13
-
14
- mock(info).values { [val1, val2] }
15
-
16
- builder = GirFFI::Builder::Type::Enum.new(info)
17
-
18
- assert_equal "TheEnum = Lib.enum :TheEnum, [:value1, 1, :value2, 2]",
19
- builder.pretty_print
20
- end
21
- end
22
4
  end
23
5
 
24
-
25
-
@@ -1,17 +1,6 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
3
  describe GirFFI::Builder::Type::Interface do
4
- describe "#pretty_print" do
5
- it "returns a module block, extending InterfaceBase" do
6
- mock(info = Object.new).safe_name { "Bar" }
7
- stub(info).namespace { "Foo" }
8
-
9
- builder = GirFFI::Builder::Type::Interface.new(info)
10
-
11
- assert_equal "module Bar\n extend InterfaceBase\nend", builder.pretty_print
12
- end
13
- end
14
-
15
4
  describe "#build_class" do
16
5
  before do
17
6
  info = get_introspection_data 'GObject', 'TypePlugin'
@@ -51,9 +51,9 @@ describe GirFFI::Builder::Type::Object do
51
51
  @go = get_method_introspection_data 'Regress', 'TestObj', 'instance_method'
52
52
  end
53
53
 
54
- it "delegates definition to Builder::Function" do
54
+ it "delegates definition to FunctionBuilder" do
55
55
  code = @cbuilder.send :function_definition, @go
56
- expected = GirFFI::Builder::Function.new(@go, Regress::Lib).generate
56
+ expected = GirFFI::FunctionBuilder.new(@go, Regress::Lib).generate
57
57
  assert_equal cws(expected), cws(code)
58
58
  end
59
59
 
@@ -2,45 +2,6 @@ require 'gir_ffi_test_helper'
2
2
 
3
3
  # FIXME: Test WithLayout directly, rather than through Struct.
4
4
  describe GirFFI::Builder::Type::Struct do
5
- describe "#pretty_print" do
6
- describe "for a struct with no methods" do
7
- it "returns a class block" do
8
- mock(info = Object.new).safe_name { "Bar" }
9
- stub(info).namespace { "Foo" }
10
- stub(info).get_methods { [] }
11
-
12
- builder = GirFFI::Builder::Type::Struct.new(info)
13
-
14
- assert_equal "class Bar\nend", builder.pretty_print
15
- end
16
- end
17
-
18
- describe "for a struct with a method" do
19
- it "returns a class block with the pretty printed method inside" do
20
- # FIXME: Loads of mocks.
21
-
22
- # Function info and its builder
23
- stub(func_info = Object.new).info_type { :function }
24
- mock(func_builder = Object.new).pretty_print { "def foo\n function_body\nend" }
25
- mock(GirFFI::Builder::Function).new(func_info, :bla) { func_builder }
26
-
27
- # Struct info
28
- mock(info = Object.new).safe_name { "Bar" }
29
- stub(info).namespace { "Foo" }
30
- mock(info).get_methods { [func_info] }
31
-
32
- # Struct builder
33
- builder = GirFFI::Builder::Type::Struct.new(info)
34
- stub(builder).lib { :bla }
35
-
36
- res = builder.pretty_print
37
- expected = "class Bar\n def foo\n function_body\n end\nend"
38
-
39
- assert_equal expected, res
40
- end
41
- end
42
- end
43
-
44
5
  describe "for a struct with a simple layout" do
45
6
  before do
46
7
  @field = Object.new
@@ -6,7 +6,7 @@ describe GirFFI::Builder::Type::Unintrospectable do
6
6
  # Ensure existence of GLocalFile type
7
7
  GirFFI.setup :Gio
8
8
  unless Gio::Lib.respond_to? :g_file_new_for_path
9
- Gio._setup_method "file_new_for_path"
9
+ Gio.setup_method "file_new_for_path"
10
10
  end
11
11
  ptr = GirFFI::InPointer.from :utf8, '/'
12
12
  Gio::Lib.g_file_new_for_path(ptr)
@@ -8,16 +8,5 @@ describe GirFFI::Builder::Type::Union do
8
8
  it "returns false looking for a method that doesn't exist" do
9
9
  assert_equal false, @cbuilder.setup_instance_method('blub')
10
10
  end
11
-
12
- describe "#pretty_print" do
13
- it "returns a class block" do
14
- mock(info = Object.new).safe_name { "Bar" }
15
- stub(info).namespace { "Foo" }
16
-
17
- builder = GirFFI::Builder::Type::Union.new(info)
18
-
19
- assert_equal "class Bar\nend", builder.pretty_print
20
- end
21
- end
22
11
  end
23
12
 
@@ -43,10 +43,6 @@ describe GirFFI::Builder do
43
43
  assert_equal [expected], GObject::Lib.ffi_libraries.map(&:name)
44
44
  end
45
45
 
46
- should "create an array CALLBACKS inside the GObject::Lib module" do
47
- assert_equal [], GObject::Lib::CALLBACKS
48
- end
49
-
50
46
  should "not replace existing classes" do
51
47
  oldclass = GObject::Object
52
48
  GirFFI::Builder.build_class get_introspection_data('GObject', 'Object')
@@ -74,7 +70,7 @@ describe GirFFI::Builder do
74
70
  end
75
71
 
76
72
  should "define ffi callback types :Callback and :ClosureNotify" do
77
- Regress._setup_method 'test_callback_destroy_notify'
73
+ Regress.setup_method 'test_callback_destroy_notify'
78
74
  tcud = Regress::Lib.find_type :TestCallbackUserData
79
75
  dn = GLib::Lib.find_type :DestroyNotify
80
76
 
@@ -180,7 +176,7 @@ describe GirFFI::Builder do
180
176
  end
181
177
 
182
178
  should "know its own module builder" do
183
- assert GirFFI::Builder::Module === Regress._builder
179
+ assert GirFFI::Builder::Module === Regress.gir_ffi_builder
184
180
  end
185
181
 
186
182
  after do
@@ -215,7 +211,7 @@ describe GirFFI::Builder do
215
211
  end
216
212
 
217
213
  should "know its own class builder" do
218
- assert GirFFI::Builder::Type::Base === Regress::TestObj._builder
214
+ assert GirFFI::Builder::Type::Base === Regress::TestObj.gir_ffi_builder
219
215
  end
220
216
 
221
217
  describe "its #torture_signature_0 method" do
@@ -333,10 +329,6 @@ describe GirFFI::Builder do
333
329
  assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
334
330
  end
335
331
 
336
- it "creates an array CALLBACKS inside the Regress::Lib module" do
337
- assert_equal [], Regress::Lib::CALLBACKS
338
- end
339
-
340
332
  it "does not replace existing module" do
341
333
  oldmodule = Regress
342
334
  GirFFI::Builder.build_module 'Regress'
@@ -47,4 +47,11 @@ describe GirFFI::CallbackHelper do
47
47
  assert_equal "good-result", r
48
48
  end
49
49
  end
50
+
51
+ describe ".store_callback" do
52
+ it "stores the passed in proc in GirFFI::CallbackHelper::CALLBACKS" do
53
+ GirFFI::CallbackHelper.store_callback "some-callback"
54
+ GirFFI::CallbackHelper::CALLBACKS.last.must_equal "some-callback"
55
+ end
56
+ end
50
57
  end
@@ -1,25 +1,15 @@
1
1
  require 'gir_ffi_test_helper'
2
2
 
3
- describe GirFFI::Builder::Function do
4
- describe "#pretty_print" do
5
- it "delegates to #generate" do
6
- builder = GirFFI::Builder::Function.new(:info, :libmodule)
7
-
8
- mock(builder).generate { 'result_from_generate' }
9
-
10
- assert_equal "result_from_generate", builder.pretty_print
11
- end
12
- end
13
-
3
+ describe GirFFI::FunctionBuilder do
14
4
  it "builds a correct definition of Regress:test_array_fixed_out_objects" do
15
5
  go = get_introspection_data 'Regress', 'test_array_fixed_out_objects'
16
6
  skip unless go
17
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
7
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
18
8
  code = fbuilder.generate
19
9
 
20
10
  expected = <<-CODE
21
11
  def self.test_array_fixed_out_objects
22
- _v1 = GirFFI::InOutPointer.for_array [:pointer, ::Regress::TestObj]
12
+ _v1 = GirFFI::InOutPointer.for [:c, [:pointer, ::Regress::TestObj]]
23
13
  DummyLib.regress_test_array_fixed_out_objects _v1
24
14
  _v2 = _v1.to_sized_array_value 2
25
15
  return _v2
@@ -31,7 +21,7 @@ describe GirFFI::Builder::Function do
31
21
 
32
22
  it "builds a correct definition for functions having a linked length argument" do
33
23
  go = get_introspection_data 'Regress', 'test_array_gint16_in'
34
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
24
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
35
25
  code = fbuilder.generate
36
26
 
37
27
  expected = <<-CODE
@@ -49,16 +39,14 @@ describe GirFFI::Builder::Function do
49
39
 
50
40
  it "builds a correct definition for functions with callbacks" do
51
41
  go = get_introspection_data 'Regress', 'test_callback_destroy_notify'
52
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
42
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
53
43
  code = fbuilder.generate
54
44
 
55
45
  expected = <<-CODE
56
46
  def self.test_callback_destroy_notify callback, user_data, notify
57
- _v1 = GirFFI::CallbackHelper.wrap_in_callback_args_mapper \"Regress\", \"TestCallbackUserData\", callback
58
- DummyLib::CALLBACKS << _v1
47
+ _v1 = GirFFI::Callback.from(\"Regress\", \"TestCallbackUserData\", callback)
59
48
  _v2 = GirFFI::InPointer.from(:void, user_data)
60
- _v3 = GirFFI::CallbackHelper.wrap_in_callback_args_mapper \"GLib\", \"DestroyNotify\", notify
61
- DummyLib::CALLBACKS << _v3
49
+ _v3 = GirFFI::Callback.from(\"GLib\", \"DestroyNotify\", notify)
62
50
  _v4 = DummyLib.regress_test_callback_destroy_notify _v1, _v2, _v3
63
51
  return _v4
64
52
  end
@@ -69,7 +57,7 @@ describe GirFFI::Builder::Function do
69
57
 
70
58
  it "builds correct definition for constructors" do
71
59
  go = get_method_introspection_data 'Regress', 'TestObj', 'new_from_file'
72
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
60
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
73
61
  code = fbuilder.generate
74
62
 
75
63
  expected = <<-CODE
@@ -88,7 +76,7 @@ describe GirFFI::Builder::Function do
88
76
 
89
77
  it "creates a call to GObject::Value#from for functions that take a GValue" do
90
78
  go = get_introspection_data 'GIMarshallingTests', 'gvalue_in'
91
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
79
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
92
80
  code = fbuilder.generate
93
81
 
94
82
  expected = <<-CODE
@@ -104,7 +92,7 @@ describe GirFFI::Builder::Function do
104
92
 
105
93
  it "builds correct definition for functions with a nullable input array" do
106
94
  go = get_introspection_data 'Regress', 'test_array_int_null_in'
107
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
95
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
108
96
  code = fbuilder.generate
109
97
 
110
98
  expected = <<-CODE
@@ -122,12 +110,12 @@ describe GirFFI::Builder::Function do
122
110
 
123
111
  it "builds correct definition for functions with a nullable output array" do
124
112
  go = get_introspection_data 'Regress', 'test_array_int_null_out'
125
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
113
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
126
114
  code = fbuilder.generate
127
115
 
128
116
  expected = <<-CODE
129
117
  def self.test_array_int_null_out
130
- _v1 = GirFFI::InOutPointer.for_array :gint32
118
+ _v1 = GirFFI::InOutPointer.for [:c, :gint32]
131
119
  _v2 = GirFFI::InOutPointer.for :gint32
132
120
  DummyLib.regress_test_array_int_null_out _v1, _v2
133
121
  _v3 = _v2.to_value
@@ -141,13 +129,13 @@ describe GirFFI::Builder::Function do
141
129
 
142
130
  it "builds the correct definition for a method with an inout array with size argument" do
143
131
  go = get_method_introspection_data 'GIMarshallingTests', 'Object', 'method_array_inout'
144
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
132
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
145
133
  code = fbuilder.generate
146
134
 
147
135
  expected = <<-CODE
148
136
  def method_array_inout ints
149
- _v1 = GirFFI::InOutPointer.from_array :gint32, ints
150
- length = ints.length
137
+ _v1 = GirFFI::InOutPointer.from [:c, :gint32], ints
138
+ length = ints.nil? ? 0 : ints.length
151
139
  _v2 = GirFFI::InOutPointer.from :gint32, length
152
140
  DummyLib.gi_marshalling_tests_object_method_array_inout self, _v1, _v2
153
141
  _v3 = _v2.to_value
@@ -161,7 +149,7 @@ describe GirFFI::Builder::Function do
161
149
 
162
150
  it "builds a correct definition for a simple method" do
163
151
  go = get_method_introspection_data 'Regress', 'TestObj', 'instance_method'
164
- fbuilder = GirFFI::Builder::Function.new go, DummyLib
152
+ fbuilder = GirFFI::FunctionBuilder.new go, DummyLib
165
153
  code = fbuilder.generate
166
154
 
167
155
  expected = <<-CODE