gir_ffi 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/README.rdoc +28 -14
- data/Rakefile +1 -1
- data/TODO.rdoc +3 -24
- data/examples/05_notification.rb +35 -0
- data/lib/gir_ffi/arg_helper.rb +15 -279
- data/lib/gir_ffi/builder/argument/base.rb +110 -0
- data/lib/gir_ffi/builder/argument/hash_table_base.rb +20 -0
- data/lib/gir_ffi/builder/argument/in_base.rb +19 -0
- data/lib/gir_ffi/builder/argument/in_out_base.rb +25 -0
- data/lib/gir_ffi/builder/argument/list_base.rb +16 -0
- data/lib/gir_ffi/builder/argument/out_base.rb +27 -0
- data/lib/gir_ffi/builder/argument.rb +167 -357
- data/lib/gir_ffi/builder/function.rb +2 -0
- data/lib/gir_ffi/builder/module.rb +2 -2
- data/lib/gir_ffi/builder/type/base.rb +7 -0
- data/lib/gir_ffi/builder/type/callback.rb +1 -8
- data/lib/gir_ffi/builder/type/constant.rb +1 -6
- data/lib/gir_ffi/builder/type/enum.rb +2 -7
- data/lib/gir_ffi/builder/type/interface.rb +12 -14
- data/lib/gir_ffi/builder/type/object.rb +32 -13
- data/lib/gir_ffi/builder/type/registered_type.rb +1 -78
- data/lib/gir_ffi/builder/type/struct.rb +2 -0
- data/lib/gir_ffi/builder/type/struct_based.rb +9 -24
- data/lib/gir_ffi/builder/type/unintrospectable.rb +63 -0
- data/lib/gir_ffi/builder/type/union.rb +8 -7
- data/lib/gir_ffi/builder/type/with_layout.rb +43 -0
- data/lib/gir_ffi/builder/type/with_methods.rb +61 -0
- data/lib/gir_ffi/builder.rb +39 -0
- data/lib/gir_ffi/callback_helper.rb +58 -0
- data/lib/gir_ffi/class_base.rb +17 -5
- data/lib/gir_ffi/i_repository.rb +0 -4
- data/lib/gir_ffi/in_out_pointer.rb +76 -0
- data/lib/gir_ffi/in_pointer.rb +46 -0
- data/lib/gir_ffi/interface_base.rb +12 -0
- data/lib/gir_ffi/module_base.rb +7 -3
- data/lib/gir_ffi/overrides/glib.rb +14 -3
- data/lib/gir_ffi/overrides/gobject.rb +37 -15
- data/lib/gir_ffi/overrides/gtk.rb +1 -1
- data/lib/gir_ffi/version.rb +1 -1
- data/lib/gir_ffi.rb +3 -0
- data/tasks/rdoc.rake +6 -0
- data/tasks/test.rake +22 -3
- data/tasks/yardoc.rake +6 -0
- data/test/arg_helper_test.rb +2 -72
- data/test/builder_test.rb +15 -19
- data/test/function_definition_builder_test.rb +30 -37
- data/test/g_object_overrides_test.rb +29 -1
- data/test/glib_overrides_test.rb +4 -0
- data/test/gtk_overrides_test.rb +21 -15
- data/test/i_repository_test.rb +2 -1
- data/test/{generated_gimarshallingtests_test.rb → integration/generated_gimarshallingtests_test.rb} +1 -1
- data/test/integration/generated_gio_test.rb +98 -0
- data/test/integration/generated_gobject_test.rb +30 -0
- data/test/{generated_gtk_test.rb → integration/generated_gtk_test.rb} +5 -5
- data/test/{generated_regress_test.rb → integration/generated_regress_test.rb} +19 -5
- data/test/interface_type_builder_test.rb +1 -1
- data/test/module_builder_test.rb +3 -3
- data/test/test_helper.rb +4 -9
- data/test/type_builder_test.rb +5 -5
- data/test/{dynamic_type_builder_test.rb → unintrospectable_type_builder_test.rb} +12 -8
- data/test/unit/builder_test.rb +31 -0
- data/test/unit/callback_helper_test.rb +19 -0
- data/test/unit/constant_builder_test.rb +5 -0
- data/test/unit/i_constant_info_test.rb +17 -0
- data/test/unit/in_out_pointer_test.rb +118 -0
- data/test/unit/in_pointer_test.rb +69 -0
- data/test/unit/object_type_builder_test.rb +20 -0
- metadata +47 -19
- data/lib/gir_ffi/builder/dynamic_type.rb +0 -41
- data/test/generated_gio_test.rb +0 -39
- data/test/generated_gobject_test.rb +0 -15
- data/test/object_type_builder_test.rb +0 -34
data/test/test_helper.rb
CHANGED
@@ -15,10 +15,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
15
15
|
|
16
16
|
require 'gir_ffi'
|
17
17
|
|
18
|
-
# Since the tests will call Gtk+ functions, Gtk+ must be initialized.
|
19
|
-
GirFFI.setup :Gtk, '2.0'
|
20
|
-
Gtk.init
|
21
|
-
|
22
18
|
GirFFI::IRepository.prepend_search_path File.join(File.dirname(__FILE__), 'lib')
|
23
19
|
module GirFFI
|
24
20
|
class IRepository
|
@@ -48,17 +44,16 @@ class MiniTest::Unit::TestCase
|
|
48
44
|
code.gsub(/(^\s*|\s*$)/, "")
|
49
45
|
end
|
50
46
|
|
51
|
-
|
52
|
-
def get_function_introspection_data namespace, function
|
47
|
+
def get_introspection_data namespace, name
|
53
48
|
gir = GirFFI::IRepository.default
|
54
49
|
gir.require namespace, nil
|
55
|
-
gir.find_by_name namespace,
|
50
|
+
gir.find_by_name namespace, name
|
56
51
|
end
|
57
52
|
|
58
|
-
def get_method_introspection_data namespace, klass,
|
53
|
+
def get_method_introspection_data namespace, klass, name
|
59
54
|
gir = GirFFI::IRepository.default
|
60
55
|
gir.require namespace, nil
|
61
|
-
gir.find_by_name(namespace, klass).find_method
|
56
|
+
gir.find_by_name(namespace, klass).find_method name
|
62
57
|
end
|
63
58
|
|
64
59
|
SAVED_MODULES = {}
|
data/test/type_builder_test.rb
CHANGED
@@ -20,7 +20,7 @@ class TypeBuilderTest < MiniTest::Spec
|
|
20
20
|
|
21
21
|
context "for Gtk::Widget" do
|
22
22
|
setup do
|
23
|
-
@cbuilder = GirFFI::Builder::Type::Object.new
|
23
|
+
@cbuilder = GirFFI::Builder::Type::Object.new get_introspection_data('Gtk', 'Widget')
|
24
24
|
end
|
25
25
|
|
26
26
|
context "looking at Gtk::Widget#show" do
|
@@ -39,19 +39,19 @@ class TypeBuilderTest < MiniTest::Spec
|
|
39
39
|
|
40
40
|
context 'the find_signal method' do
|
41
41
|
should 'find the signal "test" for TestObj' do
|
42
|
-
builder = GirFFI::Builder::Type::Object.new
|
42
|
+
builder = GirFFI::Builder::Type::Object.new get_introspection_data('Regress', 'TestObj')
|
43
43
|
sig = builder.find_signal 'test'
|
44
44
|
assert_equal 'test', sig.name
|
45
45
|
end
|
46
46
|
|
47
47
|
should 'find the signal "test" for TestSubObj' do
|
48
|
-
builder = GirFFI::Builder::Type::Object.new
|
48
|
+
builder = GirFFI::Builder::Type::Object.new get_introspection_data('Regress', 'TestSubObj')
|
49
49
|
sig = builder.find_signal 'test'
|
50
50
|
assert_equal 'test', sig.name
|
51
51
|
end
|
52
52
|
|
53
53
|
should 'find the signal "changed" for Gtk::Entry' do
|
54
|
-
builder = GirFFI::Builder::Type::Object.new
|
54
|
+
builder = GirFFI::Builder::Type::Object.new get_introspection_data('Gtk', 'Entry')
|
55
55
|
sig = builder.find_signal 'changed'
|
56
56
|
assert_equal 'changed', sig.name
|
57
57
|
end
|
@@ -59,7 +59,7 @@ class TypeBuilderTest < MiniTest::Spec
|
|
59
59
|
|
60
60
|
context "for GObject::TypeCValue (a union)" do
|
61
61
|
setup do
|
62
|
-
@cbuilder = GirFFI::Builder::Type::Union.new
|
62
|
+
@cbuilder = GirFFI::Builder::Type::Union.new get_introspection_data('GObject', 'TypeCValue')
|
63
63
|
end
|
64
64
|
|
65
65
|
should "returns false looking for a method that doesn't exist" do
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
describe "GirFFI::Builder::DynamicType" do
|
3
|
+
describe GirFFI::Builder::Type::Unintrospectable do
|
6
4
|
describe "building the GLocalFile type" do
|
7
5
|
before do
|
8
6
|
# Ensure existence of GLocalFile type
|
9
7
|
GirFFI.setup :Gio
|
10
8
|
unless Gio::Lib.respond_to? :g_file_new_for_path
|
11
|
-
Gio.
|
9
|
+
Gio._setup_method "file_new_for_path"
|
12
10
|
end
|
13
|
-
ptr = GirFFI::
|
11
|
+
ptr = GirFFI::InPointer.from :utf8, '/'
|
14
12
|
Gio::Lib.g_file_new_for_path(ptr)
|
15
13
|
|
16
14
|
@gtype = GObject.type_from_name 'GLocalFile'
|
17
|
-
bldr = GirFFI::Builder::
|
18
|
-
@klass = bldr.build_class
|
15
|
+
@bldr = GirFFI::Builder::Type::Unintrospectable.new(@gtype)
|
16
|
+
@klass = @bldr.build_class
|
19
17
|
end
|
20
18
|
|
21
19
|
it "builds a class" do
|
@@ -31,10 +29,16 @@ describe "GirFFI::Builder::DynamicType" do
|
|
31
29
|
end
|
32
30
|
|
33
31
|
it "returns the same class when built again" do
|
34
|
-
other_bldr = GirFFI::Builder::
|
32
|
+
other_bldr = GirFFI::Builder::Type::Unintrospectable.new(@gtype)
|
35
33
|
other_klass = other_bldr.build_class
|
36
34
|
|
37
35
|
assert_equal @klass, other_klass
|
38
36
|
end
|
37
|
+
|
38
|
+
describe "its #find_signal method" do
|
39
|
+
it "works for a signal that doesn't exist" do
|
40
|
+
assert_nil @bldr.find_signal "foo"
|
41
|
+
end
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe GirFFI::Builder do
|
4
|
+
describe ".itypeinfo_to_callback_ffitype" do
|
5
|
+
describe "for an :interface argument" do
|
6
|
+
setup do
|
7
|
+
@iface = Object.new
|
8
|
+
stub(@info = Object.new).interface { @iface }
|
9
|
+
stub(@info).tag { :interface }
|
10
|
+
stub(@info).pointer? { false }
|
11
|
+
end
|
12
|
+
|
13
|
+
it "correctly maps a :union argument to :pointer" do
|
14
|
+
stub(@iface).info_type { :union }
|
15
|
+
|
16
|
+
result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
|
17
|
+
|
18
|
+
assert_equal :pointer, result
|
19
|
+
end
|
20
|
+
|
21
|
+
it "correctly maps a :flags argument to :int32" do
|
22
|
+
stub(@iface).info_type { :flags }
|
23
|
+
|
24
|
+
result = GirFFI::Builder.itypeinfo_to_callback_ffitype @info
|
25
|
+
|
26
|
+
assert_equal :int32, result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe GirFFI::CallbackHelper do
|
4
|
+
describe ".map_single_callback_arg" do
|
5
|
+
it "correctly maps a :struct type" do
|
6
|
+
GirFFI.setup :GObject
|
7
|
+
|
8
|
+
cl = GObject::Closure.new_simple GObject::Closure::Struct.size, nil
|
9
|
+
|
10
|
+
cinfo = GirFFI::IRepository.default.find_by_name 'GObject', 'ClosureMarshal'
|
11
|
+
ainfo = cinfo.args[0]
|
12
|
+
|
13
|
+
r = GirFFI::CallbackHelper.map_single_callback_arg cl.to_ptr, ainfo
|
14
|
+
|
15
|
+
assert_instance_of GObject::Closure, r
|
16
|
+
assert_equal r.to_ptr, cl.to_ptr
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe GirFFI::IConstantInfo do
|
4
|
+
describe "for GLib::ALLOCATOR_LIST, a constant of type :gint32" do
|
5
|
+
before do
|
6
|
+
@info = get_introspection_data 'GLib', 'ALLOCATOR_LIST'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "returns :gint32 as its type" do
|
10
|
+
assert_equal :gint32, @info.constant_type.tag
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns a value union with member :v_int32 with value 1" do
|
14
|
+
assert_equal 1, @info.value[:v_int32]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'gir_ffi/in_out_pointer'
|
4
|
+
|
5
|
+
describe GirFFI::InOutPointer do
|
6
|
+
describe "an instance created with .from" do
|
7
|
+
setup do
|
8
|
+
@result = GirFFI::InOutPointer.from :gint32, 23
|
9
|
+
end
|
10
|
+
|
11
|
+
it "holds a pointer to the given value" do
|
12
|
+
assert_equal 23, @result.read_int32
|
13
|
+
end
|
14
|
+
|
15
|
+
it "is an instance of GirFFI::InOutPointer" do
|
16
|
+
assert_instance_of GirFFI::InOutPointer, @result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".from" do
|
21
|
+
it "handles :gboolean" do
|
22
|
+
GirFFI::InOutPointer.from :gboolean, false
|
23
|
+
end
|
24
|
+
|
25
|
+
it "handles :utf8" do
|
26
|
+
GirFFI::InOutPointer.from :utf8, "Hello"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "an instance created with .from_array" do
|
31
|
+
setup do
|
32
|
+
@result = GirFFI::InOutPointer.from_array :gint32, [24, 13]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "holds a pointer to a non-null pointer" do
|
36
|
+
ptr = @result.read_pointer
|
37
|
+
refute ptr.null?
|
38
|
+
end
|
39
|
+
|
40
|
+
it "holds a pointer to a pointer to the correct input values" do
|
41
|
+
ptr = @result.read_pointer
|
42
|
+
assert_equal [24, 13], [ptr.get_int(0), ptr.get_int(4)]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "is an instance of GirFFI::InPointer" do
|
46
|
+
assert_instance_of GirFFI::InOutPointer, @result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe ".from_array" do
|
51
|
+
it "returns nil when passed nil" do
|
52
|
+
result = GirFFI::InOutPointer.from_array :gint32, nil
|
53
|
+
assert_nil result
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "an instance created with .from_array :utf8" do
|
58
|
+
before do
|
59
|
+
@result = GirFFI::InOutPointer.from_array :utf8, ["foo", "bar", "baz"]
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns a pointer to an array of pointers to strings" do
|
63
|
+
ptr = @result.read_pointer
|
64
|
+
ary = ptr.read_array_of_pointer(3)
|
65
|
+
assert_equal ["foo", "bar", "baz"], ary.map {|p| p.read_string}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "in instance created with .for" do
|
70
|
+
setup do
|
71
|
+
@result = GirFFI::InOutPointer.for :gint32
|
72
|
+
end
|
73
|
+
|
74
|
+
it "holds a pointer to a null value" do
|
75
|
+
assert_equal 0, @result.read_int32
|
76
|
+
end
|
77
|
+
|
78
|
+
it "is an instance of GirFFI::InOutPointer" do
|
79
|
+
assert_instance_of GirFFI::InOutPointer, @result
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".for" do
|
84
|
+
it "handles :gboolean" do
|
85
|
+
GirFFI::InOutPointer.for :gboolean
|
86
|
+
end
|
87
|
+
|
88
|
+
it "handles :utf8" do
|
89
|
+
GirFFI::InOutPointer.for :utf8
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#to_value" do
|
94
|
+
it "returns the held value" do
|
95
|
+
ptr = GirFFI::InOutPointer.from :gint32, 123
|
96
|
+
assert_equal 123, ptr.to_value
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "for :gboolean values" do
|
100
|
+
it "works when the value is false" do
|
101
|
+
ptr = GirFFI::InOutPointer.from :gboolean, false
|
102
|
+
assert_equal false, ptr.to_value
|
103
|
+
end
|
104
|
+
|
105
|
+
it "works when the value is true" do
|
106
|
+
ptr = GirFFI::InOutPointer.from :gboolean, true
|
107
|
+
assert_equal true, ptr.to_value
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe "for :utf8 values" do
|
112
|
+
it "returns the held value" do
|
113
|
+
ptr = GirFFI::InOutPointer.from :utf8, "Some value"
|
114
|
+
assert_equal "Some value", ptr.to_value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require 'gir_ffi/in_pointer'
|
4
|
+
|
5
|
+
describe GirFFI::InPointer do
|
6
|
+
describe ".from_array" do
|
7
|
+
it "returns nil when passed nil" do
|
8
|
+
result = GirFFI::InPointer.from_array :gint32, nil
|
9
|
+
assert_nil result
|
10
|
+
end
|
11
|
+
|
12
|
+
it "handles type tag :gtype" do
|
13
|
+
GirFFI::InPointer.from_array :gtype, [2]
|
14
|
+
end
|
15
|
+
|
16
|
+
it "handles type tag :interface_pointer" do
|
17
|
+
GirFFI::InPointer.from_array :interface_pointer, []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "an instance created with .from_array" do
|
22
|
+
setup do
|
23
|
+
@result = GirFFI::InPointer.from_array :gint32, [24, 13]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "holds a pointer to the correct input values" do
|
27
|
+
assert_equal 24, @result.get_int(0)
|
28
|
+
assert_equal 13, @result.get_int(4)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "is an instance of GirFFI::InPointer" do
|
32
|
+
assert_instance_of GirFFI::InPointer, @result
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "an instance created with .from_array :utf8" do
|
37
|
+
before do
|
38
|
+
@result = GirFFI::InPointer.from_array :utf8, ["foo", "bar", "baz"]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns an array of pointers to strings" do
|
42
|
+
ary = @result.read_array_of_pointer(3)
|
43
|
+
assert_equal ["foo", "bar", "baz"], ary.map {|p| p.read_string}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "an instance created with .from :utf8" do
|
48
|
+
before do
|
49
|
+
@result = GirFFI::InPointer.from :utf8, "foo"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns an pointers to the given string" do
|
53
|
+
ary = @result.read_array_of_pointer(3)
|
54
|
+
assert_equal "foo", @result.read_string
|
55
|
+
end
|
56
|
+
|
57
|
+
it "is an instance of GirFFI::InPointer" do
|
58
|
+
assert_instance_of GirFFI::InPointer, @result
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ".from" do
|
63
|
+
it "returns nil when passed nil" do
|
64
|
+
result = GirFFI::InPointer.from :foo, nil
|
65
|
+
assert_nil result
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe GirFFI::Builder::Type::Object do
|
4
|
+
before do
|
5
|
+
GirFFI.setup :Regress
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#setup_method" do
|
9
|
+
it "sets up singleton methods defined in a class's parent" do
|
10
|
+
info = get_introspection_data 'Regress', 'TestSubObj'
|
11
|
+
assert_nil info.find_method "static_method"
|
12
|
+
parent = info.parent
|
13
|
+
assert_not_nil parent.find_method "static_method"
|
14
|
+
|
15
|
+
b = GirFFI::Builder::Type::Object.new(info)
|
16
|
+
b.setup_method "static_method"
|
17
|
+
pass
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gir_ffi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 11
|
10
|
+
version: 0.0.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matijs van Zuijlen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: ffi
|
@@ -86,9 +86,16 @@ files:
|
|
86
86
|
- lib/gir_ffi/g_error.rb
|
87
87
|
- lib/gir_ffi/i_object_info.rb
|
88
88
|
- lib/gir_ffi/builder.rb
|
89
|
-
- lib/gir_ffi/
|
89
|
+
- lib/gir_ffi/in_out_pointer.rb
|
90
|
+
- lib/gir_ffi/builder/argument/list_base.rb
|
91
|
+
- lib/gir_ffi/builder/argument/base.rb
|
92
|
+
- lib/gir_ffi/builder/argument/in_base.rb
|
93
|
+
- lib/gir_ffi/builder/argument/hash_table_base.rb
|
94
|
+
- lib/gir_ffi/builder/argument/out_base.rb
|
95
|
+
- lib/gir_ffi/builder/argument/in_out_base.rb
|
90
96
|
- lib/gir_ffi/builder/module.rb
|
91
97
|
- lib/gir_ffi/builder/function.rb
|
98
|
+
- lib/gir_ffi/builder/type/with_methods.rb
|
92
99
|
- lib/gir_ffi/builder/type/base.rb
|
93
100
|
- lib/gir_ffi/builder/type/constant.rb
|
94
101
|
- lib/gir_ffi/builder/type/interface.rb
|
@@ -97,12 +104,15 @@ files:
|
|
97
104
|
- lib/gir_ffi/builder/type/enum.rb
|
98
105
|
- lib/gir_ffi/builder/type/registered_type.rb
|
99
106
|
- lib/gir_ffi/builder/type/callback.rb
|
107
|
+
- lib/gir_ffi/builder/type/unintrospectable.rb
|
108
|
+
- lib/gir_ffi/builder/type/with_layout.rb
|
100
109
|
- lib/gir_ffi/builder/type/union.rb
|
101
110
|
- lib/gir_ffi/builder/type/object.rb
|
102
111
|
- lib/gir_ffi/builder/type.rb
|
103
112
|
- lib/gir_ffi/builder/argument.rb
|
104
113
|
- lib/gir_ffi/i_enum_info.rb
|
105
114
|
- lib/gir_ffi/i_value_info.rb
|
115
|
+
- lib/gir_ffi/interface_base.rb
|
106
116
|
- lib/gir_ffi/module_base.rb
|
107
117
|
- lib/gir_ffi/i_signal_info.rb
|
108
118
|
- lib/gir_ffi/i_callback_info.rb
|
@@ -113,7 +123,9 @@ files:
|
|
113
123
|
- lib/gir_ffi/i_vfunc_info.rb
|
114
124
|
- lib/gir_ffi/i_constant_info.rb
|
115
125
|
- lib/gir_ffi/class_base.rb
|
126
|
+
- lib/gir_ffi/callback_helper.rb
|
116
127
|
- lib/gir_ffi/i_struct_info.rb
|
128
|
+
- lib/gir_ffi/in_pointer.rb
|
117
129
|
- lib/gir_ffi/i_callable_info.rb
|
118
130
|
- lib/gir_ffi/i_function_info.rb
|
119
131
|
- lib/gir_ffi/i_error_domain_info.rb
|
@@ -130,7 +142,7 @@ files:
|
|
130
142
|
- lib/gir_ffi/i_arg_info.rb
|
131
143
|
- lib/gir_ffi/i_type_info.rb
|
132
144
|
- test/i_repository_test.rb
|
133
|
-
- test/
|
145
|
+
- test/unintrospectable_type_builder_test.rb
|
134
146
|
- test/function_definition_builder_test.rb
|
135
147
|
- test/g_object_test.rb
|
136
148
|
- test/arg_helper_test.rb
|
@@ -138,7 +150,6 @@ files:
|
|
138
150
|
- test/lib/autogen.sh
|
139
151
|
- test/lib/configure.ac
|
140
152
|
- test/lib/m4/jhflags.m4
|
141
|
-
- test/dynamic_type_builder_test.rb
|
142
153
|
- test/class_base_test.rb
|
143
154
|
- test/test_helper.rb
|
144
155
|
- test/girffi_test.rb
|
@@ -146,18 +157,28 @@ files:
|
|
146
157
|
- test/module_builder_test.rb
|
147
158
|
- test/i_object_info_test.rb
|
148
159
|
- test/g_object_overrides_test.rb
|
149
|
-
- test/
|
160
|
+
- test/unit/constant_builder_test.rb
|
161
|
+
- test/unit/in_out_pointer_test.rb
|
162
|
+
- test/unit/callback_helper_test.rb
|
163
|
+
- test/unit/builder_test.rb
|
164
|
+
- test/unit/in_pointer_test.rb
|
165
|
+
- test/unit/object_type_builder_test.rb
|
166
|
+
- test/unit/i_constant_info_test.rb
|
150
167
|
- test/type_builder_test.rb
|
151
168
|
- test/builder_test.rb
|
152
169
|
- test/glib_overrides_test.rb
|
153
170
|
- test/gtk_overrides_test.rb
|
154
|
-
- test/
|
155
|
-
- test/
|
156
|
-
- test/
|
157
|
-
- test/
|
171
|
+
- test/integration/generated_regress_test.rb
|
172
|
+
- test/integration/generated_gtk_test.rb
|
173
|
+
- test/integration/generated_gobject_test.rb
|
174
|
+
- test/integration/generated_gio_test.rb
|
175
|
+
- test/integration/generated_gimarshallingtests_test.rb
|
176
|
+
- tasks/yardoc.rake
|
177
|
+
- tasks/rdoc.rake
|
158
178
|
- tasks/test.rake
|
159
179
|
- tasks/setup.rb
|
160
180
|
- tasks/notes.rake
|
181
|
+
- examples/05_notification.rb
|
161
182
|
- examples/demo_ffi_safe_inherited_layout.rb
|
162
183
|
- examples/04_webkit.rb
|
163
184
|
- examples/demo_ffi_nested_struct.rb
|
@@ -209,26 +230,33 @@ test_files:
|
|
209
230
|
- test/arg_helper_test.rb
|
210
231
|
- test/builder_test.rb
|
211
232
|
- test/class_base_test.rb
|
212
|
-
- test/dynamic_type_builder_test.rb
|
213
233
|
- test/function_definition_builder_test.rb
|
214
234
|
- test/g_object_overrides_test.rb
|
215
235
|
- test/g_object_test.rb
|
216
|
-
- test/generated_gimarshallingtests_test.rb
|
217
|
-
- test/generated_gio_test.rb
|
218
|
-
- test/generated_gobject_test.rb
|
219
|
-
- test/generated_gtk_test.rb
|
220
|
-
- test/generated_regress_test.rb
|
221
236
|
- test/girffi_test.rb
|
222
237
|
- test/glib_overrides_test.rb
|
223
238
|
- test/gtk_overrides_test.rb
|
224
239
|
- test/i_object_info_test.rb
|
225
240
|
- test/i_repository_test.rb
|
241
|
+
- test/integration/generated_gimarshallingtests_test.rb
|
242
|
+
- test/integration/generated_gio_test.rb
|
243
|
+
- test/integration/generated_gobject_test.rb
|
244
|
+
- test/integration/generated_gtk_test.rb
|
245
|
+
- test/integration/generated_regress_test.rb
|
226
246
|
- test/interface_type_builder_test.rb
|
227
247
|
- test/lib/Makefile.am
|
228
248
|
- test/lib/autogen.sh
|
229
249
|
- test/lib/configure.ac
|
230
250
|
- test/lib/m4/jhflags.m4
|
231
251
|
- test/module_builder_test.rb
|
232
|
-
- test/object_type_builder_test.rb
|
233
252
|
- test/test_helper.rb
|
234
253
|
- test/type_builder_test.rb
|
254
|
+
- test/unintrospectable_type_builder_test.rb
|
255
|
+
- test/unit/builder_test.rb
|
256
|
+
- test/unit/callback_helper_test.rb
|
257
|
+
- test/unit/constant_builder_test.rb
|
258
|
+
- test/unit/i_constant_info_test.rb
|
259
|
+
- test/unit/in_out_pointer_test.rb
|
260
|
+
- test/unit/in_pointer_test.rb
|
261
|
+
- test/unit/object_type_builder_test.rb
|
262
|
+
has_rdoc:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module GirFFI
|
2
|
-
module Builder
|
3
|
-
class DynamicType
|
4
|
-
CACHE = {}
|
5
|
-
|
6
|
-
def initialize gtype
|
7
|
-
@gtype = gtype
|
8
|
-
end
|
9
|
-
|
10
|
-
def build_class
|
11
|
-
CACHE[@gtype] ||= Class.new(parent).tap do |klass|
|
12
|
-
interfaces.each do |iface|
|
13
|
-
klass.class_eval do
|
14
|
-
include iface
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def parent
|
23
|
-
parent_type = ::GObject.type_parent @gtype
|
24
|
-
info = gir.find_by_gtype(parent_type)
|
25
|
-
GirFFI::Builder.build_class info
|
26
|
-
end
|
27
|
-
|
28
|
-
def interfaces
|
29
|
-
iface_types = ::GObject.type_interfaces @gtype
|
30
|
-
iface_types.map do |gtype|
|
31
|
-
info = gir.find_by_gtype gtype
|
32
|
-
GirFFI::Builder.build_class info
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def gir
|
37
|
-
@gir ||= GirFFI::IRepository.default
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/generated_gio_test.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
# Tests generated methods and functions in the Gio namespace.
|
4
|
-
class GeneratedGioTest < MiniTest::Spec
|
5
|
-
context "In the generated Gio module" do
|
6
|
-
setup do
|
7
|
-
GirFFI.setup :Gio
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "#file_new_from_path, a method returning an interface," do
|
11
|
-
it "does not throw an error when generated" do
|
12
|
-
assert_nothing_raised {
|
13
|
-
Gio.file_new_for_path('/')
|
14
|
-
}
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns an object of a more specific class" do
|
18
|
-
file = Gio.file_new_for_path('/')
|
19
|
-
refute_instance_of Gio::File, file
|
20
|
-
assert_includes file.class.ancestors, Gio::File
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "the FileInfo class" do
|
25
|
-
context "an instance" do
|
26
|
-
setup do
|
27
|
-
file = Gio.file_new_for_path('/')
|
28
|
-
@fileinfo = file.query_info "*", :none, nil
|
29
|
-
end
|
30
|
-
|
31
|
-
should "hava a working #get_attribute_type method" do
|
32
|
-
type = @fileinfo.get_attribute_type "standard::display-name"
|
33
|
-
assert_equal :string, type
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require File.expand_path('test_helper.rb', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
describe "The generated GObject module" do
|
4
|
-
before do
|
5
|
-
GirFFI.setup :GObject
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#type_interfaces" do
|
9
|
-
it "works, showing that returning an array of GType works" do
|
10
|
-
tp = GObject.type_from_name 'GTypeModule'
|
11
|
-
ifcs = GObject.type_interfaces tp
|
12
|
-
assert_equal 1, ifcs.size
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|