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
data/test/run-test.rb ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2012 Ruby-GNOME2 Project Team
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ ruby_gnome2_base = File.join(File.dirname(__FILE__), "..", "..")
20
+ ruby_gnome2_base = File.expand_path(ruby_gnome2_base)
21
+
22
+ glib_base = File.join(ruby_gnome2_base, "glib2")
23
+ gobject_introspection_base = File.join(ruby_gnome2_base, "gobject-introspection")
24
+
25
+ modules = [
26
+ [glib_base, "glib2"],
27
+ [gobject_introspection_base, "gobject-introspection"]
28
+ ]
29
+ modules.each do |target, module_name|
30
+ if system("which make > /dev/null")
31
+ `make -C #{target.dump} > /dev/null` or exit(false)
32
+ end
33
+ $LOAD_PATH.unshift(File.join(target, "ext", module_name))
34
+ $LOAD_PATH.unshift(File.join(target, "lib"))
35
+ end
36
+
37
+ $LOAD_PATH.unshift(File.join(glib_base, "test"))
38
+ require "glib-test-init"
39
+
40
+ $LOAD_PATH.unshift(File.join(gobject_introspection_base, "test"))
41
+ require "gobject-introspection-test-utils"
42
+
43
+ require "gobject-introspection"
44
+
45
+ exit Test::Unit::AutoRunner.run(true)
@@ -0,0 +1,68 @@
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 TestArgInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @callable_info = @repository.find("GObject", "signal_name")
22
+ @info = @callable_info[0]
23
+ end
24
+
25
+ def test_direction
26
+ assert_equal(GObjectIntrospection::Direction::IN,
27
+ @info.direction)
28
+ end
29
+
30
+ def test_caller_allocate?
31
+ assert_false(@info.caller_allocates?)
32
+ end
33
+
34
+ def test_return_value?
35
+ assert_false(@info.return_value?)
36
+ end
37
+
38
+ def test_optional?
39
+ assert_false(@info.optional?)
40
+ end
41
+
42
+ def test_may_be_null?
43
+ assert_false(@info.may_be_null?)
44
+ end
45
+
46
+ def test_ownership_transfer
47
+ assert_equal(GObjectIntrospection::Transfer::NOTHING,
48
+ @info.ownership_transfer)
49
+ end
50
+
51
+ def test_scope
52
+ assert_equal(GObjectIntrospection::ScopeType::INVALID,
53
+ @info.scope)
54
+ end
55
+
56
+ def test_closure
57
+ assert_equal(-1, @info.closure)
58
+ end
59
+
60
+ def test_destroy
61
+ assert_equal(-1, @info.destroy)
62
+ end
63
+
64
+ def test_type
65
+ assert_kind_of(GObjectIntrospection::TypeInfo,
66
+ @info.type)
67
+ end
68
+ end
@@ -0,0 +1,31 @@
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 TestBaseInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @info = @repository.find("GObject", "Object")
22
+ end
23
+
24
+ def test_name
25
+ assert_equal("Object", @info.name)
26
+ end
27
+
28
+ def test_namespace
29
+ assert_equal("GObject", @info.namespace)
30
+ end
31
+ end
@@ -0,0 +1,21 @@
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 TestBoxedInfo < Test::Unit::TestCase
18
+ def setup
19
+ # TODO: find BoxedInfo
20
+ end
21
+ end
@@ -0,0 +1,49 @@
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 TestCallableInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @info = @repository.find("GObject", "signal_name")
22
+ end
23
+
24
+ def test_return_type
25
+ assert_kind_of(GObjectIntrospection::TypeInfo,
26
+ @info.return_type)
27
+ end
28
+
29
+ def test_caller_owns
30
+ assert_equal(GObjectIntrospection::Transfer::NOTHING,
31
+ @info.caller_owns)
32
+ end
33
+
34
+ def test_may_return_null?
35
+ assert_false(@info.may_return_null?)
36
+ end
37
+
38
+ def test_n_args
39
+ assert_equal(1, @info.n_args)
40
+ end
41
+
42
+ def test_aref
43
+ assert_equal("signal_id", @info[0].name)
44
+ end
45
+
46
+ def test_args
47
+ assert_equal(["signal_id"], @info.args.collect(&:name))
48
+ end
49
+ end
@@ -0,0 +1,29 @@
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 TestCallbackInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @info = @repository.find("Gio", "AsyncReadyCallback")
22
+ end
23
+
24
+ def test_name
25
+ assert_equal(GObjectIntrospection::Transfer::NOTHING,
26
+ @info.caller_owns)
27
+ end
28
+ end
29
+
@@ -0,0 +1,24 @@
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 TestConstantInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ # TODO: find ConstantInfo
22
+ # @info = @repository.find("GObject", "Object")
23
+ end
24
+ end
@@ -0,0 +1,56 @@
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 TestEnumInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @info = @repository.find("Gio", "ResourceError")
22
+ end
23
+
24
+ def test_n_values
25
+ assert_equal(2, @info.n_values)
26
+ end
27
+
28
+ def test_value
29
+ assert_kind_of(GObjectIntrospection::ValueInfo,
30
+ @info.get_value(0))
31
+ end
32
+
33
+ def test_values
34
+ assert_equal([GObjectIntrospection::ValueInfo] * @info.n_values,
35
+ @info.values.collect(&:class))
36
+ end
37
+
38
+ def test_n_methods
39
+ assert_equal(1, @info.n_methods)
40
+ end
41
+
42
+ def test_method
43
+ assert_kind_of(GObjectIntrospection::FunctionInfo,
44
+ @info.get_method(0))
45
+ end
46
+
47
+ def test_methods
48
+ assert_equal([GObjectIntrospection::FunctionInfo] * @info.n_methods,
49
+ @info.methods.collect(&:class))
50
+ end
51
+
52
+ def test_storage_type
53
+ assert_equal(GObjectIntrospection::TypeTag::UINT32,
54
+ @info.storage_type)
55
+ end
56
+ end
@@ -0,0 +1,42 @@
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 TestFieldInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("Gio")
21
+ @object_info = @repository.find("Gio", "FileOutputStream")
22
+ @info = @object_info.get_field(0)
23
+ end
24
+
25
+ def test_flags
26
+ assert_equal(GObjectIntrospection::FieldInfoFlags::READABLE,
27
+ @info.flags)
28
+ end
29
+
30
+ def test_size
31
+ assert_equal(0, @info.size)
32
+ end
33
+
34
+ def test_offset
35
+ assert_equal(0, @info.offset)
36
+ end
37
+
38
+ def test_type
39
+ assert_kind_of(GObjectIntrospection::TypeInfo,
40
+ @info.type)
41
+ end
42
+ end
@@ -0,0 +1,27 @@
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 TestFlagsInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ end
22
+
23
+ def test_class
24
+ assert_kind_of(GObjectIntrospection::FlagsInfo,
25
+ @repository.find("GObject", "SignalFlags"))
26
+ end
27
+ 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 TestFunctionInfo < Test::Unit::TestCase
18
+ def setup
19
+ @repository = GObjectIntrospection::Repository.default
20
+ @repository.require("GObject")
21
+ @info = @repository.find("GObject", "signal_name")
22
+ end
23
+
24
+ def test_symbol
25
+ assert_equal("g_signal_name", @info.symbol)
26
+ end
27
+
28
+ def test_flags
29
+ assert_equal(GObjectIntrospection::FunctionInfoFlags.new(0),
30
+ @info.flags)
31
+ end
32
+
33
+ def test_invoke
34
+ assert_equal("notify", @info.invoke(1))
35
+ end
36
+ end
37
+