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.
- checksums.yaml +7 -0
- data/{History.txt → Changelog.md} +93 -61
- data/{DESIGN.rdoc → DESIGN.md} +7 -7
- data/README.md +5 -7
- data/TODO.md +90 -0
- data/lib/ffi-glib.rb +0 -1
- data/lib/ffi-glib/array.rb +13 -29
- data/lib/ffi-glib/array_methods.rb +13 -0
- data/lib/ffi-glib/container_class_methods.rb +6 -1
- data/lib/ffi-glib/hash_table.rb +3 -2
- data/lib/ffi-glib/list.rb +3 -17
- data/lib/ffi-glib/list_methods.rb +22 -3
- data/lib/ffi-glib/ptr_array.rb +19 -19
- data/lib/ffi-glib/s_list.rb +3 -17
- data/lib/ffi-gobject.rb +10 -17
- data/lib/ffi-gobject/object.rb +19 -9
- data/lib/ffi-gobject/object_class.rb +14 -0
- data/lib/ffi-gobject/ruby_closure.rb +4 -5
- data/lib/ffi-gobject/value.rb +7 -5
- data/lib/ffi-gobject_introspection/i_vfunc_info.rb +1 -1
- data/lib/gir_ffi-base.rb +0 -2
- data/lib/gir_ffi-base/gobject.rb +1 -0
- data/lib/gir_ffi-base/gobject/lib.rb +1 -1
- data/lib/gir_ffi.rb +2 -0
- data/lib/gir_ffi/arg_helper.rb +18 -8
- data/lib/gir_ffi/builders/argument_builder.rb +62 -55
- data/lib/gir_ffi/builders/base_argument_builder.rb +52 -106
- data/lib/gir_ffi/builders/base_type_builder.rb +3 -3
- data/lib/gir_ffi/builders/c_to_ruby_convertor.rb +34 -0
- data/lib/gir_ffi/builders/callback_argument_builder.rb +73 -0
- data/lib/gir_ffi/builders/callback_builder.rb +19 -9
- data/lib/gir_ffi/builders/callback_return_value_builder.rb +54 -0
- data/lib/gir_ffi/builders/closure_convertor.rb +9 -0
- data/lib/gir_ffi/builders/closure_to_pointer_convertor.rb +9 -0
- data/lib/gir_ffi/builders/constructor_result_convertor.rb +9 -0
- data/lib/gir_ffi/builders/enum_builder.rb +16 -16
- data/lib/gir_ffi/builders/field_builder.rb +36 -15
- data/lib/gir_ffi/builders/function_builder.rb +32 -27
- data/lib/gir_ffi/builders/interface_builder.rb +14 -4
- data/lib/gir_ffi/builders/mapping_method_builder.rb +95 -43
- data/lib/gir_ffi/builders/module_builder.rb +22 -35
- data/lib/gir_ffi/builders/null_convertor.rb +9 -0
- data/lib/gir_ffi/builders/object_builder.rb +11 -14
- data/lib/gir_ffi/builders/property_builder.rb +107 -9
- data/lib/gir_ffi/builders/registered_type_builder.rb +2 -2
- data/lib/gir_ffi/builders/return_value_builder.rb +42 -33
- data/lib/gir_ffi/builders/ruby_to_c_convertor.rb +15 -0
- data/lib/gir_ffi/builders/signal_builder.rb +18 -58
- data/lib/gir_ffi/builders/struct_builder.rb +1 -2
- data/lib/gir_ffi/builders/type_builder.rb +1 -0
- data/lib/gir_ffi/builders/unintrospectable_builder.rb +4 -4
- data/lib/gir_ffi/builders/user_defined_builder.rb +151 -26
- data/lib/gir_ffi/builders/vfunc_builder.rb +57 -0
- data/lib/gir_ffi/builders/with_layout.rb +10 -8
- data/lib/gir_ffi/builders/with_methods.rb +1 -1
- data/lib/gir_ffi/callback_base.rb +42 -8
- data/lib/gir_ffi/class_base.rb +1 -2
- data/lib/gir_ffi/enum_base.rb +26 -4
- data/lib/gir_ffi/error_argument_info.rb +21 -0
- data/lib/gir_ffi/{setter_argument_info.rb → field_argument_info.rb} +2 -1
- data/lib/gir_ffi/g_type.rb +25 -0
- data/lib/gir_ffi/in_out_pointer.rb +3 -14
- data/lib/gir_ffi/in_pointer.rb +20 -21
- data/lib/gir_ffi/info_ext.rb +2 -0
- data/lib/gir_ffi/info_ext/i_callable_info.rb +0 -9
- data/lib/gir_ffi/info_ext/i_callback_info.rb +17 -0
- data/lib/gir_ffi/info_ext/i_function_info.rb +4 -0
- data/lib/gir_ffi/info_ext/i_property_info.rb +4 -0
- data/lib/gir_ffi/info_ext/i_registered_type_info.rb +1 -0
- data/lib/gir_ffi/info_ext/i_signal_info.rb +14 -16
- data/lib/gir_ffi/info_ext/i_type_info.rb +72 -34
- data/lib/gir_ffi/info_ext/i_vfunc_info.rb +12 -0
- data/lib/gir_ffi/info_ext/safe_constant_name.rb +3 -2
- data/lib/gir_ffi/interface_base.rb +8 -3
- data/lib/gir_ffi/module_base.rb +3 -5
- data/lib/gir_ffi/object_base.rb +8 -0
- data/lib/gir_ffi/receiver_argument_info.rb +21 -0
- data/lib/gir_ffi/receiver_type_info.rb +27 -0
- data/lib/gir_ffi/return_value_info.rb +23 -0
- data/lib/gir_ffi/signal_base.rb +1 -1
- data/lib/{ffi-glib → gir_ffi}/sized_array.rb +10 -6
- data/lib/gir_ffi/struct_base.rb +10 -9
- data/lib/gir_ffi/type_base.rb +1 -0
- data/lib/gir_ffi/type_map.rb +3 -0
- data/lib/gir_ffi/unintrospectable_type_info.rb +4 -1
- data/lib/gir_ffi/union_base.rb +4 -21
- data/lib/gir_ffi/user_data_argument_info.rb +21 -0
- data/lib/gir_ffi/user_data_type_info.rb +17 -0
- data/lib/gir_ffi/user_defined_type_info.rb +18 -4
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi/vfunc_base.rb +8 -0
- data/lib/gir_ffi/vfunc_implementation.rb +11 -0
- data/lib/gir_ffi/zero_terminated.rb +18 -24
- data/test/base_test_helper.rb +2 -3
- data/test/ffi-glib/array_test.rb +3 -3
- data/test/ffi-glib/ruby_closure_test.rb +3 -3
- data/test/ffi-gobject/value_test.rb +15 -1
- data/test/ffi-gobject_test.rb +2 -1
- data/test/gir_ffi/arg_helper_test.rb +21 -2
- data/test/gir_ffi/builders/argument_builder_test.rb +213 -287
- data/test/gir_ffi/builders/base_argument_builder_test.rb +1 -1
- data/test/gir_ffi/builders/callback_builder_test.rb +26 -8
- data/test/gir_ffi/builders/field_builder_test.rb +18 -3
- data/test/gir_ffi/builders/function_builder_test.rb +30 -12
- data/test/gir_ffi/builders/interface_builder_test.rb +9 -0
- data/test/gir_ffi/builders/module_builder_test.rb +0 -39
- data/test/gir_ffi/builders/object_builder_test.rb +27 -27
- data/test/gir_ffi/builders/property_builder_test.rb +110 -0
- data/test/gir_ffi/builders/return_value_builder_test.rb +168 -200
- data/test/gir_ffi/builders/signal_builder_test.rb +58 -14
- data/test/gir_ffi/builders/struct_builder_test.rb +2 -41
- data/test/gir_ffi/builders/user_defined_builder_test.rb +88 -20
- data/test/gir_ffi/builders/vfunc_builder_test.rb +44 -0
- data/test/gir_ffi/g_type_test.rb +29 -0
- data/test/gir_ffi/in_pointer_test.rb +28 -9
- data/test/gir_ffi/info_ext/i_callable_info_test.rb +0 -9
- data/test/gir_ffi/info_ext/i_callback_info_test.rb +19 -0
- data/test/gir_ffi/info_ext/i_function_info_test.rb +9 -0
- data/test/gir_ffi/info_ext/i_signal_info_test.rb +8 -11
- data/test/gir_ffi/info_ext/i_type_info_test.rb +140 -16
- data/test/gir_ffi/interface_base_test.rb +9 -3
- data/test/gir_ffi/object_base_test.rb +1 -2
- data/test/{ffi-glib → gir_ffi}/sized_array_test.rb +28 -28
- data/test/gir_ffi/type_map_test.rb +1 -1
- data/test/gir_ffi/user_defined_type_info_test.rb +36 -4
- data/test/gir_ffi_test.rb +5 -5
- data/test/gir_ffi_test_helper.rb +4 -0
- data/test/integration/generated_gimarshallingtests_test.rb +163 -59
- data/test/integration/generated_gobject_test.rb +21 -8
- data/test/integration/generated_pango_test.rb +2 -2
- data/test/integration/generated_regress_test.rb +361 -101
- data/test/lib/autogen.sh +5 -1
- metadata +51 -35
- data/TODO.rdoc +0 -63
- data/lib/gir_ffi-base/gir_ffi/library.rb +0 -17
- data/lib/gir_ffi-base/gir_ffi/struct.rb +0 -27
@@ -18,7 +18,7 @@ module GirFFI
|
|
18
18
|
def setup_gtype_getter
|
19
19
|
gtype = target_gtype
|
20
20
|
return if gtype.nil?
|
21
|
-
|
21
|
+
klass.instance_eval "
|
22
22
|
def self.get_gtype
|
23
23
|
#{gtype}
|
24
24
|
end
|
@@ -29,7 +29,7 @@ module GirFFI
|
|
29
29
|
def provide_constructor
|
30
30
|
return if info.find_method 'new'
|
31
31
|
|
32
|
-
(class <<
|
32
|
+
(class << klass; self; end).class_eval {
|
33
33
|
alias_method :new, :_allocate
|
34
34
|
}
|
35
35
|
end
|
@@ -1,63 +1,72 @@
|
|
1
1
|
require 'gir_ffi/builders/base_argument_builder'
|
2
|
+
require 'gir_ffi/builders/c_to_ruby_convertor'
|
3
|
+
require 'gir_ffi/builders/closure_convertor'
|
4
|
+
require 'gir_ffi/builders/constructor_result_convertor'
|
2
5
|
|
3
6
|
module GirFFI
|
4
7
|
module Builders
|
5
8
|
# Implements building post-processing statements for return values.
|
6
9
|
class ReturnValueBuilder < BaseArgumentBuilder
|
7
|
-
def initialize var_gen,
|
8
|
-
super var_gen,
|
10
|
+
def initialize var_gen, arginfo, is_constructor = false
|
11
|
+
super var_gen, arginfo
|
9
12
|
@is_constructor = is_constructor
|
10
|
-
@skip = skip
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
14
|
-
|
15
|
-
[ "#{retname} = #{post_conversion}" ]
|
16
|
-
else
|
17
|
-
[]
|
18
|
-
end
|
15
|
+
def is_relevant?
|
16
|
+
!is_void_return_value? && !arginfo.skip?
|
19
17
|
end
|
20
18
|
|
21
|
-
def
|
22
|
-
|
19
|
+
def capture_variable_name
|
20
|
+
@capture_variable_name ||= new_variable
|
23
21
|
end
|
24
22
|
|
25
|
-
def
|
26
|
-
if
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
def post_converted_name
|
24
|
+
@post_converted_name ||= if has_post_conversion?
|
25
|
+
new_variable
|
26
|
+
else
|
27
|
+
capture_variable_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def return_value_name
|
32
|
+
if is_relevant?
|
33
|
+
post_converted_name unless array_arg
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
36
|
-
|
37
|
+
def post_conversion
|
38
|
+
if has_post_conversion?
|
39
|
+
[ "#{post_converted_name} = #{post_convertor.conversion}" ]
|
40
|
+
else
|
41
|
+
[]
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
45
|
private
|
40
46
|
|
41
|
-
def
|
42
|
-
is_closure ||
|
47
|
+
def has_post_conversion?
|
48
|
+
is_closure || needs_constructor_wrap? ||
|
49
|
+
type_info.needs_conversion_for_functions?
|
43
50
|
end
|
44
51
|
|
45
|
-
def
|
46
|
-
if is_closure
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
def post_convertor
|
53
|
+
@post_convertor ||= if is_closure
|
54
|
+
ClosureConvertor.new(capture_variable_name)
|
55
|
+
elsif needs_constructor_wrap?
|
56
|
+
ConstructorResultConvertor.new(capture_variable_name)
|
57
|
+
else
|
58
|
+
CToRubyConvertor.new(type_info,
|
59
|
+
capture_variable_name,
|
60
|
+
length_argument_name)
|
61
|
+
end
|
53
62
|
end
|
54
63
|
|
55
|
-
def
|
56
|
-
|
64
|
+
def length_argument_name
|
65
|
+
length_arg && length_arg.post_converted_name
|
57
66
|
end
|
58
67
|
|
59
68
|
def needs_constructor_wrap?
|
60
|
-
@is_constructor &&
|
69
|
+
@is_constructor && specialized_type_tag == :object
|
61
70
|
end
|
62
71
|
|
63
72
|
def is_void_return_value?
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class GirFFI::Builders::RubyToCConvertor
|
2
|
+
def initialize type_info, argument_name
|
3
|
+
@type_info = type_info
|
4
|
+
@argument_name = argument_name
|
5
|
+
end
|
6
|
+
|
7
|
+
def conversion
|
8
|
+
args = conversion_arguments @argument_name
|
9
|
+
"#{@type_info.argument_class_name}.from(#{args})"
|
10
|
+
end
|
11
|
+
|
12
|
+
def conversion_arguments name
|
13
|
+
@type_info.extra_conversion_arguments.map(&:inspect).push(name).join(", ")
|
14
|
+
end
|
15
|
+
end
|
@@ -1,82 +1,42 @@
|
|
1
1
|
require 'gir_ffi/builders/base_type_builder'
|
2
2
|
require 'gir_ffi/builders/mapping_method_builder'
|
3
|
+
require 'gir_ffi/receiver_type_info'
|
4
|
+
require 'gir_ffi/receiver_argument_info'
|
3
5
|
require 'gir_ffi/signal_base'
|
6
|
+
require 'gir_ffi/user_data_type_info'
|
7
|
+
require 'gir_ffi/user_data_argument_info'
|
4
8
|
|
5
9
|
module GirFFI
|
6
10
|
module Builders
|
7
11
|
# Implements the creation of a signal module for handling a particular
|
8
12
|
# signal. The type will be attached to the appropriate class.
|
9
13
|
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
14
|
def instantiate_class
|
60
|
-
@klass ||= get_or_define_module container_class, @classname
|
61
15
|
unless already_set_up
|
62
|
-
|
16
|
+
klass.extend SignalBase
|
63
17
|
setup_constants
|
64
|
-
|
18
|
+
klass.class_eval mapping_method_definition
|
65
19
|
end
|
66
|
-
|
20
|
+
klass
|
21
|
+
end
|
22
|
+
|
23
|
+
def klass
|
24
|
+
@klass ||= get_or_define_module container_class, @classname
|
67
25
|
end
|
68
26
|
|
69
27
|
def mapping_method_definition
|
70
28
|
arg_infos = info.args
|
71
29
|
|
72
|
-
container_type_info =
|
73
|
-
|
30
|
+
container_type_info = ReceiverTypeInfo.new(container_info)
|
31
|
+
receiver_info = ReceiverArgumentInfo.new(container_type_info)
|
74
32
|
|
75
33
|
user_data_type_info = UserDataTypeInfo.new
|
76
|
-
user_data_argument_info = UserDataArgumentInfo.new(user_data_type_info
|
77
|
-
arg_infos.push user_data_argument_info
|
34
|
+
user_data_argument_info = UserDataArgumentInfo.new(user_data_type_info)
|
78
35
|
|
79
|
-
MappingMethodBuilder.
|
36
|
+
MappingMethodBuilder.for_signal(receiver_info,
|
37
|
+
arg_infos,
|
38
|
+
user_data_argument_info,
|
39
|
+
info.return_type).method_definition
|
80
40
|
end
|
81
41
|
|
82
42
|
def container_class
|
@@ -7,13 +7,13 @@ module GirFFI
|
|
7
7
|
# cast objects returned by a function that returns an interface.
|
8
8
|
class UnintrospectableBuilder < ObjectBuilder
|
9
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
10
|
setup_class unless already_set_up
|
15
11
|
end
|
16
12
|
|
13
|
+
def klass
|
14
|
+
@klass ||= TypeBuilder::CACHE[target_gtype] ||= Class.new(superclass)
|
15
|
+
end
|
16
|
+
|
17
17
|
def setup_class
|
18
18
|
setup_constants
|
19
19
|
setup_layout
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'gir_ffi/builders/object_builder'
|
2
|
+
require 'gir_ffi/g_type'
|
2
3
|
|
3
4
|
module GirFFI
|
4
5
|
module Builders
|
@@ -9,25 +10,19 @@ module GirFFI
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def instantiate_class
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
13
|
+
if already_set_up
|
14
|
+
@gtype = klass.get_gtype
|
15
|
+
else
|
16
|
+
@gtype = GObject.type_register_static(parent_gtype.to_i,
|
17
|
+
info.g_name,
|
18
|
+
gobject_type_info, 0)
|
19
|
+
included_interfaces.each do |interface|
|
20
|
+
ifinfo = gobject_interface_info interface
|
21
|
+
GObject.type_add_interface_static @gtype, interface.get_gtype, ifinfo
|
22
|
+
end
|
23
|
+
setup_class
|
24
|
+
TypeBuilder::CACHE[@gtype] = klass
|
23
25
|
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
26
|
end
|
32
27
|
|
33
28
|
def setup_class
|
@@ -41,14 +36,143 @@ module GirFFI
|
|
41
36
|
setup_constructor
|
42
37
|
end
|
43
38
|
|
39
|
+
def gtype
|
40
|
+
@gtype
|
41
|
+
end
|
42
|
+
|
44
43
|
private
|
45
44
|
|
45
|
+
# FIXME: Is this really used?
|
46
46
|
def target_gtype
|
47
47
|
@gtype
|
48
48
|
end
|
49
49
|
|
50
50
|
def parent
|
51
|
-
@parent
|
51
|
+
@parent ||= gir.find_by_gtype(parent_gtype.to_i)
|
52
|
+
end
|
53
|
+
|
54
|
+
def parent_gtype
|
55
|
+
@parent_gtype ||= GType.new(klass.superclass.get_gtype)
|
56
|
+
end
|
57
|
+
|
58
|
+
def interface_gtypes
|
59
|
+
included_interfaces.map {|interface| GType.new(interface.get_gtype) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def included_interfaces
|
63
|
+
klass.included_modules - Object.included_modules
|
64
|
+
end
|
65
|
+
|
66
|
+
def klass
|
67
|
+
@klass ||= @info.described_class
|
68
|
+
end
|
69
|
+
|
70
|
+
def gobject_type_info
|
71
|
+
GObject::TypeInfo.new.tap do |type_info|
|
72
|
+
type_info.class_size = class_size
|
73
|
+
type_info.instance_size = instance_size
|
74
|
+
type_info.class_init = class_init_proc
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def gobject_interface_info interface
|
79
|
+
GObject::InterfaceInfo.new.tap do |interface_info|
|
80
|
+
interface_info.interface_init = interface_init_proc(interface)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def class_init_proc
|
85
|
+
proc do |object_class_ptr, data|
|
86
|
+
setup_properties object_class_ptr
|
87
|
+
setup_vfuncs object_class_ptr
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def interface_init_proc interface
|
92
|
+
proc do |interface_ptr, data|
|
93
|
+
setup_interface_vfuncs interface, interface_ptr
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def instance_size
|
98
|
+
size = parent_gtype.instance_size
|
99
|
+
properties.each do
|
100
|
+
size += FFI.type_size(:int32)
|
101
|
+
end
|
102
|
+
return size
|
103
|
+
end
|
104
|
+
|
105
|
+
def class_size
|
106
|
+
parent_gtype.class_size + interface_gtypes.map(&:class_size).inject(0, :+)
|
107
|
+
end
|
108
|
+
|
109
|
+
def setup_properties object_class_ptr
|
110
|
+
object_class = GObject::ObjectClass.wrap object_class_ptr
|
111
|
+
|
112
|
+
object_class.get_property = property_getter
|
113
|
+
object_class.set_property = property_setter
|
114
|
+
|
115
|
+
properties.each_with_index do |property, index|
|
116
|
+
object_class.install_property index + 1, property.param_spec
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def property_getter
|
121
|
+
proc do |object, property_id, value, pspec|
|
122
|
+
value.set_value object.send(pspec.get_name)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def property_setter
|
127
|
+
proc do |object, property_id, value, pspec|
|
128
|
+
object.send("#{pspec.get_name}=", value.get_value)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def setup_vfuncs object_class_ptr
|
133
|
+
super_class_struct = superclass.gir_ffi_builder.object_class_struct::Struct.new(object_class_ptr)
|
134
|
+
|
135
|
+
info.vfunc_implementations.each do |impl|
|
136
|
+
setup_vfunc super_class_struct, impl
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def setup_interface_vfuncs interface, interface_ptr
|
141
|
+
interface_builder = interface.gir_ffi_builder
|
142
|
+
|
143
|
+
interface_struct = interface_builder.interface_struct::Struct.new(interface_ptr)
|
144
|
+
interface_info = interface_builder.info
|
145
|
+
|
146
|
+
info.vfunc_implementations.each do |impl|
|
147
|
+
setup_interface_vfunc interface_info, interface_struct, impl
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def setup_vfunc super_class_struct, impl
|
152
|
+
vfunc_name = impl.name
|
153
|
+
vfunc_info = parent.find_vfunc vfunc_name.to_s
|
154
|
+
|
155
|
+
if vfunc_info
|
156
|
+
install_vfunc super_class_struct, vfunc_name, vfunc_info, impl.implementation
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def setup_interface_vfunc interface_info, interface_struct, impl
|
161
|
+
vfunc_name = impl.name
|
162
|
+
vfunc_info = interface_info.find_vfunc vfunc_name.to_s
|
163
|
+
|
164
|
+
if vfunc_info
|
165
|
+
install_vfunc interface_struct, vfunc_name, vfunc_info, impl.implementation
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def install_vfunc container_struct, vfunc_name, vfunc_info, implementation
|
170
|
+
vfunc = VFuncBuilder.new(vfunc_info).build_class
|
171
|
+
# NOTE: This assigns a VFuncBase to a CallbackBase.
|
172
|
+
# This suggests that the two should be combined, but it seems
|
173
|
+
# CallbackBase will not cast the first argument correctly if used
|
174
|
+
# to map the implementation proc arguments.
|
175
|
+
container_struct[vfunc_name] = vfunc.from implementation
|
52
176
|
end
|
53
177
|
|
54
178
|
def properties
|
@@ -73,19 +197,20 @@ module GirFFI
|
|
73
197
|
end
|
74
198
|
|
75
199
|
def setup_accessors_for_param_info pinfo
|
200
|
+
field_name = pinfo.name
|
76
201
|
code = <<-CODE
|
77
|
-
def #{
|
78
|
-
@struct[:#{
|
202
|
+
def #{field_name}
|
203
|
+
@struct[:#{field_name}]
|
79
204
|
end
|
80
|
-
def #{
|
81
|
-
@struct[:#{
|
205
|
+
def #{field_name}= val
|
206
|
+
@struct[:#{field_name}] = val
|
82
207
|
end
|
83
208
|
CODE
|
84
209
|
|
85
|
-
|
210
|
+
klass.class_eval code
|
86
211
|
end
|
87
212
|
|
88
|
-
def method_introspection_data
|
213
|
+
def method_introspection_data _method
|
89
214
|
nil
|
90
215
|
end
|
91
216
|
|
@@ -96,7 +221,7 @@ module GirFFI
|
|
96
221
|
self.wrap(gptr)
|
97
222
|
end
|
98
223
|
CODE
|
99
|
-
|
224
|
+
klass.class_eval code
|
100
225
|
end
|
101
226
|
end
|
102
227
|
end
|