gir_ffi 0.6.7 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/{History.txt → Changelog.md} +93 -61
  3. data/{DESIGN.rdoc → DESIGN.md} +7 -7
  4. data/README.md +5 -7
  5. data/TODO.md +90 -0
  6. data/lib/ffi-glib.rb +0 -1
  7. data/lib/ffi-glib/array.rb +13 -29
  8. data/lib/ffi-glib/array_methods.rb +13 -0
  9. data/lib/ffi-glib/container_class_methods.rb +6 -1
  10. data/lib/ffi-glib/hash_table.rb +3 -2
  11. data/lib/ffi-glib/list.rb +3 -17
  12. data/lib/ffi-glib/list_methods.rb +22 -3
  13. data/lib/ffi-glib/ptr_array.rb +19 -19
  14. data/lib/ffi-glib/s_list.rb +3 -17
  15. data/lib/ffi-gobject.rb +10 -17
  16. data/lib/ffi-gobject/object.rb +19 -9
  17. data/lib/ffi-gobject/object_class.rb +14 -0
  18. data/lib/ffi-gobject/ruby_closure.rb +4 -5
  19. data/lib/ffi-gobject/value.rb +7 -5
  20. data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
  21. data/lib/gir_ffi-base.rb +0 -2
  22. data/lib/gir_ffi-base/gobject.rb +1 -0
  23. data/lib/gir_ffi-base/gobject/lib.rb +1 -1
  24. data/lib/gir_ffi.rb +2 -0
  25. data/lib/gir_ffi/arg_helper.rb +18 -8
  26. data/lib/gir_ffi/builders/argument_builder.rb +62 -55
  27. data/lib/gir_ffi/builders/base_argument_builder.rb +52 -106
  28. data/lib/gir_ffi/builders/base_type_builder.rb +3 -3
  29. data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +34 -0
  30. data/lib/gir_ffi/builders/callback_argument_builder.rb +73 -0
  31. data/lib/gir_ffi/builders/callback_builder.rb +19 -9
  32. data/lib/gir_ffi/builders/callback_return_value_builder.rb +54 -0
  33. data/lib/gir_ffi/builders/closure_convertor.rb +9 -0
  34. data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +9 -0
  35. data/lib/gir_ffi/builders/constructor_result_convertor.rb +9 -0
  36. data/lib/gir_ffi/builders/enum_builder.rb +16 -16
  37. data/lib/gir_ffi/builders/field_builder.rb +36 -15
  38. data/lib/gir_ffi/builders/function_builder.rb +32 -27
  39. data/lib/gir_ffi/builders/interface_builder.rb +14 -4
  40. data/lib/gir_ffi/builders/mapping_method_builder.rb +95 -43
  41. data/lib/gir_ffi/builders/module_builder.rb +22 -35
  42. data/lib/gir_ffi/builders/null_convertor.rb +9 -0
  43. data/lib/gir_ffi/builders/object_builder.rb +11 -14
  44. data/lib/gir_ffi/builders/property_builder.rb +107 -9
  45. data/lib/gir_ffi/builders/registered_type_builder.rb +2 -2
  46. data/lib/gir_ffi/builders/return_value_builder.rb +42 -33
  47. data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +15 -0
  48. data/lib/gir_ffi/builders/signal_builder.rb +18 -58
  49. data/lib/gir_ffi/builders/struct_builder.rb +1 -2
  50. data/lib/gir_ffi/builders/type_builder.rb +1 -0
  51. data/lib/gir_ffi/builders/unintrospectable_builder.rb +4 -4
  52. data/lib/gir_ffi/builders/user_defined_builder.rb +151 -26
  53. data/lib/gir_ffi/builders/vfunc_builder.rb +57 -0
  54. data/lib/gir_ffi/builders/with_layout.rb +10 -8
  55. data/lib/gir_ffi/builders/with_methods.rb +1 -1
  56. data/lib/gir_ffi/callback_base.rb +42 -8
  57. data/lib/gir_ffi/class_base.rb +1 -2
  58. data/lib/gir_ffi/enum_base.rb +26 -4
  59. data/lib/gir_ffi/error_argument_info.rb +21 -0
  60. data/lib/gir_ffi/{setter_argument_info.rb → field_argument_info.rb} +2 -1
  61. data/lib/gir_ffi/g_type.rb +25 -0
  62. data/lib/gir_ffi/in_out_pointer.rb +3 -14
  63. data/lib/gir_ffi/in_pointer.rb +20 -21
  64. data/lib/gir_ffi/info_ext.rb +2 -0
  65. data/lib/gir_ffi/info_ext/i_callable_info.rb +0 -9
  66. data/lib/gir_ffi/info_ext/i_callback_info.rb +17 -0
  67. data/lib/gir_ffi/info_ext/i_function_info.rb +4 -0
  68. data/lib/gir_ffi/info_ext/i_property_info.rb +4 -0
  69. data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -0
  70. data/lib/gir_ffi/info_ext/i_signal_info.rb +14 -16
  71. data/lib/gir_ffi/info_ext/i_type_info.rb +72 -34
  72. data/lib/gir_ffi/info_ext/i_vfunc_info.rb +12 -0
  73. data/lib/gir_ffi/info_ext/safe_constant_name.rb +3 -2
  74. data/lib/gir_ffi/interface_base.rb +8 -3
  75. data/lib/gir_ffi/module_base.rb +3 -5
  76. data/lib/gir_ffi/object_base.rb +8 -0
  77. data/lib/gir_ffi/receiver_argument_info.rb +21 -0
  78. data/lib/gir_ffi/receiver_type_info.rb +27 -0
  79. data/lib/gir_ffi/return_value_info.rb +23 -0
  80. data/lib/gir_ffi/signal_base.rb +1 -1
  81. data/lib/{ffi-glib → gir_ffi}/sized_array.rb +10 -6
  82. data/lib/gir_ffi/struct_base.rb +10 -9
  83. data/lib/gir_ffi/type_base.rb +1 -0
  84. data/lib/gir_ffi/type_map.rb +3 -0
  85. data/lib/gir_ffi/unintrospectable_type_info.rb +4 -1
  86. data/lib/gir_ffi/union_base.rb +4 -21
  87. data/lib/gir_ffi/user_data_argument_info.rb +21 -0
  88. data/lib/gir_ffi/user_data_type_info.rb +17 -0
  89. data/lib/gir_ffi/user_defined_type_info.rb +18 -4
  90. data/lib/gir_ffi/version.rb +1 -1
  91. data/lib/gir_ffi/vfunc_base.rb +8 -0
  92. data/lib/gir_ffi/vfunc_implementation.rb +11 -0
  93. data/lib/gir_ffi/zero_terminated.rb +18 -24
  94. data/test/base_test_helper.rb +2 -3
  95. data/test/ffi-glib/array_test.rb +3 -3
  96. data/test/ffi-glib/ruby_closure_test.rb +3 -3
  97. data/test/ffi-gobject/value_test.rb +15 -1
  98. data/test/ffi-gobject_test.rb +2 -1
  99. data/test/gir_ffi/arg_helper_test.rb +21 -2
  100. data/test/gir_ffi/builders/argument_builder_test.rb +213 -287
  101. data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
  102. data/test/gir_ffi/builders/callback_builder_test.rb +26 -8
  103. data/test/gir_ffi/builders/field_builder_test.rb +18 -3
  104. data/test/gir_ffi/builders/function_builder_test.rb +30 -12
  105. data/test/gir_ffi/builders/interface_builder_test.rb +9 -0
  106. data/test/gir_ffi/builders/module_builder_test.rb +0 -39
  107. data/test/gir_ffi/builders/object_builder_test.rb +27 -27
  108. data/test/gir_ffi/builders/property_builder_test.rb +110 -0
  109. data/test/gir_ffi/builders/return_value_builder_test.rb +168 -200
  110. data/test/gir_ffi/builders/signal_builder_test.rb +58 -14
  111. data/test/gir_ffi/builders/struct_builder_test.rb +2 -41
  112. data/test/gir_ffi/builders/user_defined_builder_test.rb +88 -20
  113. data/test/gir_ffi/builders/vfunc_builder_test.rb +44 -0
  114. data/test/gir_ffi/g_type_test.rb +29 -0
  115. data/test/gir_ffi/in_pointer_test.rb +28 -9
  116. data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -9
  117. data/test/gir_ffi/info_ext/i_callback_info_test.rb +19 -0
  118. data/test/gir_ffi/info_ext/i_function_info_test.rb +9 -0
  119. data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -11
  120. data/test/gir_ffi/info_ext/i_type_info_test.rb +140 -16
  121. data/test/gir_ffi/interface_base_test.rb +9 -3
  122. data/test/gir_ffi/object_base_test.rb +1 -2
  123. data/test/{ffi-glib → gir_ffi}/sized_array_test.rb +28 -28
  124. data/test/gir_ffi/type_map_test.rb +1 -1
  125. data/test/gir_ffi/user_defined_type_info_test.rb +36 -4
  126. data/test/gir_ffi_test.rb +5 -5
  127. data/test/gir_ffi_test_helper.rb +4 -0
  128. data/test/integration/generated_gimarshallingtests_test.rb +163 -59
  129. data/test/integration/generated_gobject_test.rb +21 -8
  130. data/test/integration/generated_pango_test.rb +2 -2
  131. data/test/integration/generated_regress_test.rb +361 -101
  132. data/test/lib/autogen.sh +5 -1
  133. metadata +51 -35
  134. data/TODO.rdoc +0 -63
  135. data/lib/gir_ffi-base/gir_ffi/library.rb +0 -17
  136. data/lib/gir_ffi-base/gir_ffi/struct.rb +0 -27
@@ -9,7 +9,6 @@ require 'ffi-glib/hash_table'
9
9
  require 'ffi-glib/list'
10
10
  require 'ffi-glib/ptr_array'
11
11
  require 'ffi-glib/s_list'
12
- require 'ffi-glib/sized_array'
13
12
  require 'ffi-glib/strv'
14
13
  require 'ffi-glib/variant'
15
14
 
@@ -1,3 +1,6 @@
1
+ require 'ffi-glib/container_class_methods'
2
+ require 'ffi-glib/array_methods'
3
+
1
4
  module GLib
2
5
  load_class :Array
3
6
 
@@ -5,12 +8,10 @@ module GLib
5
8
  # be necessary to create objects of this class from Ruby directly.
6
9
  class Array
7
10
  include Enumerable
11
+ include ArrayMethods
12
+ extend ContainerClassMethods
8
13
 
9
14
  attr_reader :element_type
10
- def element_type= val
11
- @element_type = val
12
- check_element_size_match
13
- end
14
15
 
15
16
  class << self
16
17
  undef :new
@@ -26,15 +27,6 @@ module GLib
26
27
  self
27
28
  end
28
29
 
29
- # Re-implementation of the g_array_index macro
30
- def index idx
31
- if idx >= length or idx < 0
32
- raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
33
- end
34
- ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * get_element_size
35
- ptr.to_ruby_value
36
- end
37
-
38
30
  def each
39
31
  length.times do |idx|
40
32
  yield index(idx)
@@ -49,32 +41,24 @@ module GLib
49
41
  @struct[:data]
50
42
  end
51
43
 
52
- undef :data
53
-
54
- # @deprecated From 0.7.0, data will return the actual data as a string,
55
- # as generated by GirFFI.
56
- alias data data_ptr
57
-
58
44
  def get_element_size
59
45
  Lib.g_array_get_element_size self
60
46
  end
61
47
 
48
+ alias element_size get_element_size
49
+
62
50
  def ==(other)
63
51
  self.to_a == other.to_a
64
52
  end
65
53
 
66
- def self.wrap elmttype, ptr
67
- super(ptr).tap do |array|
68
- array.element_type = elmttype if array
69
- end
54
+ def reset_typespec typespec
55
+ @element_type = typespec
56
+ check_element_size_match
57
+ self
70
58
  end
71
59
 
72
- def self.from elmtype, it
73
- case it
74
- when self then it
75
- when FFI::Pointer then wrap elmtype, it
76
- else self.new(elmtype).tap {|arr| arr.append_vals it }
77
- end
60
+ def self.from_enumerable elmtype, it
61
+ self.new(elmtype).tap {|arr| arr.append_vals it }
78
62
  end
79
63
 
80
64
  private
@@ -0,0 +1,13 @@
1
+ module GLib
2
+ # Common methods for GLib::Array and GLib::PtrArray
3
+ module ArrayMethods
4
+ # Re-implementation of the g_array_index and g_ptr_array_index macros
5
+ def index idx
6
+ if idx >= length or idx < 0
7
+ raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
8
+ end
9
+ ptr = GirFFI::InOutPointer.new element_type, data_ptr + idx * element_size
10
+ ptr.to_ruby_value
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,6 @@
1
1
  module GLib
2
+ # Common methods for container classes: Array, PtrArray, List, SList and
3
+ # HashTable.
2
4
  module ContainerClassMethods
3
5
  def wrap typespec, ptr
4
6
  super(ptr).tap do |container|
@@ -6,7 +8,10 @@ module GLib
6
8
  end
7
9
  end
8
10
 
9
- def from typespec, it
11
+ # FIXME: Drop Ruby 1.8.7 support and make first argument optional.
12
+ def from *args
13
+ it, typespec = *args.reverse
14
+ typespec ||= :void
10
15
  case it
11
16
  when nil
12
17
  nil
@@ -12,12 +12,13 @@ module GLib
12
12
  attr_reader :value_type
13
13
 
14
14
  def each
15
- prc = Proc.new {|keyptr, valptr, userdata|
15
+ prc = proc {|keyptr, valptr, userdata|
16
16
  key = GirFFI::ArgHelper.cast_from_pointer key_type, keyptr
17
17
  val = GirFFI::ArgHelper.cast_from_pointer value_type, valptr
18
18
  yield key, val
19
19
  }
20
- ::GLib::Lib.g_hash_table_foreach self.to_ptr, prc, nil
20
+ callback = GLib::HFunc.from prc
21
+ ::GLib::Lib.g_hash_table_foreach self.to_ptr, callback, nil
21
22
  end
22
23
 
23
24
  def to_hash
@@ -7,27 +7,13 @@ module GLib
7
7
  class List
8
8
  include ListMethods
9
9
 
10
- class << self
11
- remove_method :new
12
- end
13
-
14
- def self.new type
15
- _real_new.tap do |it|
16
- struct = self::Struct.new(FFI::Pointer.new(0))
17
- it.instance_variable_set :@struct, struct
18
- it.element_type = type
19
- end
20
- end
21
-
22
10
  def self.from_enumerable type, arr
23
- arr.inject(self.new type) { |lst, val|
24
- lst.append val }
11
+ arr.inject(self.new type) { |lst, val| lst.append val }
25
12
  end
26
13
 
27
14
  def append data
28
- elm_t = element_type
29
- data_ptr = GirFFI::InPointer.from(elm_t, data)
30
- self.class.wrap(elm_t, Lib.g_list_append(self, data_ptr))
15
+ self.class.wrap(element_type,
16
+ Lib.g_list_append(self, element_ptr_for(data)))
31
17
  end
32
18
  end
33
19
  end
@@ -1,15 +1,20 @@
1
1
  require 'ffi-glib/container_class_methods'
2
2
 
3
3
  module GLib
4
+ # Common methods for List and SList.
4
5
  module ListMethods
5
6
  include Enumerable
6
- attr_accessor :element_type
7
+ attr_reader :element_type
7
8
 
8
9
  def self.included base
9
- base.extend ContainerClassMethods
10
10
  # Override default field accessors.
11
11
  replace_method base, :next, :tail
12
12
  replace_method base, :data, :head
13
+
14
+ class << base; self end.send :remove_method, :new
15
+ base.extend ListClassMethods
16
+
17
+ base.extend ContainerClassMethods
13
18
  end
14
19
 
15
20
  def self.replace_method base, old, new
@@ -35,7 +40,7 @@ module GLib
35
40
  end
36
41
 
37
42
  def reset_typespec typespec
38
- self.element_type = typespec
43
+ @element_type = typespec
39
44
  self
40
45
  end
41
46
 
@@ -55,6 +60,20 @@ module GLib
55
60
  @current = @current.tail
56
61
  element
57
62
  end
63
+
64
+ def element_ptr_for data
65
+ GirFFI::InPointer.from(element_type, data)
66
+ end
67
+
68
+ module ListClassMethods
69
+ def new type
70
+ _real_new.tap do |it|
71
+ struct = self::Struct.new(FFI::Pointer.new(0))
72
+ it.instance_variable_set :@struct, struct
73
+ it.instance_variable_set :@element_type, type
74
+ end
75
+ end
76
+ end
58
77
  end
59
78
  end
60
79
 
@@ -1,3 +1,6 @@
1
+ require 'ffi-glib/container_class_methods'
2
+ require 'ffi-glib/array_methods'
3
+
1
4
  module GLib
2
5
  load_class :PtrArray
3
6
 
@@ -5,8 +8,10 @@ module GLib
5
8
  # pointers.
6
9
  class PtrArray
7
10
  include Enumerable
11
+ include ArrayMethods
12
+ extend ContainerClassMethods
8
13
 
9
- attr_accessor :element_type
14
+ attr_reader :element_type
10
15
 
11
16
  POINTER_SIZE = FFI.type_size(:pointer)
12
17
 
@@ -20,23 +25,19 @@ module GLib
20
25
  wrap(type, Lib.g_ptr_array_new)
21
26
  end
22
27
 
23
- def self.wrap type, ptr
24
- super(ptr).tap {|it|
25
- it.element_type = type}
26
- end
27
-
28
- def self.from type, it
29
- case it
30
- when self then it
31
- when FFI::Pointer then wrap type, it
32
- else self.new(type).tap {|arr| arr.add_array it}
33
- end
28
+ def self.from_enumerable(type, it)
29
+ self.new(type).tap {|arr| arr.add_array it}
34
30
  end
35
31
 
36
32
  def self.add array, data
37
33
  array.add data
38
34
  end
39
35
 
36
+ def reset_typespec typespec
37
+ @element_type = typespec
38
+ self
39
+ end
40
+
40
41
  def add data
41
42
  ptr = GirFFI::InPointer.from element_type, data
42
43
  Lib.g_ptr_array_add self, ptr
@@ -46,13 +47,12 @@ module GLib
46
47
  ary.each {|item| add item}
47
48
  end
48
49
 
49
- # Re-implementation of the g_ptr_array_index macro
50
- def index idx
51
- if idx >= length or idx < 0
52
- raise IndexError, "Index #{idx} outside of bounds 0..#{length - 1}"
53
- end
54
- ptr = GirFFI::InOutPointer.new element_type, @struct[:pdata] + idx * POINTER_SIZE
55
- ptr.to_ruby_value
50
+ def data_ptr
51
+ @struct[:pdata]
52
+ end
53
+
54
+ def element_size
55
+ POINTER_SIZE
56
56
  end
57
57
 
58
58
  def each
@@ -7,27 +7,13 @@ module GLib
7
7
  class SList
8
8
  include ListMethods
9
9
 
10
- class << self
11
- remove_method :new
12
- end
13
-
14
- def self.new type
15
- _real_new.tap do |it|
16
- struct = self::Struct.new(FFI::Pointer.new(0))
17
- it.instance_variable_set :@struct, struct
18
- it.element_type = type
19
- end
20
- end
21
-
22
10
  def self.from_enumerable type, arr
23
- arr.reverse.inject(self.new type) { |lst, val|
24
- lst.prepend val }
11
+ arr.reverse.inject(self.new type) { |lst, val| lst.prepend val }
25
12
  end
26
13
 
27
14
  def prepend data
28
- elm_t = element_type
29
- data_ptr = GirFFI::InPointer.from(elm_t, data)
30
- self.class.wrap(elm_t, Lib.g_slist_prepend(self, data_ptr))
15
+ self.class.wrap(element_type,
16
+ Lib.g_slist_prepend(self, element_ptr_for(data)))
31
17
  end
32
18
  end
33
19
  end
@@ -9,9 +9,11 @@ require 'ffi-gobject/value'
9
9
  require 'ffi-gobject/initially_unowned'
10
10
  require 'ffi-gobject/closure'
11
11
  require 'ffi-gobject/object'
12
+ require 'ffi-gobject/object_class'
12
13
  require 'ffi-gobject/ruby_closure'
13
14
  require 'gir_ffi/builders/user_defined_builder'
14
15
 
16
+ # Module representing GLib's GObject namespace.
15
17
  module GObject
16
18
  def self.object_ref obj
17
19
  Lib::g_object_ref obj.to_ptr
@@ -32,6 +34,7 @@ module GObject
32
34
  def self.type_from_instance_pointer inst_ptr
33
35
  return nil if inst_ptr.null?
34
36
  klsptr = inst_ptr.get_pointer 0
37
+ # TODO: Cache the message name somewhere.
35
38
  klsptr.send "get_#{GirFFI::TypeMap::TAG_TYPE_MAP[:GType]}", 0
36
39
  end
37
40
 
@@ -60,10 +63,12 @@ module GObject
60
63
  signal_id = signal_lookup_from_instance signal, object
61
64
  detail_quark = GLib.quark_from_string(detail)
62
65
  sig_info = object.class.find_signal signal
63
- arr = sig_info.signal_arguments_to_gvalue_array object, *args
64
- rval = sig_info.gvalue_for_signal_return_value
65
66
 
66
- Lib.g_signal_emitv arr.values, signal_id, detail_quark, rval
67
+ arr_ptr = sig_info.arguments_to_gvalue_array_pointer object, args
68
+
69
+ rval = sig_info.gvalue_for_return_value
70
+
71
+ Lib.g_signal_emitv arr_ptr, signal_id, detail_quark, rval
67
72
 
68
73
  return rval
69
74
  end
@@ -71,10 +76,10 @@ module GObject
71
76
  def self.signal_connect object, detailed_signal, data=nil, &block
72
77
  signal, _ = detailed_signal.split('::')
73
78
  sig_info = object.class.find_signal signal
74
- callback = sig_info.signal_callback(&block)
79
+ callback = sig_info.create_callback(&block)
75
80
  GirFFI::CallbackBase.store_callback callback
76
81
 
77
- data_ptr = GirFFI::InPointer.from_object data
82
+ data_ptr = GirFFI::InPointer.from_closure_data data
78
83
 
79
84
  Lib.g_signal_connect_data object, detailed_signal, callback, data_ptr, nil, 0
80
85
  end
@@ -119,16 +124,4 @@ module GObject
119
124
  TYPE_ARRAY = Lib.g_array_get_type
120
125
  TYPE_HASH_TABLE = Lib.g_hash_table_get_type
121
126
  TYPE_STRV = Lib.g_strv_get_type
122
-
123
- TYPE_TAG_TO_GTYPE = {
124
- :array => TYPE_ARRAY,
125
- :gboolean => TYPE_BOOLEAN,
126
- :gdouble => TYPE_DOUBLE,
127
- :gfloat => TYPE_FLOAT,
128
- :ghash => TYPE_HASH_TABLE,
129
- :gint32 => TYPE_INT,
130
- :glist => TYPE_POINTER,
131
- :utf8 => TYPE_STRING,
132
- :void => TYPE_NONE
133
- }
134
127
  end
@@ -24,13 +24,9 @@ module GObject
24
24
  setup_instance_method "get_property"
25
25
  setup_instance_method "set_property"
26
26
 
27
- def get_property_with_override property_name
27
+ def get_property_extended property_name
28
+ gvalue = get_property property_name
28
29
  type_info = get_property_type property_name
29
- pspec = type_class.find_property property_name
30
-
31
- gvalue = GObject::Value.for_g_type pspec.value_type
32
- get_property_without_override property_name, gvalue
33
-
34
30
  case type_info.tag
35
31
  when :ghash, :glist
36
32
  adjust_value_to_type gvalue.get_value_plain, type_info
@@ -39,12 +35,26 @@ module GObject
39
35
  end
40
36
  end
41
37
 
42
- def set_property_with_override property_name, value
43
- type_info = get_property_type property_name
38
+ def get_property_with_override property_name
44
39
  pspec = type_class.find_property property_name
45
40
 
46
41
  gvalue = GObject::Value.for_g_type pspec.value_type
47
- gvalue.set_value adjust_value_to_type(value, type_info)
42
+ get_property_without_override property_name, gvalue
43
+
44
+ gvalue
45
+ end
46
+
47
+ def set_property_extended property_name, value
48
+ type_info = get_property_type property_name
49
+ adjusted_value = adjust_value_to_type(value, type_info)
50
+
51
+ set_property property_name, adjusted_value
52
+ end
53
+
54
+ def set_property_with_override property_name, value
55
+ pspec = type_class.find_property property_name
56
+ gvalue = GObject::Value.for_g_type pspec.value_type
57
+ gvalue.set_value value
48
58
  set_property_without_override property_name, gvalue
49
59
  end
50
60
 
@@ -0,0 +1,14 @@
1
+ module GObject
2
+ load_class :ObjectClass
3
+
4
+ # Overrides for GObjectClass, a struct containing GObject's class data
5
+ class ObjectClass
6
+ def set_property= callback
7
+ @struct[:set_property] = GObject::ObjectSetPropertyFunc.from callback
8
+ end
9
+
10
+ def get_property= callback
11
+ @struct[:get_property] = GObject::ObjectGetPropertyFunc.from callback
12
+ end
13
+ end
14
+ end