gir_ffi 0.6.6 → 0.6.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/History.txt +14 -0
  2. data/TODO.rdoc +23 -5
  3. data/lib/ffi-glib/array.rb +14 -15
  4. data/lib/ffi-glib/container_class_methods.rb +0 -1
  5. data/lib/ffi-glib/hash_table.rb +3 -4
  6. data/lib/ffi-glib/ptr_array.rb +12 -4
  7. data/lib/ffi-glib/sized_array.rb +27 -7
  8. data/lib/ffi-gobject.rb +14 -15
  9. data/lib/ffi-gobject/closure.rb +1 -1
  10. data/lib/ffi-gobject/object.rb +40 -15
  11. data/lib/ffi-gobject/ruby_closure.rb +0 -1
  12. data/lib/ffi-gobject/value.rb +45 -21
  13. data/lib/ffi-gobject_introspection/i_arg_info.rb +4 -0
  14. data/lib/ffi-gobject_introspection/i_base_info.rb +42 -2
  15. data/lib/ffi-gobject_introspection/i_callable_info.rb +8 -0
  16. data/lib/ffi-gobject_introspection/i_enum_info.rb +1 -4
  17. data/lib/ffi-gobject_introspection/i_interface_info.rb +1 -0
  18. data/lib/ffi-gobject_introspection/i_object_info.rb +2 -0
  19. data/lib/ffi-gobject_introspection/i_repository.rb +2 -3
  20. data/lib/ffi-gobject_introspection/i_struct_info.rb +3 -8
  21. data/lib/ffi-gobject_introspection/lib.rb +3 -0
  22. data/lib/gir_ffi-base.rb +3 -1
  23. data/lib/gir_ffi-base/gir_ffi/struct.rb +27 -0
  24. data/lib/gir_ffi-base/glib/boolean.rb +13 -1
  25. data/lib/gir_ffi-base/gobject.rb +7 -0
  26. data/lib/gir_ffi-base/gobject/lib.rb +0 -2
  27. data/lib/gir_ffi.rb +1 -3
  28. data/lib/gir_ffi/arg_helper.rb +4 -85
  29. data/lib/gir_ffi/builder.rb +5 -5
  30. data/lib/gir_ffi/builder_helper.rb +7 -0
  31. data/lib/gir_ffi/builders/argument_builder.rb +132 -0
  32. data/lib/gir_ffi/{base_argument_builder.rb → builders/base_argument_builder.rb} +32 -41
  33. data/lib/gir_ffi/builders/base_type_builder.rb +47 -0
  34. data/lib/gir_ffi/builders/callback_builder.rb +38 -0
  35. data/lib/gir_ffi/builders/constant_builder.rb +18 -0
  36. data/lib/gir_ffi/builders/enum_builder.rb +62 -0
  37. data/lib/gir_ffi/builders/error_argument_builder.rb +18 -0
  38. data/lib/gir_ffi/builders/field_builder.rb +94 -0
  39. data/lib/gir_ffi/builders/function_builder.rb +123 -0
  40. data/lib/gir_ffi/builders/interface_builder.rb +29 -0
  41. data/lib/gir_ffi/builders/mapping_method_builder.rb +88 -0
  42. data/lib/gir_ffi/builders/module_builder.rb +124 -0
  43. data/lib/gir_ffi/{null_argument_builder.rb → builders/null_argument_builder.rb} +0 -0
  44. data/lib/gir_ffi/builders/null_builder.rb +11 -0
  45. data/lib/gir_ffi/builders/object_builder.rb +123 -0
  46. data/lib/gir_ffi/{builder/property.rb → builders/property_builder.rb} +0 -0
  47. data/lib/gir_ffi/builders/registered_type_builder.rb +50 -0
  48. data/lib/gir_ffi/builders/return_value_builder.rb +68 -0
  49. data/lib/gir_ffi/builders/signal_builder.rb +91 -0
  50. data/lib/gir_ffi/builders/struct_builder.rb +35 -0
  51. data/lib/gir_ffi/builders/type_builder.rb +40 -0
  52. data/lib/gir_ffi/builders/unintrospectable_builder.rb +35 -0
  53. data/lib/gir_ffi/builders/union_builder.rb +34 -0
  54. data/lib/gir_ffi/builders/user_defined_builder.rb +103 -0
  55. data/lib/gir_ffi/builders/with_layout.rb +55 -0
  56. data/lib/gir_ffi/builders/with_methods.rb +44 -0
  57. data/lib/gir_ffi/callback_base.rb +31 -0
  58. data/lib/gir_ffi/class_base.rb +16 -10
  59. data/lib/gir_ffi/enum_base.rb +8 -4
  60. data/lib/gir_ffi/ffi_ext/pointer.rb +19 -2
  61. data/lib/gir_ffi/in_out_pointer.rb +38 -39
  62. data/lib/gir_ffi/in_pointer.rb +33 -18
  63. data/lib/gir_ffi/info_ext.rb +0 -4
  64. data/lib/gir_ffi/info_ext/i_arg_info.rb +0 -18
  65. data/lib/gir_ffi/info_ext/i_callable_info.rb +2 -1
  66. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +6 -8
  67. data/lib/gir_ffi/info_ext/i_signal_info.rb +6 -21
  68. data/lib/gir_ffi/info_ext/i_type_info.rb +54 -29
  69. data/lib/gir_ffi/info_ext/safe_constant_name.rb +8 -1
  70. data/lib/gir_ffi/interface_base.rb +1 -1
  71. data/lib/gir_ffi/module_base.rb +5 -1
  72. data/lib/gir_ffi/object_base.rb +5 -1
  73. data/lib/gir_ffi/setter_argument_info.rb +4 -0
  74. data/lib/gir_ffi/signal_base.rb +21 -0
  75. data/lib/gir_ffi/struct_base.rb +24 -0
  76. data/lib/gir_ffi/type_base.rb +11 -0
  77. data/lib/gir_ffi/type_map.rb +4 -2
  78. data/lib/gir_ffi/union_base.rb +24 -0
  79. data/lib/gir_ffi/version.rb +1 -1
  80. data/tasks/test.rake +73 -7
  81. data/test/base_test_helper.rb +3 -19
  82. data/test/ffi-glib/array_test.rb +6 -0
  83. data/test/ffi-glib/ptr_array_test.rb +13 -0
  84. data/test/ffi-glib/ruby_closure_test.rb +7 -7
  85. data/test/ffi-glib/sized_array_test.rb +2 -2
  86. data/test/ffi-gobject/gobject_test.rb +3 -12
  87. data/test/ffi-gobject/object_test.rb +33 -2
  88. data/test/ffi-gobject/value_test.rb +114 -1
  89. data/test/ffi-gobject_introspection/i_enum_info_test.rb +2 -2
  90. data/test/ffi-gobject_introspection/i_object_info_test.rb +3 -3
  91. data/test/ffi-gobject_introspection/i_repository_test.rb +26 -21
  92. data/test/ffi-gobject_test.rb +14 -14
  93. data/test/gir_ffi-base/glib/boolean_test.rb +6 -0
  94. data/test/gir_ffi/arg_helper_test.rb +2 -122
  95. data/test/gir_ffi/builder_test.rb +67 -204
  96. data/test/gir_ffi/{argument_builder_test.rb → builders/argument_builder_test.rb} +230 -108
  97. data/test/gir_ffi/builders/base_argument_builder_test.rb +5 -0
  98. data/test/gir_ffi/builders/callback_builder_test.rb +50 -0
  99. data/test/gir_ffi/builders/constant_builder_test.rb +4 -0
  100. data/test/gir_ffi/{builder/type/enum_test.rb → builders/enum_builder_test.rb} +2 -3
  101. data/test/gir_ffi/builders/field_builder_test.rb +94 -0
  102. data/test/gir_ffi/{function_builder_test.rb → builders/function_builder_test.rb} +43 -24
  103. data/test/gir_ffi/{builder/type/interface_test.rb → builders/interface_builder_test.rb} +2 -2
  104. data/test/gir_ffi/{builder/module_test.rb → builders/module_builder_test.rb} +12 -13
  105. data/test/gir_ffi/{builder/type/object_test.rb → builders/object_builder_test.rb} +9 -9
  106. data/test/gir_ffi/{return_value_builder_test.rb → builders/return_value_builder_test.rb} +94 -58
  107. data/test/gir_ffi/builders/signal_builder_test.rb +62 -0
  108. data/test/gir_ffi/{builder/type/struct_test.rb → builders/struct_builder_test.rb} +36 -19
  109. data/test/gir_ffi/{builder/type/unintrospectable_test.rb → builders/unintrospectable_builder_test.rb} +3 -3
  110. data/test/gir_ffi/builders/union_builder_test.rb +29 -0
  111. data/test/gir_ffi/{builder/type/user_defined_test.rb → builders/user_defined_builder_test.rb} +2 -2
  112. data/test/gir_ffi/callback_base_test.rb +11 -0
  113. data/test/gir_ffi/class_base_test.rb +22 -22
  114. data/test/gir_ffi/ffi_ext/pointer_test.rb +18 -0
  115. data/test/gir_ffi/in_out_pointer_test.rb +0 -7
  116. data/test/gir_ffi/in_pointer_test.rb +27 -3
  117. data/test/gir_ffi/info_ext/i_signal_info_test.rb +16 -44
  118. data/test/gir_ffi/info_ext/i_type_info_test.rb +315 -74
  119. data/test/gir_ffi/info_ext/safe_constant_name_test.rb +6 -0
  120. data/test/gir_ffi/interface_base_test.rb +3 -5
  121. data/test/gir_ffi/object_base_test.rb +10 -6
  122. data/test/gir_ffi/type_map_test.rb +2 -2
  123. data/test/gir_ffi/unintrospectable_type_info_test.rb +2 -2
  124. data/test/gir_ffi_test_helper.rb +12 -4
  125. data/test/integration/generated_gimarshallingtests_test.rb +436 -76
  126. data/test/integration/generated_gio_test.rb +5 -11
  127. data/test/integration/generated_gobject_test.rb +8 -0
  128. data/test/integration/generated_regress_test.rb +755 -309
  129. data/test/integration/generated_secret_test.rb +2 -1
  130. metadata +73 -72
  131. data/lib/ffi-gobject/ruby_style.rb +0 -23
  132. data/lib/gir_ffi/argument_builder.rb +0 -154
  133. data/lib/gir_ffi/builder/field.rb +0 -60
  134. data/lib/gir_ffi/builder/module.rb +0 -127
  135. data/lib/gir_ffi/builder/type.rb +0 -39
  136. data/lib/gir_ffi/builder/type/base.rb +0 -48
  137. data/lib/gir_ffi/builder/type/callback.rb +0 -30
  138. data/lib/gir_ffi/builder/type/constant.rb +0 -22
  139. data/lib/gir_ffi/builder/type/enum.rb +0 -66
  140. data/lib/gir_ffi/builder/type/interface.rb +0 -33
  141. data/lib/gir_ffi/builder/type/object.rb +0 -134
  142. data/lib/gir_ffi/builder/type/registered_type.rb +0 -62
  143. data/lib/gir_ffi/builder/type/struct.rb +0 -34
  144. data/lib/gir_ffi/builder/type/unintrospectable.rb +0 -39
  145. data/lib/gir_ffi/builder/type/union.rb +0 -34
  146. data/lib/gir_ffi/builder/type/user_defined.rb +0 -107
  147. data/lib/gir_ffi/builder/type/with_layout.rb +0 -62
  148. data/lib/gir_ffi/builder/type/with_methods.rb +0 -64
  149. data/lib/gir_ffi/callback.rb +0 -72
  150. data/lib/gir_ffi/callback_helper.rb +0 -11
  151. data/lib/gir_ffi/error_argument_builder.rb +0 -17
  152. data/lib/gir_ffi/function_builder.rb +0 -112
  153. data/lib/gir_ffi/info_ext/i_enum_info.rb +0 -11
  154. data/lib/gir_ffi/info_ext/i_object_info.rb +0 -11
  155. data/lib/gir_ffi/info_ext/i_struct_info.rb +0 -11
  156. data/lib/gir_ffi/info_ext/i_union_info.rb +0 -12
  157. data/lib/gir_ffi/return_value_builder.rb +0 -81
  158. data/test/ffi-gobject/ruby_style_test.rb +0 -38
  159. data/test/gir_ffi/base_argument_builder_test.rb +0 -13
  160. data/test/gir_ffi/builder/type/callback_test.rb +0 -6
  161. data/test/gir_ffi/builder/type/constant_test.rb +0 -4
  162. data/test/gir_ffi/builder/type/union_test.rb +0 -12
  163. data/test/gir_ffi/callback_helper_test.rb +0 -10
  164. data/test/gir_ffi/callback_test.rb +0 -49
  165. data/test/gir_ffi/info_ext/i_arg_info_test.rb +0 -39
  166. data/test/gir_ffi/info_ext/i_object_info_test.rb +0 -14
@@ -1,62 +0,0 @@
1
- require 'gir_ffi/builder/type/base'
2
- require 'gir_ffi/class_base'
3
-
4
- module GirFFI
5
- module Builder
6
- module Type
7
-
8
- # Base class for type builders building types specified by subtypes
9
- # of IRegisteredTypeInfo. These are types whose C representation is
10
- # complex, i.e., a struct or a union.
11
- class RegisteredType < Base
12
- private
13
-
14
- def setup_constants
15
- @klass.const_set :GIR_INFO, info
16
- @klass.const_set :GIR_FFI_BUILDER, self
17
- end
18
-
19
- def already_set_up
20
- const_defined_for @klass, :GIR_FFI_BUILDER
21
- end
22
-
23
- def target_gtype
24
- info.g_type
25
- end
26
-
27
- # TODO: Rename the created method, or use a constant.
28
- # FIXME: Only used in some of the subclases. Make mixin?
29
- def setup_gtype_getter
30
- gtype = target_gtype
31
- return if gtype.nil?
32
- @klass.instance_eval "
33
- def self.get_gtype
34
- #{gtype}
35
- end
36
- "
37
- end
38
-
39
- # FIXME: Only used in some of the subclases. Make mixin?
40
- def provide_constructor
41
- return if info.find_method 'new'
42
-
43
- (class << @klass; self; end).class_eval {
44
- alias_method :new, :_allocate
45
- }
46
- end
47
-
48
- def parent
49
- nil
50
- end
51
-
52
- def fields
53
- info.fields
54
- end
55
-
56
- def superclass
57
- @superclass ||= ClassBase
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,34 +0,0 @@
1
- require 'gir_ffi/builder/type/registered_type'
2
- require 'gir_ffi/builder/type/with_layout'
3
- require 'gir_ffi/builder/type/with_methods'
4
-
5
- module GirFFI
6
- module Builder
7
- module Type
8
-
9
- # Implements the creation of a class representing a Struct.
10
- class Struct < RegisteredType
11
- include WithMethods
12
- include WithLayout
13
-
14
- private
15
-
16
- def setup_class
17
- setup_layout
18
- setup_constants
19
- stub_methods
20
- setup_gtype_getter
21
- setup_field_accessors
22
- provide_constructor
23
- end
24
-
25
- # FIXME: Private method only in subclass
26
- def layout_superclass
27
- FFI::Struct
28
- end
29
- end
30
- end
31
- end
32
- end
33
-
34
-
@@ -1,39 +0,0 @@
1
- require 'gir_ffi/builder/type/object'
2
-
3
- module GirFFI
4
- module Builder
5
- module Type
6
-
7
- # Implements the creation of a class representing an object type for
8
- # which no data is found in the GIR. Typically, these are created to
9
- # cast objects returned by a function that returns an interface.
10
- class Unintrospectable < Object
11
- def instantiate_class
12
- gtype = target_gtype
13
- CACHE[gtype] ||= Class.new(superclass)
14
- @klass = CACHE[gtype]
15
- @structklass = get_or_define_class @klass, :Struct, layout_superclass
16
- setup_class unless already_set_up
17
- end
18
-
19
- def setup_class
20
- setup_constants
21
- setup_layout
22
- setup_interfaces
23
- setup_gtype_getter
24
- end
25
-
26
- def setup_instance_method method
27
- false
28
- end
29
-
30
- private
31
-
32
- def signal_definers
33
- info.interfaces
34
- end
35
- end
36
- end
37
- end
38
- end
39
-
@@ -1,34 +0,0 @@
1
- require 'gir_ffi/builder/type/registered_type'
2
- require 'gir_ffi/builder/type/with_layout'
3
- require 'gir_ffi/builder/type/with_methods'
4
-
5
- module GirFFI
6
- module Builder
7
- module Type
8
-
9
- # Implements the creation of a class representing union type. The
10
- # class will have a nested FFI::Union class to represent its C union.
11
- class Union < RegisteredType
12
- include WithMethods
13
- include WithLayout
14
-
15
- private
16
-
17
- def setup_class
18
- setup_layout
19
- setup_constants
20
- stub_methods
21
- setup_gtype_getter
22
- setup_field_accessors
23
- provide_constructor
24
- end
25
-
26
- def layout_superclass
27
- FFI::Union
28
- end
29
- end
30
- end
31
- end
32
- end
33
-
34
-
@@ -1,107 +0,0 @@
1
- require 'gir_ffi/builder/type/object'
2
-
3
- module GirFFI
4
- module Builder
5
- module Type
6
-
7
- # Implements the creation of GObject subclasses from Ruby.
8
- class UserDefined < Object
9
- def initialize info
10
- @info = info
11
- end
12
-
13
- def instantiate_class
14
- @klass = @info.described_class
15
-
16
- parent_type = @klass.get_gtype
17
- @parent = gir.find_by_gtype(parent_type)
18
-
19
- query_result = GObject.type_query parent_type
20
- type_info = GObject::TypeInfo.new
21
- type_info.class_size = query_result.class_size
22
- type_info.instance_size = query_result.instance_size
23
- properties.each do
24
- type_info.instance_size += FFI.type_size(:int32)
25
- end
26
-
27
- @gtype = GObject.type_register_static(parent_type, @klass.name,
28
- type_info, 0)
29
-
30
- @structklass = get_or_define_class @klass, :Struct, layout_superclass
31
- setup_class unless already_set_up
32
- CACHE[@gtype] = @klass
33
- end
34
-
35
- def setup_class
36
- setup_layout
37
- setup_constants
38
- #stub_methods
39
- setup_gtype_getter
40
- setup_property_accessors
41
- #setup_vfunc_invokers
42
- #setup_interfaces
43
- setup_constructor
44
- end
45
-
46
- private
47
-
48
- def target_gtype
49
- @gtype
50
- end
51
-
52
- def parent
53
- @parent
54
- end
55
-
56
- def properties
57
- info.properties
58
- end
59
-
60
- def layout_specification
61
- parent_spec = [:parent, superclass::Struct, 0]
62
- offset = superclass::Struct.size
63
- fields_spec = properties.map do |pinfo|
64
- spec = [pinfo.name.to_sym, :int32, offset]
65
- offset += FFI.type_size(:int32)
66
- spec
67
- end.flatten(1)
68
- parent_spec + fields_spec
69
- end
70
-
71
- def setup_property_accessors
72
- properties.each do |pinfo|
73
- setup_accessors_for_param_info pinfo
74
- end
75
- end
76
-
77
- def setup_accessors_for_param_info pinfo
78
- code = <<-CODE
79
- def #{pinfo.name}
80
- @struct[:#{pinfo.name}]
81
- end
82
- def #{pinfo.name}= val
83
- @struct[:#{pinfo.name}] = val
84
- end
85
- CODE
86
-
87
- @klass.class_eval code
88
- end
89
-
90
- def method_introspection_data method
91
- nil
92
- end
93
-
94
- def setup_constructor
95
- code = <<-CODE
96
- def self.new
97
- gptr = GObject::Lib.g_object_newv #{@gtype}, 0, nil
98
- self.wrap(gptr)
99
- end
100
- CODE
101
- @klass.class_eval code
102
- end
103
- end
104
- end
105
- end
106
- end
107
-
@@ -1,62 +0,0 @@
1
- require 'gir_ffi/builder/field'
2
-
3
- module GirFFI
4
- module Builder
5
- module Type
6
-
7
- # Implements the creation of classes representing types with layout,
8
- # i.e., :union, :struct, :object.
9
- # Note: This module depends on the additional inclusion of
10
- # WithMethods.
11
- module WithLayout
12
- private
13
-
14
- def setup_layout
15
- spec = layout_specification
16
- @structklass.class_eval { layout(*spec) }
17
- end
18
-
19
- def dummy_layout_specification
20
- if parent
21
- [:parent, superclass.const_get(:Struct), 0]
22
- else
23
- [:dummy, :char, 0]
24
- end
25
- end
26
-
27
- def base_layout_specification
28
- fields.map { |finfo| finfo.layout_specification }.flatten(1)
29
- end
30
-
31
- def layout_specification
32
- spec = base_layout_specification
33
- if spec.empty?
34
- dummy_layout_specification
35
- else
36
- spec
37
- end
38
- end
39
-
40
- def setup_accessors_for_field_info finfo
41
- builder = Builder::Field.new(finfo, lib, @structklass)
42
- unless has_instance_method finfo.name
43
- @klass.class_eval builder.getter_def
44
- end
45
- @klass.class_eval builder.setter_def if finfo.writable?
46
- end
47
-
48
- def setup_field_accessors
49
- fields.each do |finfo|
50
- setup_accessors_for_field_info finfo
51
- end
52
- end
53
-
54
- def instantiate_class
55
- @klass = get_or_define_class namespace_module, @classname, superclass
56
- @structklass = get_or_define_class @klass, :Struct, layout_superclass
57
- setup_class unless already_set_up
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,64 +0,0 @@
1
- require 'gir_ffi/method_stubber'
2
-
3
- module GirFFI
4
- module Builder
5
- module Type
6
-
7
- # Implements method creation for types such as, :union, :struct,
8
- # :object, :interface.
9
- module WithMethods
10
- def setup_method method
11
- go = method_introspection_data method
12
- attach_and_define_method method, go, meta_class
13
- end
14
-
15
- def setup_instance_method method
16
- go = instance_method_introspection_data method
17
- attach_and_define_method method, go, build_class
18
- end
19
-
20
- def has_instance_method method
21
- !!instance_method_introspection_data(method)
22
- end
23
-
24
- private
25
-
26
- def meta_class
27
- klass = build_class
28
- return (class << klass; self; end)
29
- end
30
-
31
- def method_introspection_data method
32
- info.find_method method
33
- end
34
-
35
- def instance_method_introspection_data method
36
- data = method_introspection_data method
37
- return data if data && data.method?
38
- end
39
-
40
- def function_definition_builder go
41
- FunctionBuilder.new(go, lib)
42
- end
43
-
44
- def function_definition go
45
- function_definition_builder(go).generate
46
- end
47
-
48
- def attach_and_define_method method, go, modul
49
- return false if go.nil?
50
- Builder.attach_ffi_function lib, go
51
- modul.class_eval { remove_method method }
52
- build_class.class_eval function_definition(go)
53
- true
54
- end
55
-
56
- def stub_methods
57
- info.get_methods.each do |minfo|
58
- @klass.class_eval MethodStubber.new(minfo).method_stub
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,72 +0,0 @@
1
- module GirFFI
2
- # Specialized kind of Proc to be used for callback arguments.
3
- # TODO: Create superclass for all actual callback types that does the wrapping for this.
4
- class Callback < Proc
5
- # Create Callback from a Proc. Makes sure arguments are properly wrapped,
6
- # and the callback is stored to prevent garbage collection.
7
- def self.from namespace, name, prc
8
- wrap_in_callback_args_mapper(namespace, name, prc).tap do |cb|
9
- CallbackHelper.store_callback cb
10
- end
11
- end
12
-
13
- # TODO: Create actual callback class from the callback info, so no lookup
14
- # is needed. This class can then also perform the argument mapping.
15
- def self.wrap_in_callback_args_mapper namespace, name, prc
16
- return prc if FFI::Function === prc
17
- return nil if prc.nil?
18
- info = GObjectIntrospection::IRepository.default.find_by_name namespace, name
19
- return self.new do |*args|
20
- prc.call(*map_callback_args(args, info))
21
- end
22
- end
23
-
24
- def self.map_callback_args args, info
25
- args.zip(info.args).map { |arg, inf|
26
- map_single_callback_arg arg, inf.argument_type }
27
- end
28
-
29
- # TODO: Use GirFFI::ReturnValue classes for mapping.
30
- def self.map_single_callback_arg arg, type
31
- case type.tag
32
- when :interface
33
- map_interface_callback_arg arg, type
34
- when :utf8
35
- ArgHelper.ptr_to_utf8 arg
36
- when :void
37
- map_void_callback_arg arg
38
- when :array
39
- subtype = type.param_type(0)
40
- if subtype.tag == :interface and arg.is_a?(FFI::Pointer)
41
- map_interface_callback_arg arg, subtype
42
- else
43
- raise NotImplementedError
44
- end
45
- else
46
- arg
47
- end
48
- end
49
-
50
- def self.map_interface_callback_arg arg, type
51
- iface = type.interface
52
- case iface.info_type
53
- when :object, :interface
54
- arg.to_object
55
- when :struct
56
- klass = GirFFI::Builder.build_class iface
57
- klass.wrap arg
58
- else
59
- arg
60
- end
61
- end
62
-
63
- def self.map_void_callback_arg arg
64
- if arg.null?
65
- nil
66
- else
67
- GirFFI::ArgHelper::OBJECT_STORE[arg.address]
68
- end
69
- end
70
-
71
- end
72
- end