gir_ffi 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/History.txt +7 -0
  2. data/{README.rdoc → README.md} +31 -25
  3. data/Rakefile +1 -1
  4. data/TODO.rdoc +1 -1
  5. data/lib/ffi-glib.rb +5 -5
  6. data/lib/ffi-glib/container_class_methods.rb +1 -2
  7. data/lib/ffi-glib/list_methods.rb +16 -6
  8. data/lib/ffi-gobject.rb +4 -7
  9. data/lib/ffi-gobject/helper.rb +6 -6
  10. data/lib/ffi-gobject/object.rb +4 -4
  11. data/lib/ffi-gobject_introspection.rb +0 -1
  12. data/lib/ffi-gobject_introspection/g_error.rb +15 -5
  13. data/lib/ffi-gobject_introspection/i_base_info.rb +7 -4
  14. data/lib/ffi-gobject_introspection/i_function_info.rb +3 -1
  15. data/lib/ffi-gobject_introspection/i_repository.rb +8 -15
  16. data/lib/ffi-gobject_introspection/i_struct_info.rb +5 -10
  17. data/lib/gir_ffi-base.rb +2 -0
  18. data/lib/gir_ffi-base/glib/strv.rb +43 -0
  19. data/lib/{ffi-gobject_introspection/gobject_lib.rb → gir_ffi-base/gobject/lib.rb} +4 -2
  20. data/lib/gir_ffi/arg_helper.rb +4 -2
  21. data/lib/gir_ffi/builder.rb +1 -7
  22. data/lib/gir_ffi/builder/argument.rb +34 -108
  23. data/lib/gir_ffi/builder/argument/base.rb +26 -20
  24. data/lib/gir_ffi/builder/type/object.rb +14 -2
  25. data/lib/gir_ffi/builder/type/registered_type.rb +1 -11
  26. data/lib/gir_ffi/class_base.rb +21 -26
  27. data/lib/gir_ffi/in_pointer.rb +11 -5
  28. data/lib/gir_ffi/info_ext/i_type_info.rb +26 -0
  29. data/lib/gir_ffi/interface_base.rb +10 -0
  30. data/lib/gir_ffi/module_base.rb +14 -4
  31. data/lib/gir_ffi/object_base.rb +39 -0
  32. data/lib/gir_ffi/type_map.rb +1 -3
  33. data/lib/gir_ffi/version.rb +1 -1
  34. data/tasks/test.rake +33 -44
  35. data/test/{test_helper.rb → base_test_helper.rb} +2 -11
  36. data/test/ffi-glib/array_test.rb +1 -1
  37. data/test/ffi-glib/byte_array_test.rb +1 -1
  38. data/test/ffi-glib/hash_table_test.rb +30 -1
  39. data/test/ffi-glib/list_test.rb +1 -1
  40. data/test/ffi-glib/ptr_array_test.rb +1 -1
  41. data/test/ffi-glib/ruby_closure_test.rb +54 -0
  42. data/test/ffi-glib/s_list_test.rb +1 -1
  43. data/test/ffi-gobject/gobject_test.rb +1 -1
  44. data/test/ffi-gobject/helper_test.rb +103 -0
  45. data/test/ffi-gobject/object_class_test.rb +1 -1
  46. data/test/ffi-gobject/object_test.rb +1 -1
  47. data/test/ffi-gobject/ruby_style_test.rb +1 -1
  48. data/test/ffi-gobject/value_test.rb +1 -1
  49. data/test/ffi-gobject_introspection/i_base_info_test.rb +1 -1
  50. data/test/ffi-gobject_introspection/i_constant_info_test.rb +1 -1
  51. data/test/ffi-gobject_introspection/i_function_info_test.rb +1 -1
  52. data/test/ffi-gobject_introspection/i_object_info_test.rb +1 -1
  53. data/test/ffi-gobject_introspection/i_repository_test.rb +1 -1
  54. data/test/ffi-gobject_introspection/lib_test.rb +1 -1
  55. data/test/ffi-gobject_test.rb +120 -0
  56. data/test/{ffi-glib → gir_ffi-base/glib}/strv_test.rb +8 -5
  57. data/test/{unit → gir_ffi}/arg_helper_test.rb +2 -2
  58. data/test/{unit/argument_builder_test.rb → gir_ffi/builder/argument/base_test.rb} +1 -13
  59. data/test/{unit/function_builder_test.rb → gir_ffi/builder/function_test.rb} +2 -2
  60. data/test/{unit/module_builder_test.rb → gir_ffi/builder/module_test.rb} +1 -1
  61. data/test/{unit/callback_builder_test.rb → gir_ffi/builder/type/callback_test.rb} +1 -1
  62. data/test/{unit/constant_builder_test.rb → gir_ffi/builder/type/constant_test.rb} +1 -1
  63. data/test/{unit/enum_builder_test.rb → gir_ffi/builder/type/enum_test.rb} +1 -1
  64. data/test/{unit/interface_builder_test.rb → gir_ffi/builder/type/interface_test.rb} +1 -4
  65. data/test/{unit/object_type_builder_test.rb → gir_ffi/builder/type/object_test.rb} +21 -2
  66. data/test/{unit/struct_builder_test.rb → gir_ffi/builder/type/struct_test.rb} +1 -1
  67. data/test/{unit/unintrospectable_type_builder_test.rb → gir_ffi/builder/type/unintrospectable_test.rb} +1 -1
  68. data/test/{unit/union_builder_test.rb → gir_ffi/builder/type/union_test.rb} +9 -3
  69. data/test/{unit/user_defined_type_builder_test.rb → gir_ffi/builder/type/user_defined_test.rb} +4 -2
  70. data/test/gir_ffi/builder_test.rb +398 -0
  71. data/test/{unit → gir_ffi}/callback_helper_test.rb +1 -1
  72. data/test/{unit → gir_ffi}/class_base_test.rb +1 -1
  73. data/test/{unit → gir_ffi}/in_out_pointer_test.rb +1 -1
  74. data/test/{unit → gir_ffi}/in_pointer_test.rb +24 -3
  75. data/test/{unit → gir_ffi/info_ext}/i_field_info_test.rb +1 -1
  76. data/test/gir_ffi/info_ext/i_type_info_test.rb +71 -0
  77. data/test/{unit/user_defined_object_info_test.rb → gir_ffi/user_defined/i_object_info_test.rb} +1 -1
  78. data/test/{unit/user_defined_property_info_test.rb → gir_ffi/user_defined/i_property_info_test.rb} +1 -1
  79. data/test/{unit/user_defined_registered_type_info_test.rb → gir_ffi/user_defined/i_registered_type_info_test.rb} +1 -1
  80. data/test/{unit → gir_ffi}/variable_name_generator_test.rb +1 -1
  81. data/test/{unit/gir_ffi_test.rb → gir_ffi_test.rb} +24 -4
  82. data/test/gir_ffi_test_helper.rb +1 -1
  83. data/test/integration/derived_classes_test.rb +1 -1
  84. data/test/integration/generated_gimarshallingtests_test.rb +1 -1
  85. data/test/integration/generated_gio_test.rb +1 -1
  86. data/test/integration/generated_gobject_test.rb +1 -1
  87. data/test/integration/generated_regress_test.rb +2 -3
  88. data/test/integration/method_lookup_test.rb +1 -1
  89. data/test/integration/pretty_print_test.rb +1 -1
  90. data/test/introspection_test_helper.rb +11 -0
  91. metadata +71 -77
  92. data/lib/ffi-glib/strv.rb +0 -31
  93. data/test/builder_test.rb +0 -264
  94. data/test/ffi-glib/glib_overrides_test.rb +0 -38
  95. data/test/ffi-gobject/g_object_overrides_test.rb +0 -274
  96. data/test/girffi_test.rb +0 -27
  97. data/test/integration/generated_pango_test.rb +0 -20
  98. data/test/type_builder_test.rb +0 -36
  99. data/test/unit/builder_test.rb +0 -143
  100. data/test/unit/hash_table_element_type_provider_test.rb +0 -16
  101. data/test/unit/i_type_info_test.rb +0 -23
  102. data/test/unit/list_element_type_provider_test.rb +0 -13
@@ -1,27 +0,0 @@
1
- require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- class GirFFITest < MiniTest::Spec
4
- context "GirFFI" do
5
- it "sets up cairo as Cairo" do
6
- GirFFI.setup :cairo
7
- assert Object.const_defined?(:Cairo)
8
- end
9
-
10
- it "sets up xlib, which has no shared library" do
11
- gir = GObjectIntrospection::IRepository.default
12
- gir.require 'xlib'
13
- assert_nil gir.shared_library('xlib'), "Precondition for test failed"
14
- GirFFI.setup :xlib
15
- end
16
-
17
- it "sets up dependencies" do
18
- save_module :GObject
19
- save_module :Regress
20
- GirFFI.setup :Regress
21
- assert Object.const_defined?(:GObject)
22
- restore_module :Regress
23
- restore_module :GObject
24
- end
25
- end
26
- end
27
-
@@ -1,20 +0,0 @@
1
- # coding: utf-8
2
- require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
3
-
4
- require 'gir_ffi'
5
-
6
- GirFFI.setup :Gdk
7
- GirFFI.setup :Pango
8
- Gdk.init []
9
-
10
- # Tests generated methods and functions in the Pango namespace.
11
- describe "Building classes in the Pango namespace" do
12
- describe "the relevant Pango::FontMap subclass" do
13
- it "is a descendant from Pango::FontMap" do
14
- ctx = Gdk.pango_context_get
15
- result = ctx.get_font_map
16
- result.class.ancestors.must_include Pango::FontMap
17
- end
18
- end
19
- end
20
-
@@ -1,36 +0,0 @@
1
- require File.expand_path('gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- class TypeBuilderTest < MiniTest::Spec
4
- context "The Builder::Type class" do
5
- context 'the find_signal method' do
6
- should 'find the signal "test" for TestObj' do
7
- builder = GirFFI::Builder::Type::Object.new get_introspection_data('Regress', 'TestObj')
8
- sig = builder.find_signal 'test'
9
- assert_equal 'test', sig.name
10
- end
11
-
12
- should 'find the signal "test" for TestSubObj' do
13
- builder = GirFFI::Builder::Type::Object.new get_introspection_data('Regress', 'TestSubObj')
14
- sig = builder.find_signal 'test'
15
- assert_equal 'test', sig.name
16
- end
17
-
18
- should 'find the signal "changed" for Gtk::Entry' do
19
- builder = GirFFI::Builder::Type::Object.new get_introspection_data('Gtk', 'Entry')
20
- sig = builder.find_signal 'changed'
21
- assert_equal 'changed', sig.name
22
- end
23
- end
24
-
25
- context "for GObject::TypeCValue (a union)" do
26
- setup do
27
- @cbuilder = GirFFI::Builder::Type::Union.new get_introspection_data('GObject', 'TypeCValue')
28
- end
29
-
30
- should "returns false looking for a method that doesn't exist" do
31
- assert_equal false, @cbuilder.setup_instance_method('blub')
32
- end
33
- end
34
- end
35
- end
36
-
@@ -1,143 +0,0 @@
1
- require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- describe GirFFI::Builder do
4
- describe "::itypeinfo_to_callback_ffitype" do
5
- describe "for an :interface argument" do
6
- before do
7
- @iface = Object.new
8
- stub(@info = Object.new).interface { @iface }
9
- stub(@info).tag { :interface }
10
- stub(@info).pointer? { false }
11
- end
12
-
13
- it "correctly maps a :union argument to :pointer" do
14
- stub(@iface).info_type { :union }
15
-
16
- result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
17
-
18
- assert_equal :pointer, result
19
- end
20
-
21
- it "correctly maps a :flags argument to :int32" do
22
- stub(@iface).info_type { :flags }
23
-
24
- result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
25
-
26
- assert_equal :int32, result
27
- end
28
- end
29
- end
30
-
31
- describe "building Regress::TestSubObj" do
32
- before do
33
- save_module :Regress
34
- save_module :GObject
35
- GirFFI::Builder.build_class get_introspection_data('Regress', 'TestSubObj')
36
- end
37
-
38
- it "builds Regress namespace" do
39
- assert Regress.const_defined? :Lib
40
- assert Regress.respond_to? :method_missing
41
- end
42
-
43
- it "builds parent classes also" do
44
- assert Regress.const_defined? :TestObj
45
- assert Object.const_defined? :GObject
46
- assert GObject.const_defined? :Object
47
- end
48
-
49
- it "sets up the inheritance chain" do
50
- ancestors = Regress::TestSubObj.ancestors
51
- assert_equal [
52
- Regress::TestSubObj,
53
- Regress::TestObj,
54
- GObject::Object
55
- ], ancestors[0..2]
56
- end
57
-
58
- it "creates a Regress::TestSubObj#to_ptr method" do
59
- assert Regress::TestSubObj.public_method_defined? :to_ptr
60
- end
61
-
62
- after do
63
- restore_module :Regress
64
- restore_module :GObject
65
- end
66
- end
67
-
68
- describe "building Regress" do
69
- before do
70
- save_module :Regress
71
- GirFFI::Builder.build_module 'Regress'
72
- end
73
-
74
- it "creates a Lib module ready to attach functions from the shared library" do
75
- gir = GObjectIntrospection::IRepository.default
76
- expected = [gir.shared_library('Regress')]
77
- assert_equal expected, Regress::Lib.ffi_libraries.map(&:name)
78
- end
79
-
80
- it "creates an array CALLBACKS inside the Regress::Lib module" do
81
- assert_equal [], Regress::Lib::CALLBACKS
82
- end
83
-
84
- it "does not replace existing module" do
85
- oldmodule = Regress
86
- GirFFI::Builder.build_module 'Regress'
87
- assert_equal oldmodule, Regress
88
- end
89
-
90
- it "does not replace existing Lib module" do
91
- oldmodule = Regress::Lib
92
- GirFFI::Builder.build_module 'Regress'
93
- assert_equal oldmodule, Regress::Lib
94
- end
95
-
96
- after do
97
- restore_module :Regress
98
- end
99
- end
100
-
101
- describe "looking at Regress.test_array_gint32_in" do
102
- setup do
103
- save_module :Regress
104
- GirFFI::Builder.build_module 'Regress'
105
- @go = get_introspection_data 'Regress', 'test_array_gint32_in'
106
- end
107
-
108
- it "has correct introspection data" do
109
- gir = GObjectIntrospection::IRepository.default
110
- gir.require "Regress", nil
111
- go2 = gir.find_by_name "Regress", "test_array_gint32_in"
112
- assert_equal go2, @go
113
- end
114
-
115
- it "attaches function to Regress::Lib" do
116
- GirFFI::Builder.send :attach_ffi_function, Regress::Lib, @go
117
- assert_defines_singleton_method Regress::Lib, :regress_test_array_gint32_in
118
- end
119
-
120
- it "has :pointer, :pointer as types of the arguments for the attached function" do
121
- assert_equal [:int32, :pointer], GirFFI::Builder.send(:ffi_function_argument_types, @go)
122
- end
123
-
124
- it "has :void as return type for the attached function" do
125
- assert_equal :int32, GirFFI::Builder.send(:ffi_function_return_type, @go)
126
- end
127
-
128
- after do
129
- restore_module :Regress
130
- end
131
- end
132
-
133
- describe "looking at Regress::TestObj#instance_method" do
134
- setup do
135
- @go = get_method_introspection_data 'Regress', 'TestObj', 'instance_method'
136
- end
137
-
138
- it "has :pointer as types of the arguments for the attached function" do
139
- assert_equal [:pointer], GirFFI::Builder.send(:ffi_function_argument_types, @go)
140
- end
141
- end
142
- end
143
-
@@ -1,16 +0,0 @@
1
- require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- describe GirFFI::Builder::HashTableElementTypeProvider do
4
- describe "#elm_t" do
5
- it "returns a string with an array of the first two subtype tags" do
6
- builder = Object.new
7
- builder.extend GirFFI::Builder::HashTableElementTypeProvider
8
-
9
- stub(builder).subtype_tag(0) { :foo }
10
- stub(builder).subtype_tag(1) { :bar }
11
-
12
- assert_equal "[:foo, :bar]", builder.elm_t
13
- end
14
- end
15
- end
16
-
@@ -1,23 +0,0 @@
1
- require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- describe GirFFI::InfoExt::ITypeInfo do
4
- describe "#layout_specification_type" do
5
- it "returns an array with elements subtype and size for type :array" do
6
- testclass = Class.new do
7
- include GirFFI::InfoExt::ITypeInfo
8
- end
9
-
10
- mock(subtype = Object.new).layout_specification_type { :foo }
11
-
12
- type = testclass.new
13
- mock(type).array_fixed_size { 2 }
14
- mock(type).param_type(0) { subtype }
15
-
16
- mock(GirFFI::Builder).itypeinfo_to_ffitype(type) { :array }
17
-
18
- result = type.layout_specification_type
19
-
20
- assert_equal [:foo, 2], result
21
- end
22
- end
23
- end
@@ -1,13 +0,0 @@
1
- require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))
2
-
3
- describe GirFFI::Builder::ListElementTypeProvider do
4
- describe "#elm_t" do
5
- it "returns a string with just the first subtype tag" do
6
- builder = Object.new
7
- builder.extend GirFFI::Builder::ListElementTypeProvider
8
- mock(builder).subtype_tag { :foo }
9
-
10
- assert_equal ":foo", builder.elm_t
11
- end
12
- end
13
- end