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
@@ -0,0 +1,50 @@
1
+ require 'gir_ffi/builders/base_type_builder'
2
+ require 'gir_ffi/class_base'
3
+
4
+ module GirFFI
5
+ module Builders
6
+ # Base class for type builders building types specified by subtypes
7
+ # of IRegisteredTypeInfo. These are types whose C representation is
8
+ # complex, i.e., a struct or a union.
9
+ class RegisteredTypeBuilder < BaseTypeBuilder
10
+ private
11
+
12
+ def target_gtype
13
+ info.g_type
14
+ end
15
+
16
+ # TODO: Rename the created method, or use a constant.
17
+ # FIXME: Only used in some of the subclases. Make mixin?
18
+ def setup_gtype_getter
19
+ gtype = target_gtype
20
+ return if gtype.nil?
21
+ @klass.instance_eval "
22
+ def self.get_gtype
23
+ #{gtype}
24
+ end
25
+ "
26
+ end
27
+
28
+ # FIXME: Only used in some of the subclases. Make mixin?
29
+ def provide_constructor
30
+ return if info.find_method 'new'
31
+
32
+ (class << @klass; self; end).class_eval {
33
+ alias_method :new, :_allocate
34
+ }
35
+ end
36
+
37
+ def parent
38
+ nil
39
+ end
40
+
41
+ def fields
42
+ info.fields
43
+ end
44
+
45
+ def superclass
46
+ ClassBase
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,68 @@
1
+ require 'gir_ffi/builders/base_argument_builder'
2
+
3
+ module GirFFI
4
+ module Builders
5
+ # Implements building post-processing statements for return values.
6
+ class ReturnValueBuilder < BaseArgumentBuilder
7
+ def initialize var_gen, type_info, is_constructor = false, skip = false
8
+ super var_gen, nil, type_info, :return
9
+ @is_constructor = is_constructor
10
+ @skip = skip
11
+ end
12
+
13
+ def post
14
+ if has_conversion?
15
+ [ "#{retname} = #{post_conversion}" ]
16
+ else
17
+ []
18
+ end
19
+ end
20
+
21
+ def inarg
22
+ nil
23
+ end
24
+
25
+ def retval
26
+ if has_conversion?
27
+ super
28
+ elsif is_relevant?
29
+ callarg
30
+ else
31
+ nil
32
+ end
33
+ end
34
+
35
+ def is_relevant?
36
+ !is_void_return_value? && !@skip
37
+ end
38
+
39
+ private
40
+
41
+ def has_conversion?
42
+ is_closure || needs_outgoing_parameter_conversion? || needs_constructor_wrap?
43
+ end
44
+
45
+ def post_conversion
46
+ if is_closure
47
+ "GirFFI::ArgHelper::OBJECT_STORE[#{callarg}.address]"
48
+ elsif needs_constructor_wrap?
49
+ "self.constructor_wrap(#{callarg})"
50
+ else
51
+ outgoing_conversion callarg
52
+ end
53
+ end
54
+
55
+ def retname
56
+ @retname ||= @var_gen.new_var
57
+ end
58
+
59
+ def needs_constructor_wrap?
60
+ @is_constructor && [ :interface, :object ].include?(specialized_type_tag)
61
+ end
62
+
63
+ def is_void_return_value?
64
+ specialized_type_tag == :void && !type_info.pointer?
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,91 @@
1
+ require 'gir_ffi/builders/base_type_builder'
2
+ require 'gir_ffi/builders/mapping_method_builder'
3
+ require 'gir_ffi/signal_base'
4
+
5
+ module GirFFI
6
+ module Builders
7
+ # Implements the creation of a signal module for handling a particular
8
+ # signal. The type will be attached to the appropriate class.
9
+ class SignalBuilder < BaseTypeBuilder
10
+ class SignalReceiverTypeInfo
11
+ include InfoExt::ITypeInfo
12
+
13
+ def initialize interface_info
14
+ @interface_info = interface_info
15
+ end
16
+
17
+ def interface
18
+ @interface_info
19
+ end
20
+
21
+ def tag
22
+ :interface
23
+ end
24
+ end
25
+
26
+ class SignalReceiverArgumentInfo
27
+ attr_reader :argument_type
28
+
29
+ def initialize type
30
+ @argument_type = type
31
+ end
32
+
33
+ def closure
34
+ -1
35
+ end
36
+ end
37
+
38
+ class UserDataTypeInfo
39
+ include InfoExt::ITypeInfo
40
+
41
+ def tag
42
+ :void
43
+ end
44
+
45
+ def pointer?
46
+ true
47
+ end
48
+ end
49
+
50
+ class UserDataArgumentInfo
51
+ attr_reader :argument_type
52
+ attr_reader :closure
53
+ def initialize type, position
54
+ @argument_type = type
55
+ @closure = position
56
+ end
57
+ end
58
+
59
+ def instantiate_class
60
+ @klass ||= get_or_define_module container_class, @classname
61
+ unless already_set_up
62
+ @klass.extend SignalBase
63
+ setup_constants
64
+ @klass.class_eval mapping_method_definition
65
+ end
66
+ @klass
67
+ end
68
+
69
+ def mapping_method_definition
70
+ arg_infos = info.args
71
+
72
+ container_type_info = SignalReceiverTypeInfo.new(container_info)
73
+ arg_infos.unshift SignalReceiverArgumentInfo.new(container_type_info)
74
+
75
+ user_data_type_info = UserDataTypeInfo.new
76
+ user_data_argument_info = UserDataArgumentInfo.new(user_data_type_info, arg_infos.length)
77
+ arg_infos.push user_data_argument_info
78
+
79
+ MappingMethodBuilder.new(arg_infos, info.return_type).method_definition
80
+ end
81
+
82
+ def container_class
83
+ @container_class ||= Builder.build_class(container_info)
84
+ end
85
+
86
+ def container_info
87
+ @container_info ||= info.container
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,35 @@
1
+ require 'gir_ffi/builders/registered_type_builder'
2
+ require 'gir_ffi/builders/with_layout'
3
+ require 'gir_ffi/builders/with_methods'
4
+ require 'gir_ffi/struct_base'
5
+
6
+ module GirFFI
7
+ module Builders
8
+ # Implements the creation of a class representing a Struct.
9
+ class StructBuilder < RegisteredTypeBuilder
10
+ include WithMethods
11
+ include WithLayout
12
+
13
+ private
14
+
15
+ def setup_class
16
+ setup_layout
17
+ setup_constants
18
+ stub_methods
19
+ setup_gtype_getter
20
+ setup_field_accessors
21
+ provide_constructor
22
+ end
23
+
24
+ # FIXME: Private method only in subclass
25
+ def layout_superclass
26
+ # FIXME: Is this needed now that StructBase is a DataConverter?
27
+ GirFFI::Struct
28
+ end
29
+
30
+ def superclass
31
+ StructBase
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ require 'gir_ffi/builders/callback_builder'
2
+ require 'gir_ffi/builders/constant_builder'
3
+ require 'gir_ffi/builders/enum_builder'
4
+ require 'gir_ffi/builders/interface_builder'
5
+ require 'gir_ffi/builders/object_builder'
6
+ require 'gir_ffi/builders/struct_builder'
7
+ require 'gir_ffi/builders/signal_builder'
8
+ require 'gir_ffi/builders/unintrospectable_builder'
9
+ require 'gir_ffi/builders/union_builder'
10
+
11
+ module GirFFI
12
+ module Builders
13
+ # Builds a class based on information found in the introspection
14
+ # repository.
15
+ module TypeBuilder
16
+ CACHE = {}
17
+
18
+ TYPE_MAP = {
19
+ :callback => CallbackBuilder,
20
+ :constant => ConstantBuilder,
21
+ :enum => EnumBuilder,
22
+ :flags => EnumBuilder,
23
+ :interface => InterfaceBuilder,
24
+ :object => ObjectBuilder,
25
+ :struct => StructBuilder,
26
+ :union => UnionBuilder,
27
+ :unintrospectable => UnintrospectableBuilder
28
+ }
29
+
30
+ def self.build info
31
+ TYPE_MAP[info.info_type].new(info).build_class
32
+ end
33
+
34
+ # TODO: Pull up to include :function and :module
35
+ def self.builder_for info
36
+ TYPE_MAP[info.info_type].new(info)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ require 'gir_ffi/builders/object_builder'
2
+
3
+ module GirFFI
4
+ module Builders
5
+ # Implements the creation of a class representing an object type for
6
+ # which no data is found in the GIR. Typically, these are created to
7
+ # cast objects returned by a function that returns an interface.
8
+ class UnintrospectableBuilder < ObjectBuilder
9
+ def instantiate_class
10
+ gtype = target_gtype
11
+ TypeBuilder::CACHE[gtype] ||= Class.new(superclass)
12
+ @klass = TypeBuilder::CACHE[gtype]
13
+ @structklass = get_or_define_class @klass, :Struct, layout_superclass
14
+ setup_class unless already_set_up
15
+ end
16
+
17
+ def setup_class
18
+ setup_constants
19
+ setup_layout
20
+ setup_interfaces
21
+ setup_gtype_getter
22
+ end
23
+
24
+ def setup_instance_method method
25
+ false
26
+ end
27
+
28
+ private
29
+
30
+ def signal_definers
31
+ info.interfaces
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ require 'gir_ffi/builders/registered_type_builder'
2
+ require 'gir_ffi/builders/with_layout'
3
+ require 'gir_ffi/builders/with_methods'
4
+ require 'gir_ffi/union_base'
5
+
6
+ module GirFFI
7
+ module Builders
8
+ # Implements the creation of a class representing union type. The
9
+ # class will have a nested FFI::Union class to represent its C union.
10
+ class UnionBuilder < RegisteredTypeBuilder
11
+ include WithMethods
12
+ include WithLayout
13
+
14
+ def layout_superclass
15
+ FFI::Union
16
+ end
17
+
18
+ private
19
+
20
+ def setup_class
21
+ setup_layout
22
+ setup_constants
23
+ stub_methods
24
+ setup_gtype_getter
25
+ setup_field_accessors
26
+ provide_constructor
27
+ end
28
+
29
+ def superclass
30
+ UnionBase
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,103 @@
1
+ require 'gir_ffi/builders/object_builder'
2
+
3
+ module GirFFI
4
+ module Builders
5
+ # Implements the creation of GObject subclasses from Ruby.
6
+ class UserDefinedBuilder < ObjectBuilder
7
+ def initialize info
8
+ @info = info
9
+ end
10
+
11
+ def instantiate_class
12
+ @klass = @info.described_class
13
+
14
+ parent_type = @klass.get_gtype
15
+ @parent = gir.find_by_gtype(parent_type)
16
+
17
+ query_result = GObject.type_query parent_type
18
+ type_info = GObject::TypeInfo.new
19
+ type_info.class_size = query_result.class_size
20
+ type_info.instance_size = query_result.instance_size
21
+ properties.each do
22
+ type_info.instance_size += FFI.type_size(:int32)
23
+ end
24
+
25
+ @gtype = GObject.type_register_static(parent_type, @klass.name,
26
+ type_info, 0)
27
+
28
+ @structklass = get_or_define_class @klass, :Struct, layout_superclass
29
+ setup_class unless already_set_up
30
+ TypeBuilder::CACHE[@gtype] = @klass
31
+ end
32
+
33
+ def setup_class
34
+ setup_layout
35
+ setup_constants
36
+ #stub_methods
37
+ setup_gtype_getter
38
+ setup_property_accessors
39
+ #setup_vfunc_invokers
40
+ #setup_interfaces
41
+ setup_constructor
42
+ end
43
+
44
+ private
45
+
46
+ def target_gtype
47
+ @gtype
48
+ end
49
+
50
+ def parent
51
+ @parent
52
+ end
53
+
54
+ def properties
55
+ info.properties
56
+ end
57
+
58
+ def layout_specification
59
+ parent_spec = [:parent, superclass::Struct, 0]
60
+ offset = superclass::Struct.size
61
+ fields_spec = properties.map do |pinfo|
62
+ spec = [pinfo.name.to_sym, :int32, offset]
63
+ offset += FFI.type_size(:int32)
64
+ spec
65
+ end.flatten(1)
66
+ parent_spec + fields_spec
67
+ end
68
+
69
+ def setup_property_accessors
70
+ properties.each do |pinfo|
71
+ setup_accessors_for_param_info pinfo
72
+ end
73
+ end
74
+
75
+ def setup_accessors_for_param_info pinfo
76
+ code = <<-CODE
77
+ def #{pinfo.name}
78
+ @struct[:#{pinfo.name}]
79
+ end
80
+ def #{pinfo.name}= val
81
+ @struct[:#{pinfo.name}] = val
82
+ end
83
+ CODE
84
+
85
+ @klass.class_eval code
86
+ end
87
+
88
+ def method_introspection_data method
89
+ nil
90
+ end
91
+
92
+ def setup_constructor
93
+ code = <<-CODE
94
+ def self.new
95
+ gptr = GObject::Lib.g_object_newv #{@gtype}, 0, nil
96
+ self.wrap(gptr)
97
+ end
98
+ CODE
99
+ @klass.class_eval code
100
+ end
101
+ end
102
+ end
103
+ end