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,5 +1,7 @@
1
- module GObjectIntrospection
2
- module GObjectLib
1
+ require 'ffi'
2
+
3
+ module GObject
4
+ module Lib
3
5
  extend FFI::Library
4
6
  ffi_lib "gobject-2.0"
5
7
  attach_function :g_type_init, [], :void
@@ -11,9 +11,11 @@ module GirFFI
11
11
  SIMPLE_G_TYPES = [
12
12
  :gint8, :gint16, :gint, :gint32, :gint64,
13
13
  :guint8, :guint16, :guint32, :guint64,
14
- :gfloat, :gdouble]
14
+ :gfloat, :gdouble
15
+ ]
15
16
 
16
- # FIXME: Hideous.
17
+ # FIXME: Hideous
18
+ # TODO: Move this implementation to InPointer
17
19
  def self.object_to_inptr obj
18
20
  return obj.to_ptr if obj.respond_to? :to_ptr
19
21
  return nil if obj.nil?
@@ -71,13 +71,7 @@ module GirFFI
71
71
  end
72
72
 
73
73
  def self.ffi_function_return_type info
74
- rt = info.return_type
75
- # FIXME: Workaround for older gobject-introspection not identifying all
76
- # objects as being pointers.
77
- if rt.tag == :interface and rt.interface.info_type == :object
78
- return :pointer
79
- end
80
- itypeinfo_to_ffitype rt
74
+ itypeinfo_to_ffitype info.return_type
81
75
  end
82
76
 
83
77
  def self.itypeinfo_to_callback_ffitype info
@@ -31,33 +31,15 @@ module GirFFI::Builder
31
31
  case type.interface.info_type
32
32
  when :callback
33
33
  return CallbackInArgument.new var_gen, name, type, libmodule
34
- when :object, :struct
35
- ObjectInArgument
36
34
  else
37
35
  RegularInArgument
38
36
  end
39
- when :void
40
- VoidInArgument
41
37
  when :array
42
38
  if type.array_type == :c
43
39
  CArrayInArgument
44
40
  else
45
41
  RegularInArgument
46
42
  end
47
- when :glist, :gslist
48
- it = Argument::InBase.new var_gen, name, type
49
- it.extend ContainerClassName
50
- it.extend ListElementTypeProvider
51
- it.extend WithTypedContainerPreMethod
52
- return it
53
- when :ghash
54
- it = Argument::InBase.new var_gen, name, type
55
- it.extend ContainerClassName
56
- it.extend HashTableElementTypeProvider
57
- it.extend WithTypedContainerPreMethod
58
- return it
59
- when :utf8
60
- Utf8InArgument
61
43
  else
62
44
  RegularInArgument
63
45
  end
@@ -80,42 +62,8 @@ module GirFFI::Builder
80
62
  end
81
63
  end
82
64
 
83
- # Implements argument processing for void pointer arguments with
84
- # direction :in.
85
- class VoidInArgument < Argument::InBase
86
- def pre
87
- [ "#{callarg} = GirFFI::ArgHelper.object_to_inptr #{@name}" ]
88
- end
89
- end
90
-
91
- module ContainerClassName
92
- TAG_TO_CONTAINER_CLASS_MAP = {
93
- :glist => 'GLib::List',
94
- :gslist => 'GLib::SList',
95
- :ghash => 'GLib::HashTable',
96
- :array => 'GLib::Array'
97
- }
98
-
99
- def class_name
100
- TAG_TO_CONTAINER_CLASS_MAP[type_info.tag]
101
- end
102
- end
103
-
104
- module ListElementTypeProvider
105
- def elm_t
106
- subtype_tag.inspect
107
- end
108
- end
109
-
110
- module HashTableElementTypeProvider
111
- def elm_t
112
- [subtype_tag(0), subtype_tag(1)].inspect
113
- end
114
- end
115
-
116
65
  # Implements argument processing for array arguments with direction :in.
117
66
  class CArrayInArgument < Argument::InBase
118
- include ListElementTypeProvider
119
67
  def pre
120
68
  pr = []
121
69
  size = type_info.array_fixed_size
@@ -127,40 +75,43 @@ module GirFFI::Builder
127
75
  end
128
76
  end
129
77
 
130
- module WithTypedContainerPreMethod
131
- def pre
132
- [ "#{callarg} = #{class_name}.from #{elm_t}, #{@name}" ]
133
- end
134
- end
135
-
136
- # Implements argument processing for UTF8 string arguments with direction
137
- # :in.
138
- class Utf8InArgument < Argument::InBase
139
- def pre
140
- [ "#{callarg} = GirFFI::InPointer.from :utf8, #{@name}" ]
141
- end
142
- end
143
-
144
- # Implements argument processing for arguments with direction :in that
145
- # are GObjects.
146
- class ObjectInArgument < Argument::InBase
147
- def pre
148
- [ "#{callarg} = #{argument_class_name}.from #{@name}" ]
149
- end
150
- end
151
-
152
78
  # Implements argument processing for arguments with direction :in whose
153
79
  # type-specific processing is left to FFI (e.g., ints and floats, and
154
80
  # objects that implement to_ptr.).
81
+ #
82
+ # Implements argument processing for arguments with direction :in that
83
+ # are GObjects.
84
+ #
85
+ # Implements argument processing for UTF8 string arguments with direction
86
+ # :in.
87
+ #
88
+ # Implements argument processing for void pointer arguments with
89
+ # direction :in.
155
90
  class RegularInArgument < Argument::InBase
156
91
  def pre
157
92
  pr = []
93
+ assign_array_length(pr)
94
+ set_function_call_argument(pr)
95
+ pr
96
+ end
97
+
98
+ def assign_array_length(pr)
158
99
  if @array_arg
159
100
  arrname = @array_arg.name
160
- pr << "#{@name} = #{arrname}.nil? ? 0 : #{arrname}.length"
101
+ pr << "#{@name} = #{arrname}.nil? ? 0 : #{arrname}.length"
102
+ end
103
+ end
104
+
105
+ def set_function_call_argument(pr)
106
+ if type_tag == :interface && [:object, :struct].include?(type_info.interface.info_type)
107
+ pr << "#{callarg} = #{argument_class_name}.from #{@name}"
108
+ elsif [:utf8, :void].include? type_tag
109
+ pr << "#{callarg} = #{argument_class_name}.from #{type_tag.inspect}, #{@name}"
110
+ elsif [:glist, :gslist, :ghash].include? type_tag
111
+ pr << "#{callarg} = #{argument_class_name}.from #{elm_t}, #{@name}"
112
+ else
113
+ pr << "#{callarg} = #{@name}"
161
114
  end
162
- pr << "#{callarg} = #{@name}"
163
- pr
164
115
  end
165
116
  end
166
117
 
@@ -182,29 +133,23 @@ module GirFFI::Builder
182
133
  end
183
134
  when :array
184
135
  if type.zero_terminated?
185
- StrvOutArgument
136
+ InterfaceOutArgument
186
137
  else
187
138
  case type.array_type
188
139
  when :c
189
140
  CArrayOutArgument
190
141
  when :array
191
142
  it = PointerLikeOutArgument.new var_gen, arginfo.name, type
192
- it.extend ContainerClassName
193
- it.extend ListElementTypeProvider
194
143
  it.extend WithTypedContainerPostMethod
195
144
  return it
196
145
  end
197
146
  end
198
147
  when :glist, :gslist
199
148
  it = PointerLikeOutArgument.new var_gen, arginfo.name, type
200
- it.extend ContainerClassName
201
- it.extend ListElementTypeProvider
202
149
  it.extend WithTypedContainerPostMethod
203
150
  return it
204
151
  when :ghash
205
152
  it = PointerLikeOutArgument.new var_gen, arginfo.name, type
206
- it.extend ContainerClassName
207
- it.extend HashTableElementTypeProvider
208
153
  it.extend WithTypedContainerPostMethod
209
154
  return it
210
155
  else
@@ -273,23 +218,18 @@ module GirFFI::Builder
273
218
 
274
219
  # Implements argument processing for interface arguments with direction
275
220
  # :out (structs, objects, etc.).
276
- class InterfaceOutArgument < PointerLikeOutArgument
277
- def post
278
- [ "#{retname} = #{argument_class_name}.wrap #{callarg}.to_value" ]
279
- end
280
- end
281
-
221
+ #
282
222
  # Implements argument processing for strv arguments with direction
283
223
  # :out.
284
- class StrvOutArgument < PointerLikeOutArgument
224
+ class InterfaceOutArgument < PointerLikeOutArgument
285
225
  def post
286
- [ "#{retname} = GLib::Strv.wrap #{callarg}.to_value" ]
226
+ [ "#{retname} = #{argument_class_name}.wrap #{callarg}.to_value" ]
287
227
  end
288
228
  end
289
229
 
290
230
  module WithTypedContainerPostMethod
291
231
  def post
292
- [ "#{retname} = #{class_name}.wrap #{elm_t}, #{callarg}.to_value" ]
232
+ [ "#{retname} = #{argument_class_name}.wrap #{elm_t}, #{callarg}.to_value" ]
293
233
  end
294
234
  end
295
235
 
@@ -314,8 +254,6 @@ module GirFFI::Builder
314
254
  CArrayInOutArgument
315
255
  when :array
316
256
  it = Argument::InOutBase.new var_gen, arginfo.name, type
317
- it.extend ContainerClassName
318
- it.extend ListElementTypeProvider
319
257
  it.extend WithTypedContainerInOutPreMethod
320
258
  it.extend WithTypedContainerPostMethod
321
259
  return it
@@ -323,15 +261,11 @@ module GirFFI::Builder
323
261
  end
324
262
  when :glist, :gslist
325
263
  it = Argument::InOutBase.new var_gen, arginfo.name, type
326
- it.extend ContainerClassName
327
- it.extend ListElementTypeProvider
328
264
  it.extend WithTypedContainerInOutPreMethod
329
265
  it.extend WithTypedContainerPostMethod
330
266
  return it
331
267
  when :ghash
332
268
  it = Argument::InOutBase.new var_gen, arginfo.name, type
333
- it.extend ContainerClassName
334
- it.extend HashTableElementTypeProvider
335
269
  it.extend WithTypedContainerInOutPreMethod
336
270
  it.extend WithTypedContainerPostMethod
337
271
  return it
@@ -372,7 +306,6 @@ module GirFFI::Builder
372
306
  # Implements argument processing for strv arguments with direction
373
307
  # :inout.
374
308
  class StrvInOutArgument < Argument::InOutBase
375
- include ListElementTypeProvider
376
309
  def pre
377
310
  [ "#{callarg} = GirFFI::InOutPointer.from_array #{elm_t}, #{@name}" ]
378
311
  end
@@ -385,7 +318,6 @@ module GirFFI::Builder
385
318
  # Implements argument processing for array arguments with direction
386
319
  # :inout.
387
320
  class CArrayInOutArgument < Argument::InOutBase
388
- include ListElementTypeProvider
389
321
  def pre
390
322
  [ "#{callarg} = GirFFI::InOutPointer.from_array #{elm_t}, #{@name}" ]
391
323
  end
@@ -399,7 +331,7 @@ module GirFFI::Builder
399
331
 
400
332
  module WithTypedContainerInOutPreMethod
401
333
  def pre
402
- [ "#{callarg} = GirFFI::InOutPointer.from :pointer, #{class_name}.from(#{elm_t}, #{@name})" ]
334
+ [ "#{callarg} = GirFFI::InOutPointer.from :pointer, #{argument_class_name}.from(#{elm_t}, #{@name})" ]
403
335
  end
404
336
  end
405
337
 
@@ -466,8 +398,6 @@ module GirFFI::Builder
466
398
  CArrayReturnValue
467
399
  when :array
468
400
  it = ReturnValue.new var_gen, name, type
469
- it.extend ContainerClassName
470
- it.extend ListElementTypeProvider
471
401
  it.extend WithTypedContainerPostMethod
472
402
  return it
473
403
  when :byte_array
@@ -478,14 +408,10 @@ module GirFFI::Builder
478
408
  end
479
409
  when :glist, :gslist
480
410
  it = ReturnValue.new var_gen, name, type
481
- it.extend ContainerClassName
482
- it.extend ListElementTypeProvider
483
411
  it.extend WithTypedContainerPostMethod
484
412
  return it
485
413
  when :ghash
486
414
  it = ReturnValue.new var_gen, name, type
487
- it.extend ContainerClassName
488
- it.extend HashTableElementTypeProvider
489
415
  it.extend WithTypedContainerPostMethod
490
416
  return it
491
417
  when :utf8
@@ -32,33 +32,35 @@ module GirFFI
32
32
  end
33
33
 
34
34
  def type_tag
35
- tag = type_info.tag
36
- tag == :GType ? :gtype : tag
35
+ type_info.tag
37
36
  end
38
37
 
39
- def subtype_tag index=0
40
- st = type_info.param_type(index)
41
- tag = st.tag
42
- case tag
43
- when :GType
44
- return :gtype
38
+ TAG_TO_WRAPPER_CLASS_MAP = {
39
+ :glist => 'GLib::List',
40
+ :gslist => 'GLib::SList',
41
+ :ghash => 'GLib::HashTable',
42
+ :array => 'GLib::Array',
43
+ :utf8 => 'GirFFI::InPointer',
44
+ :void => 'GirFFI::InPointer'
45
+ }
46
+
47
+ def argument_class_name
48
+ case (tag = type_tag)
45
49
  when :interface
46
- return :interface_pointer if st.pointer?
47
- return :interface
48
- when :void
49
- return :gpointer if st.pointer?
50
- return :void
50
+ iface = type_info.interface
51
+ # FIXME: Extract to ITypeInfo.
52
+ "::#{iface.safe_namespace}::#{iface.name}"
53
+ when :array
54
+ if type_info.zero_terminated?
55
+ 'GLib::Strv'
56
+ else
57
+ 'GLib::Array'
58
+ end
51
59
  else
52
- return tag
60
+ TAG_TO_WRAPPER_CLASS_MAP[tag]
53
61
  end
54
62
  end
55
63
 
56
- def argument_class_name
57
- iface = type_info.interface
58
- # FIXME: Extract to ITypeInfo.
59
- "::#{iface.safe_namespace}::#{iface.name}"
60
- end
61
-
62
64
  def subtype_tag_or_class_name index=0
63
65
  type = type_info.param_type(index)
64
66
  tag = type.tag
@@ -75,6 +77,10 @@ module GirFFI
75
77
  end
76
78
  end
77
79
 
80
+ def elm_t
81
+ type_info.element_type.inspect
82
+ end
83
+
78
84
  def array_size
79
85
  if @length_arg
80
86
  @length_arg.retname
@@ -1,6 +1,7 @@
1
1
  require 'gir_ffi/builder/type/struct_based'
2
2
  require 'gir_ffi/builder/property'
3
3
  require 'gir_ffi/info_ext/i_property_info'
4
+ require 'gir_ffi/object_base'
4
5
 
5
6
  module GirFFI
6
7
  module Builder
@@ -15,7 +16,7 @@ module GirFFI
15
16
  end
16
17
  end
17
18
  if parent
18
- return superclass._find_signal signal_name
19
+ return superclass.find_signal signal_name
19
20
  end
20
21
  raise "Signal #{signal_name} not found"
21
22
  end
@@ -25,7 +26,7 @@ module GirFFI
25
26
  return prop if prop.name == property_name
26
27
  end
27
28
  if parent
28
- return superclass._find_property property_name
29
+ return superclass.find_property property_name
29
30
  end
30
31
  raise "Property #{property_name} not found"
31
32
  end
@@ -58,6 +59,17 @@ module GirFFI
58
59
  @parent
59
60
  end
60
61
 
62
+ def superclass
63
+ unless defined? @superclass
64
+ if parent
65
+ @superclass = Builder.build_class parent
66
+ else
67
+ @superclass = ObjectBase
68
+ end
69
+ end
70
+ @superclass
71
+ end
72
+
61
73
  def setup_property_accessors
62
74
  info.properties.each do |prop|
63
75
  setup_accessors_for_property_info prop
@@ -54,19 +54,9 @@ module GirFFI
54
54
  end
55
55
 
56
56
  def superclass
57
- unless defined? @superclass
58
- if parent
59
- @superclass = Builder.build_class parent
60
- else
61
- @superclass = GirFFI::ClassBase
62
- end
63
- end
64
- @superclass
57
+ @superclass ||= ClassBase
65
58
  end
66
59
  end
67
60
  end
68
61
  end
69
62
  end
70
-
71
-
72
-
@@ -9,14 +9,6 @@ module GirFFI
9
9
  extend Forwardable
10
10
  def_delegators :@struct, :to_ptr
11
11
 
12
- def ffi_structure
13
- self.class.ffi_structure
14
- end
15
-
16
- def _builder
17
- self.class._builder
18
- end
19
-
20
12
  def setup_and_call method, *arguments, &block
21
13
  result = self.class.ancestors.any? do |klass|
22
14
  klass.respond_to?(:_setup_instance_method) &&
@@ -44,31 +36,39 @@ module GirFFI
44
36
  end
45
37
 
46
38
  class << self
39
+ # @deprecated Compatibility function. Remove in version 0.5.0.
47
40
  def ffi_structure
48
- self.const_get(:Struct)
41
+ self::Struct
49
42
  end
50
43
 
51
44
  def gir_info
52
- self.const_get :GIR_INFO
45
+ self.const_get :GIR_INFO
53
46
  end
54
47
 
48
+ # @deprecated Compatibility function. Remove in version 0.5.0.
55
49
  def _builder
56
- self.const_get :GIR_FFI_BUILDER
50
+ gir_ffi_builder
57
51
  end
58
52
 
59
- def _find_signal name
60
- _builder.find_signal name
53
+ def gir_ffi_builder
54
+ self.const_get :GIR_FFI_BUILDER
61
55
  end
62
56
 
63
- def _find_property name
64
- _builder.find_property name
57
+ # @deprecated Compatibility function. Remove in version 0.5.0.
58
+ def _setup_method name
59
+ setup_method name
65
60
  end
66
61
 
67
- def _setup_method name
62
+ def setup_method name
68
63
  _builder.setup_method name
69
64
  end
70
65
 
66
+ # @deprecated Compatibility function. Remove in version 0.5.0.
71
67
  def _setup_instance_method name
68
+ setup_instance_method name
69
+ end
70
+
71
+ def setup_instance_method name
72
72
  _builder.setup_instance_method name
73
73
  end
74
74
 
@@ -76,20 +76,15 @@ module GirFFI
76
76
  undef new
77
77
 
78
78
  def wrap ptr
79
- return nil if ptr.nil? or ptr.null?
80
- obj = _real_new
81
- obj.instance_variable_set :@struct, ffi_structure.new(ptr.to_ptr)
79
+ return nil if ptr.nil? or ptr.null?
80
+ obj = _real_new
81
+ obj.instance_variable_set :@struct, self::Struct.new(ptr.to_ptr)
82
82
  obj
83
83
  end
84
84
 
85
- # TODO: Only makes sense for :objects.
86
- def constructor_wrap ptr
87
- wrap ptr
88
- end
89
-
90
85
  def allocate
91
- obj = _real_new
92
- obj.instance_variable_set :@struct, ffi_structure.new
86
+ obj = _real_new
87
+ obj.instance_variable_set :@struct, self::Struct.new
93
88
  obj
94
89
  end
95
90