gobject-introspection 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/Rakefile +50 -0
  2. data/ext/gobject-introspection/extconf.rb +97 -0
  3. data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
  4. data/ext/gobject-introspection/rb-gi-argument.c +223 -0
  5. data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
  6. data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
  7. data/ext/gobject-introspection/rb-gi-callable-info.c +124 -0
  8. data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
  9. data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
  10. data/ext/gobject-introspection/rb-gi-constructor-info.c +82 -0
  11. data/ext/gobject-introspection/rb-gi-conversions.h +95 -0
  12. data/ext/gobject-introspection/rb-gi-enum-info.c +145 -0
  13. data/ext/gobject-introspection/rb-gi-field-info.c +149 -0
  14. data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
  15. data/ext/gobject-introspection/rb-gi-function-info.c +199 -0
  16. data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
  17. data/ext/gobject-introspection/rb-gi-loader.c +61 -0
  18. data/ext/gobject-introspection/rb-gi-method-info.c +66 -0
  19. data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
  20. data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
  21. data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
  22. data/ext/gobject-introspection/rb-gi-repository.c +164 -0
  23. data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
  24. data/ext/gobject-introspection/rb-gi-struct-info.c +183 -0
  25. data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
  26. data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
  27. data/ext/gobject-introspection/rb-gi-types.h +71 -0
  28. data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
  29. data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
  30. data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
  31. data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
  32. data/ext/gobject-introspection/rb-gobject-introspection.c +42 -0
  33. data/ext/gobject-introspection/rb-gobject-introspection.h +105 -0
  34. data/extconf.rb +71 -0
  35. data/lib/gobject-introspection.rb +39 -0
  36. data/lib/gobject-introspection/collection-reader.rb +34 -0
  37. data/lib/gobject-introspection/loader.rb +148 -0
  38. data/lib/gobject-introspection/object-info.rb +33 -0
  39. data/lib/gobject-introspection/repository.rb +32 -0
  40. data/lib/gobject-introspection/struct-info.rb +28 -0
  41. data/sample/clutter-basic-actor.rb +132 -0
  42. data/sample/clutter.rb +29 -0
  43. data/test/gobject-introspection-test-utils.rb +26 -0
  44. data/test/run-test.rb +45 -0
  45. data/test/test-arg-info.rb +68 -0
  46. data/test/test-base-info.rb +31 -0
  47. data/test/test-boxed-info.rb +21 -0
  48. data/test/test-callable-info.rb +49 -0
  49. data/test/test-callback-info.rb +29 -0
  50. data/test/test-constant-info.rb +24 -0
  51. data/test/test-enum-info.rb +56 -0
  52. data/test/test-field-type.rb +42 -0
  53. data/test/test-flags-info.rb +27 -0
  54. data/test/test-function-info.rb +37 -0
  55. data/test/test-interface-info.rb +97 -0
  56. data/test/test-loader.rb +30 -0
  57. data/test/test-object-info.rb +131 -0
  58. data/test/test-property-info.rb +38 -0
  59. data/test/test-registered-type-info.rb +35 -0
  60. data/test/test-repository.rb +59 -0
  61. data/test/test-signal-info.rb +37 -0
  62. data/test/test-struct-info.rb +57 -0
  63. data/test/test-type-info.rb +62 -0
  64. data/test/test-type-tag.rb +29 -0
  65. data/test/test-union-info.rb +21 -0
  66. data/test/test-value-info.rb +28 -0
  67. data/test/test-vfunc-info.rb +42 -0
  68. metadata +162 -0
@@ -0,0 +1,97 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestInterfaceInfo < Test::Unit::TestCase
18
+ include GObjectIntrospectionTestUtils
19
+
20
+ def setup
21
+ @repository = GObjectIntrospection::Repository.default
22
+ @repository.require("Gio")
23
+ @info = @repository.find("Gio", "TlsServerConnection")
24
+ end
25
+
26
+ def test_n_prerequisites
27
+ assert_equal(1, @info.n_prerequisites)
28
+ end
29
+
30
+ def test_prerequisite
31
+ assert_kind_of(GObjectIntrospection::ObjectInfo,
32
+ @info.get_prerequisite(0))
33
+ end
34
+
35
+ def test_n_properties
36
+ assert_equal(1, @info.n_properties)
37
+ end
38
+
39
+ def test_propertiy
40
+ assert_kind_of(GObjectIntrospection::PropertyInfo,
41
+ @info.get_property(0))
42
+ end
43
+
44
+ def test_n_methods
45
+ assert_equal(1, @info.n_methods)
46
+ end
47
+
48
+ def test_get_method_n
49
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
50
+ @info.get_method(0))
51
+ end
52
+
53
+ def test_get_method_name
54
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
55
+ @info.get_method("new"))
56
+ end
57
+
58
+ def test_n_signals
59
+ info = @repository.find("Gio", "Volume")
60
+ assert_equal(2, info.n_signals)
61
+ end
62
+
63
+ def test_get_signal_n
64
+ info = @repository.find("Gio", "Volume")
65
+ assert_kind_of(GObjectIntrospection::SignalInfo,
66
+ info.get_signal(0))
67
+ end
68
+
69
+ def test_get_signal_name
70
+ require_version(1, 34, 0)
71
+ info = @repository.find("Gio", "Volume")
72
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
73
+ info.get_signal("changed"))
74
+ end
75
+
76
+ def test_n_vfuncs
77
+ info = @repository.find("Gio", "Volume")
78
+ assert_operator(0, :<, info.n_vfuncs)
79
+ end
80
+
81
+ def test_get_vfunc_n
82
+ info = @repository.find("Gio", "Volume")
83
+ assert_kind_of(GObjectIntrospection::VFuncInfo,
84
+ info.get_vfunc(0))
85
+ end
86
+
87
+ def test_get_vfunc_name
88
+ info = @repository.find("Gio", "Volume")
89
+ assert_kind_of(GObjectIntrospection::VFuncInfo,
90
+ info.get_vfunc("can_eject"))
91
+ end
92
+
93
+ def test_iface_struct
94
+ assert_kind_of(GObjectIntrospection::StructInfo,
95
+ @info.iface_struct)
96
+ end
97
+ end
@@ -0,0 +1,30 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestLoaderInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @info = @repository.find("Gio", "Application")
22
+ @sandbox = Module.new
23
+ end
24
+
25
+ def test_define_class
26
+ gtype = @info.gtype
27
+ GObjectIntrospection::Loader.define_class(gtype, "Application", @sandbox)
28
+ assert_equal(gtype, @sandbox::Application.gtype)
29
+ end
30
+ end
@@ -0,0 +1,131 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestObjectInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @info = @repository.find("Gio", "FileOutputStream")
22
+ end
23
+
24
+ def test_type_name
25
+ assert_equal("GFileOutputStream", @info.type_name)
26
+ end
27
+
28
+ def test_type_init
29
+ assert_equal("g_file_output_stream_get_type", @info.type_init)
30
+ end
31
+
32
+ def test_abstract?
33
+ assert_false(@info.abstract?)
34
+ end
35
+
36
+ def test_fundamental?
37
+ assert_false(@info.fundamental?)
38
+ end
39
+
40
+ def test_parent
41
+ assert_equal("OutputStream", @info.parent.name)
42
+ end
43
+
44
+ def test_n_interfaces
45
+ assert_equal(1, @info.n_interfaces)
46
+ end
47
+
48
+ def test_get_interface
49
+ assert_kind_of(GObjectIntrospection::InterfaceInfo,
50
+ @info.get_interface(0))
51
+ end
52
+
53
+ def test_n_fields
54
+ assert_equal(2, @info.n_fields)
55
+ end
56
+
57
+ def test_get_field
58
+ assert_kind_of(GObjectIntrospection::FieldInfo,
59
+ @info.get_field(0))
60
+ end
61
+
62
+ def test_n_properties
63
+ info = @repository.find("Gio", "BufferedOutputStream")
64
+ assert_equal(2, info.n_properties)
65
+ end
66
+
67
+ def test_get_property
68
+ info = @repository.find("Gio", "BufferedOutputStream")
69
+ assert_kind_of(GObjectIntrospection::PropertyInfo,
70
+ info.get_property(0))
71
+ end
72
+
73
+ def test_n_methods
74
+ assert_equal(4, @info.n_methods)
75
+ end
76
+
77
+ def test_get_method_n
78
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
79
+ @info.get_method(0))
80
+ end
81
+
82
+ def test_get_method_name
83
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
84
+ @info.get_method("get_etag"))
85
+ end
86
+
87
+ def test_n_signals
88
+ info = @repository.find("Gio", "Application")
89
+ assert_equal(5, info.n_signals)
90
+ end
91
+
92
+ def test_get_signal
93
+ info = @repository.find("Gio", "Application")
94
+ assert_kind_of(GObjectIntrospection::SignalInfo,
95
+ info.get_signal(0))
96
+ end
97
+
98
+ def test_n_vfuncs
99
+ assert_equal(9, @info.n_vfuncs)
100
+ end
101
+
102
+ def test_get_vfunc_n
103
+ assert_kind_of(GObjectIntrospection::VFuncInfo,
104
+ @info.get_vfunc(0))
105
+ end
106
+
107
+ def test_get_vfunc_name
108
+ assert_kind_of(GObjectIntrospection::VFuncInfo,
109
+ @info.get_vfunc("can_seek"))
110
+ end
111
+
112
+ def test_n_constants
113
+ assert_equal(0, @info.n_constants)
114
+ end
115
+
116
+ def test_unref_function
117
+ assert_nil(@info.unref_function)
118
+ end
119
+
120
+ def test_ref_function
121
+ assert_nil(@info.ref_function)
122
+ end
123
+
124
+ def test_set_value_function
125
+ assert_nil(@info.set_value_function)
126
+ end
127
+
128
+ def test_get_value_function
129
+ assert_nil(@info.get_value_function)
130
+ end
131
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestPropertyInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @object_info = @repository.find("Gio", "Application")
22
+ @info = @object_info.get_property(0)
23
+ end
24
+
25
+ def test_flags
26
+ assert_equal(GLib::Param::WRITABLE, @info.flags)
27
+ end
28
+
29
+ def test_type
30
+ assert_kind_of(GObjectIntrospection::TypeInfo,
31
+ @info.type)
32
+ end
33
+
34
+ def test_ownership_transfer
35
+ assert_equal(GObjectIntrospection::Transfer::NOTHING,
36
+ @info.ownership_transfer)
37
+ end
38
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestRegisteredTypeInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @info = @repository.find("GObject", "TypePlugin")
22
+ end
23
+
24
+ def test_type_name
25
+ assert_equal("GTypePlugin", @info.type_name)
26
+ end
27
+
28
+ def test_type_init
29
+ assert_equal("g_type_plugin_get_type", @info.type_init)
30
+ end
31
+
32
+ def test_gtype
33
+ assert_equal(GLib::Type.new("GTypePlugin"), @info.gtype)
34
+ end
35
+ end
@@ -0,0 +1,59 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestRepository < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @repository.require("Gio")
22
+ end
23
+
24
+ def test_get_n_infos
25
+ assert_kind_of(Integer, @repository.get_n_infos("GObject"))
26
+ end
27
+
28
+ def test_get_info
29
+ assert_kind_of(GObjectIntrospection::BaseInfo,
30
+ @repository.get_info("GObject", 0))
31
+ end
32
+
33
+ def test_get_dependencies
34
+ assert_equal(["GLib-2.0", "GObject-2.0"].sort,
35
+ @repository.get_dependencies("Gio").sort)
36
+ end
37
+
38
+ def test_loaded_namespaces
39
+ assert_equal(["GLib", "GObject", "Gio"].sort,
40
+ @repository.loaded_namespaces.sort)
41
+ end
42
+
43
+ def test_enumerable
44
+ namespaces = @repository.collect do |info|
45
+ info.namespace
46
+ end
47
+ assert_equal(["GLib", "GObject", "Gio"].sort, namespaces.uniq.sort)
48
+ end
49
+
50
+ def test_find_by_gtype
51
+ info = @repository.find(GLib::Object.gtype)
52
+ assert_equal("Object", info.name)
53
+ end
54
+
55
+ def test_find_by_name
56
+ info = @repository.find("GObject", "Object")
57
+ assert_equal("Object", info.name)
58
+ end
59
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestSignalInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @object_info = @repository.find("Gio", "Application")
22
+ @info = @object_info.get_signal(0)
23
+ end
24
+
25
+ def test_flags
26
+ assert_equal(GLib::SignalFlags::RUN_CLEANUP,
27
+ @info.flags)
28
+ end
29
+
30
+ def test_class_closure
31
+ assert_nil(@info.class_closure)
32
+ end
33
+
34
+ def test_true_stops_emit?
35
+ assert_false(@info.true_stops_emit?)
36
+ end
37
+ end
@@ -0,0 +1,57 @@
1
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ class TestStructInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @info = @repository.find("GObject", "Value")
22
+ end
23
+
24
+ def test_n_fields
25
+ assert_equal(2, @info.n_fields)
26
+ end
27
+
28
+ def test_get_field
29
+ assert_kind_of(GObjectIntrospection::FieldInfo,
30
+ @info.get_field(0))
31
+ end
32
+
33
+ def test_n_methods
34
+ assert_equal(62, @info.n_methods)
35
+ end
36
+
37
+ def test_get_method
38
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
39
+ @info.get_method(0))
40
+ end
41
+
42
+ def test_size
43
+ assert_equal(24, @info.size)
44
+ end
45
+
46
+ def test_alignment
47
+ assert_equal(8, @info.alignment)
48
+ end
49
+
50
+ def test_gtype_struct?
51
+ assert_false(@info.gtype_struct?)
52
+ end
53
+
54
+ def test_foreign?
55
+ assert_false(@info.foreign?)
56
+ end
57
+ end