gobject-introspection 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +50 -0
- data/ext/gobject-introspection/extconf.rb +97 -0
- data/ext/gobject-introspection/rb-gi-arg-info.c +151 -0
- data/ext/gobject-introspection/rb-gi-argument.c +223 -0
- data/ext/gobject-introspection/rb-gi-base-info.c +218 -0
- data/ext/gobject-introspection/rb-gi-boxed-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-callable-info.c +124 -0
- data/ext/gobject-introspection/rb-gi-callback-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-constant-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-constructor-info.c +82 -0
- data/ext/gobject-introspection/rb-gi-conversions.h +95 -0
- data/ext/gobject-introspection/rb-gi-enum-info.c +145 -0
- data/ext/gobject-introspection/rb-gi-field-info.c +149 -0
- data/ext/gobject-introspection/rb-gi-flags-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-function-info.c +199 -0
- data/ext/gobject-introspection/rb-gi-interface-info.c +222 -0
- data/ext/gobject-introspection/rb-gi-loader.c +61 -0
- data/ext/gobject-introspection/rb-gi-method-info.c +66 -0
- data/ext/gobject-introspection/rb-gi-object-info.c +345 -0
- data/ext/gobject-introspection/rb-gi-property-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-registered-type-info.c +86 -0
- data/ext/gobject-introspection/rb-gi-repository.c +164 -0
- data/ext/gobject-introspection/rb-gi-signal-info.c +77 -0
- data/ext/gobject-introspection/rb-gi-struct-info.c +183 -0
- data/ext/gobject-introspection/rb-gi-type-info.c +143 -0
- data/ext/gobject-introspection/rb-gi-type-tag.c +43 -0
- data/ext/gobject-introspection/rb-gi-types.h +71 -0
- data/ext/gobject-introspection/rb-gi-union-info.c +206 -0
- data/ext/gobject-introspection/rb-gi-unresolved-info.c +48 -0
- data/ext/gobject-introspection/rb-gi-value-info.c +57 -0
- data/ext/gobject-introspection/rb-gi-vfunc-info.c +91 -0
- data/ext/gobject-introspection/rb-gobject-introspection.c +42 -0
- data/ext/gobject-introspection/rb-gobject-introspection.h +105 -0
- data/extconf.rb +71 -0
- data/lib/gobject-introspection.rb +39 -0
- data/lib/gobject-introspection/collection-reader.rb +34 -0
- data/lib/gobject-introspection/loader.rb +148 -0
- data/lib/gobject-introspection/object-info.rb +33 -0
- data/lib/gobject-introspection/repository.rb +32 -0
- data/lib/gobject-introspection/struct-info.rb +28 -0
- data/sample/clutter-basic-actor.rb +132 -0
- data/sample/clutter.rb +29 -0
- data/test/gobject-introspection-test-utils.rb +26 -0
- data/test/run-test.rb +45 -0
- data/test/test-arg-info.rb +68 -0
- data/test/test-base-info.rb +31 -0
- data/test/test-boxed-info.rb +21 -0
- data/test/test-callable-info.rb +49 -0
- data/test/test-callback-info.rb +29 -0
- data/test/test-constant-info.rb +24 -0
- data/test/test-enum-info.rb +56 -0
- data/test/test-field-type.rb +42 -0
- data/test/test-flags-info.rb +27 -0
- data/test/test-function-info.rb +37 -0
- data/test/test-interface-info.rb +97 -0
- data/test/test-loader.rb +30 -0
- data/test/test-object-info.rb +131 -0
- data/test/test-property-info.rb +38 -0
- data/test/test-registered-type-info.rb +35 -0
- data/test/test-repository.rb +59 -0
- data/test/test-signal-info.rb +37 -0
- data/test/test-struct-info.rb +57 -0
- data/test/test-type-info.rb +62 -0
- data/test/test-type-tag.rb +29 -0
- data/test/test-union-info.rb +21 -0
- data/test/test-value-info.rb +28 -0
- data/test/test-vfunc-info.rb +42 -0
- metadata +162 -0
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# -*- 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
|
+
$LOAD_PATH.unshift("./../glib2/lib")
|
20
|
+
require "gnome2-raketask"
|
21
|
+
|
22
|
+
package = GNOME2Package.new do |_package|
|
23
|
+
_package.summary = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection."
|
24
|
+
_package.description = "Ruby/GObjectIntrospection is a Ruby binding of GObjectIntrospection."
|
25
|
+
_package.dependency.gem.runtime = ["glib2"]
|
26
|
+
_package.dependency.gem.development = [["test-unit", ">= 2"]]
|
27
|
+
_package.win32.packages = []
|
28
|
+
_package.win32.dependencies = []
|
29
|
+
_package.win32.build_dependencies = ["glib2"]
|
30
|
+
libffi_lib_dir = File.join(_package.win32.package.root_dir, "..",
|
31
|
+
"glib2", "vendor", "local", "lib")
|
32
|
+
libffi_include_dir = File.join(libffi_lib_dir, "libffi-3.0.6", "include")
|
33
|
+
_package.win32.build_packages = [
|
34
|
+
{
|
35
|
+
:name => "gobject-introspection",
|
36
|
+
:download_site => :gnome,
|
37
|
+
:label => "gobject-introspection",
|
38
|
+
:version => "1.35.3",
|
39
|
+
:include_paths => [
|
40
|
+
libffi_include_dir,
|
41
|
+
],
|
42
|
+
:library_paths => [
|
43
|
+
libffi_lib_dir,
|
44
|
+
],
|
45
|
+
:configure_args => [],
|
46
|
+
:compression_method => "xz",
|
47
|
+
},
|
48
|
+
]
|
49
|
+
end
|
50
|
+
package.define_tasks
|
@@ -0,0 +1,97 @@
|
|
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
|
+
require "pathname"
|
20
|
+
|
21
|
+
source_dir = Pathname(__FILE__).dirname
|
22
|
+
base_dir = source_dir.parent.parent.expand_path
|
23
|
+
top_dir = base_dir.parent.expand_path
|
24
|
+
top_build_dir = Pathname(".").parent.parent.parent.expand_path
|
25
|
+
|
26
|
+
mkmf_gnome2_dir = top_dir + "glib2" + 'lib'
|
27
|
+
version_suffix = ""
|
28
|
+
unless mkmf_gnome2_dir.exist?
|
29
|
+
if /(-\d+\.\d+\.\d+)(?:\.\d+)?\z/ =~ base_dir.basename.to_s
|
30
|
+
version_suffix = $1
|
31
|
+
mkmf_gnome2_dir = top_dir + "glib2#{version_suffix}" + 'lib'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
$LOAD_PATH.unshift(mkmf_gnome2_dir.to_s)
|
36
|
+
|
37
|
+
module_name = "gobject_introspection"
|
38
|
+
package_id = "gobject-introspection-1.0"
|
39
|
+
|
40
|
+
begin
|
41
|
+
require "mkmf-gnome2"
|
42
|
+
rescue LoadError
|
43
|
+
require "rubygems"
|
44
|
+
gem "glib2"
|
45
|
+
require "mkmf-gnome2"
|
46
|
+
end
|
47
|
+
|
48
|
+
["glib2"].each do |package|
|
49
|
+
directory = "#{package}#{version_suffix}"
|
50
|
+
build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
|
51
|
+
add_depend_package(package, "#{directory}/ext/#{package}",
|
52
|
+
top_dir.to_s,
|
53
|
+
:top_build_dir => top_build_dir.to_s,
|
54
|
+
:target_build_dir => build_dir)
|
55
|
+
end
|
56
|
+
|
57
|
+
setup_win32(module_name, base_dir)
|
58
|
+
|
59
|
+
unless required_pkg_config_package(package_id,
|
60
|
+
:debian => "libgirepository1.0-dev",
|
61
|
+
:fedora => "gobject-introspection-devel",
|
62
|
+
:homebrew => "gobject-introspection",
|
63
|
+
:macports => "gobject-introspection")
|
64
|
+
exit(false)
|
65
|
+
end
|
66
|
+
|
67
|
+
make_version_header("GI", package_id, ".")
|
68
|
+
|
69
|
+
ruby_headers = ["ruby.h"]
|
70
|
+
have_type("enum ruby_value_type", ruby_headers)
|
71
|
+
|
72
|
+
gi_headers = ["girepository.h"]
|
73
|
+
have_func("g_interface_info_find_signal", gi_headers)
|
74
|
+
|
75
|
+
enum_type_prefix = "gobject-introspection-enum-types"
|
76
|
+
include_paths = PKGConfig.cflags_only_I(package_id)
|
77
|
+
headers = include_paths.split.inject([]) do |result, path|
|
78
|
+
result + Dir.glob(File.join(path.sub(/^-I/, ""), "gi{repository,types}.h"))
|
79
|
+
end
|
80
|
+
glib_mkenums(enum_type_prefix, headers, "G_TYPE_", ["girepository.h"])
|
81
|
+
|
82
|
+
create_pkg_config_file("Ruby/GObjectIntrospection",
|
83
|
+
package_id, ruby_gnome2_version,
|
84
|
+
"ruby-gobject-introspection.pc")
|
85
|
+
|
86
|
+
ensure_objs
|
87
|
+
|
88
|
+
$defs << "-DRUBY_GOBJECT_INTROSPECTION_COMPILATION"
|
89
|
+
create_makefile(module_name)
|
90
|
+
|
91
|
+
pkg_config_dir = with_config("pkg-config-dir")
|
92
|
+
if pkg_config_dir.is_a?(String)
|
93
|
+
File.open("Makefile", "ab") do |makefile|
|
94
|
+
makefile.puts
|
95
|
+
makefile.puts("pkgconfigdir=#{pkg_config_dir}")
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
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,
|
18
|
+
* MA 02110-1301 USA
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include "rb-gobject-introspection.h"
|
22
|
+
|
23
|
+
#define RG_TARGET_NAMESPACE rb_cGIArgInfo
|
24
|
+
#define SELF(self) (RVAL2GI_ARG_INFO(self))
|
25
|
+
|
26
|
+
GType
|
27
|
+
gi_arg_info_get_type(void)
|
28
|
+
{
|
29
|
+
static GType type = 0;
|
30
|
+
if (type == 0) {
|
31
|
+
type = g_boxed_type_register_static("GIArgInfo",
|
32
|
+
(GBoxedCopyFunc)g_base_info_ref,
|
33
|
+
(GBoxedFreeFunc)g_base_info_unref);
|
34
|
+
}
|
35
|
+
return type;
|
36
|
+
}
|
37
|
+
|
38
|
+
static VALUE
|
39
|
+
rg_direction(VALUE self)
|
40
|
+
{
|
41
|
+
GIArgInfo *info;
|
42
|
+
|
43
|
+
info = SELF(self);
|
44
|
+
return GI_DIRECTION2RVAL(g_arg_info_get_direction(info));
|
45
|
+
}
|
46
|
+
|
47
|
+
static VALUE
|
48
|
+
rg_caller_allocates_p(VALUE self)
|
49
|
+
{
|
50
|
+
GIArgInfo *info;
|
51
|
+
|
52
|
+
info = SELF(self);
|
53
|
+
return CBOOL2RVAL(g_arg_info_is_caller_allocates(info));
|
54
|
+
}
|
55
|
+
|
56
|
+
static VALUE
|
57
|
+
rg_return_value_p(VALUE self)
|
58
|
+
{
|
59
|
+
GIArgInfo *info;
|
60
|
+
|
61
|
+
info = SELF(self);
|
62
|
+
return CBOOL2RVAL(g_arg_info_is_return_value(info));
|
63
|
+
}
|
64
|
+
|
65
|
+
static VALUE
|
66
|
+
rg_optional_p(VALUE self)
|
67
|
+
{
|
68
|
+
GIArgInfo *info;
|
69
|
+
|
70
|
+
info = SELF(self);
|
71
|
+
return CBOOL2RVAL(g_arg_info_is_optional(info));
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE
|
75
|
+
rg_may_be_null_p(VALUE self)
|
76
|
+
{
|
77
|
+
GIArgInfo *info;
|
78
|
+
|
79
|
+
info = SELF(self);
|
80
|
+
return CBOOL2RVAL(g_arg_info_may_be_null(info));
|
81
|
+
}
|
82
|
+
|
83
|
+
static VALUE
|
84
|
+
rg_ownership_transfer(VALUE self)
|
85
|
+
{
|
86
|
+
GIArgInfo *info;
|
87
|
+
|
88
|
+
info = SELF(self);
|
89
|
+
return GI_TRANSFER2RVAL(g_arg_info_get_ownership_transfer(info));
|
90
|
+
}
|
91
|
+
|
92
|
+
static VALUE
|
93
|
+
rg_scope(VALUE self)
|
94
|
+
{
|
95
|
+
GIArgInfo *info;
|
96
|
+
|
97
|
+
info = SELF(self);
|
98
|
+
return GI_SCOPE_TYPE2RVAL(g_arg_info_get_scope(info));
|
99
|
+
}
|
100
|
+
|
101
|
+
static VALUE
|
102
|
+
rg_closure(VALUE self)
|
103
|
+
{
|
104
|
+
GIArgInfo *info;
|
105
|
+
|
106
|
+
info = SELF(self);
|
107
|
+
return INT2NUM(g_arg_info_get_closure(info));
|
108
|
+
}
|
109
|
+
|
110
|
+
static VALUE
|
111
|
+
rg_destroy(VALUE self)
|
112
|
+
{
|
113
|
+
GIArgInfo *info;
|
114
|
+
|
115
|
+
info = SELF(self);
|
116
|
+
return INT2NUM(g_arg_info_get_destroy(info));
|
117
|
+
}
|
118
|
+
|
119
|
+
static VALUE
|
120
|
+
rg_type(VALUE self)
|
121
|
+
{
|
122
|
+
GIArgInfo *info;
|
123
|
+
|
124
|
+
info = SELF(self);
|
125
|
+
return GI_BASE_INFO2RVAL_WITH_UNREF(g_arg_info_get_type(info));
|
126
|
+
}
|
127
|
+
|
128
|
+
void
|
129
|
+
rb_gi_arg_info_init(VALUE rb_mGI, VALUE rb_cGIBaseInfo)
|
130
|
+
{
|
131
|
+
VALUE RG_TARGET_NAMESPACE;
|
132
|
+
|
133
|
+
RG_TARGET_NAMESPACE =
|
134
|
+
G_DEF_CLASS_WITH_PARENT(GI_TYPE_ARG_INFO, "ArgInfo", rb_mGI,
|
135
|
+
rb_cGIBaseInfo);
|
136
|
+
|
137
|
+
RG_DEF_METHOD(direction, 0);
|
138
|
+
RG_DEF_METHOD_P(caller_allocates, 0);
|
139
|
+
RG_DEF_METHOD_P(return_value, 0);
|
140
|
+
RG_DEF_METHOD_P(optional, 0);
|
141
|
+
RG_DEF_METHOD_P(may_be_null, 0);
|
142
|
+
RG_DEF_METHOD(ownership_transfer, 0);
|
143
|
+
RG_DEF_METHOD(scope, 0);
|
144
|
+
RG_DEF_METHOD(closure, 0);
|
145
|
+
RG_DEF_METHOD(destroy, 0);
|
146
|
+
RG_DEF_METHOD(type, 0);
|
147
|
+
|
148
|
+
G_DEF_CLASS(G_TYPE_I_DIRECTION, "Direction", rb_mGI);
|
149
|
+
G_DEF_CLASS(G_TYPE_I_SCOPE_TYPE, "ScopeType", rb_mGI);
|
150
|
+
G_DEF_CLASS(G_TYPE_I_TRANSFER, "Transfer", rb_mGI);
|
151
|
+
}
|
@@ -0,0 +1,223 @@
|
|
1
|
+
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
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,
|
18
|
+
* MA 02110-1301 USA
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include "rb-gobject-introspection.h"
|
22
|
+
|
23
|
+
VALUE
|
24
|
+
rb_gi_argument_to_ruby(GIArgument *argument, GITypeInfo *type_info)
|
25
|
+
{
|
26
|
+
VALUE rb_argument = Qnil;
|
27
|
+
|
28
|
+
switch (g_type_info_get_tag(type_info)) {
|
29
|
+
case GI_TYPE_TAG_VOID:
|
30
|
+
rb_argument = Qnil;
|
31
|
+
break;
|
32
|
+
case GI_TYPE_TAG_BOOLEAN:
|
33
|
+
rb_argument = CBOOL2RVAL(argument->v_boolean);
|
34
|
+
break;
|
35
|
+
case GI_TYPE_TAG_INT8:
|
36
|
+
rb_argument = INT2NUM(argument->v_int8);
|
37
|
+
break;
|
38
|
+
case GI_TYPE_TAG_UINT8:
|
39
|
+
rb_argument = UINT2NUM(argument->v_uint8);
|
40
|
+
break;
|
41
|
+
case GI_TYPE_TAG_INT16:
|
42
|
+
rb_argument = INT2NUM(argument->v_int16);
|
43
|
+
break;
|
44
|
+
case GI_TYPE_TAG_UINT16:
|
45
|
+
rb_argument = UINT2NUM(argument->v_uint16);
|
46
|
+
break;
|
47
|
+
case GI_TYPE_TAG_INT32:
|
48
|
+
rb_argument = INT2NUM(argument->v_int32);
|
49
|
+
break;
|
50
|
+
case GI_TYPE_TAG_UINT32:
|
51
|
+
rb_argument = UINT2NUM(argument->v_uint32);
|
52
|
+
break;
|
53
|
+
case GI_TYPE_TAG_INT64:
|
54
|
+
rb_argument = LONG2NUM(argument->v_int64);
|
55
|
+
break;
|
56
|
+
case GI_TYPE_TAG_UINT64:
|
57
|
+
rb_argument = ULONG2NUM(argument->v_uint64);
|
58
|
+
break;
|
59
|
+
case GI_TYPE_TAG_FLOAT:
|
60
|
+
rb_argument = DBL2NUM(argument->v_float);
|
61
|
+
break;
|
62
|
+
case GI_TYPE_TAG_DOUBLE:
|
63
|
+
rb_argument = DBL2NUM(argument->v_double);
|
64
|
+
break;
|
65
|
+
case GI_TYPE_TAG_GTYPE:
|
66
|
+
rb_argument = rbgobj_gtype_new(argument->v_size);
|
67
|
+
break;
|
68
|
+
case GI_TYPE_TAG_UTF8:
|
69
|
+
rb_argument = CSTR2RVAL(argument->v_string);
|
70
|
+
break;
|
71
|
+
case GI_TYPE_TAG_FILENAME:
|
72
|
+
/* TODO: set encoding */
|
73
|
+
rb_argument = CSTR2RVAL(argument->v_string);
|
74
|
+
break;
|
75
|
+
case GI_TYPE_TAG_ARRAY:
|
76
|
+
/* TODO */
|
77
|
+
break;
|
78
|
+
case GI_TYPE_TAG_INTERFACE:
|
79
|
+
{
|
80
|
+
GIBaseInfo *interface_info;
|
81
|
+
GIInfoType interface_type;
|
82
|
+
GType gtype;
|
83
|
+
|
84
|
+
interface_info = g_type_info_get_interface(type_info);
|
85
|
+
interface_type = g_base_info_get_type(interface_info);
|
86
|
+
|
87
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
88
|
+
switch (interface_type) {
|
89
|
+
case GI_INFO_TYPE_ENUM:
|
90
|
+
rb_argument = GENUM2RVAL(argument->v_int32, gtype);
|
91
|
+
break;
|
92
|
+
case GI_INFO_TYPE_FLAGS:
|
93
|
+
rb_argument = GFLAGS2RVAL(argument->v_int32, gtype);
|
94
|
+
break;
|
95
|
+
case GI_INFO_TYPE_OBJECT:
|
96
|
+
rb_argument = GOBJ2RVAL(argument->v_pointer);
|
97
|
+
break;
|
98
|
+
case GI_INFO_TYPE_STRUCT:
|
99
|
+
rb_argument = BOXED2RVAL(argument->v_pointer, gtype);
|
100
|
+
break;
|
101
|
+
}
|
102
|
+
|
103
|
+
g_base_info_unref(interface_info);
|
104
|
+
}
|
105
|
+
break;
|
106
|
+
case GI_TYPE_TAG_GLIST:
|
107
|
+
case GI_TYPE_TAG_GSLIST:
|
108
|
+
case GI_TYPE_TAG_GHASH:
|
109
|
+
/* TODO */
|
110
|
+
break;
|
111
|
+
case GI_TYPE_TAG_ERROR:
|
112
|
+
RG_RAISE_ERROR(argument->v_pointer);
|
113
|
+
break;
|
114
|
+
case GI_TYPE_TAG_UNICHAR:
|
115
|
+
/* TODO */
|
116
|
+
break;
|
117
|
+
default:
|
118
|
+
g_assert_not_reached();
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
|
122
|
+
return rb_argument;
|
123
|
+
}
|
124
|
+
|
125
|
+
GIArgument *
|
126
|
+
rb_gi_argument_from_ruby(GIArgument *argument, GITypeInfo *type_info,
|
127
|
+
VALUE rb_argument)
|
128
|
+
{
|
129
|
+
memset(argument, 0, sizeof(GIArgument));
|
130
|
+
|
131
|
+
switch (g_type_info_get_tag(type_info)) {
|
132
|
+
case GI_TYPE_TAG_VOID:
|
133
|
+
break;
|
134
|
+
case GI_TYPE_TAG_BOOLEAN:
|
135
|
+
argument->v_boolean = RVAL2CBOOL(rb_argument);
|
136
|
+
break;
|
137
|
+
case GI_TYPE_TAG_INT8:
|
138
|
+
argument->v_int8 = NUM2INT(rb_argument);
|
139
|
+
break;
|
140
|
+
case GI_TYPE_TAG_UINT8:
|
141
|
+
argument->v_uint8 = NUM2UINT(rb_argument);
|
142
|
+
break;
|
143
|
+
case GI_TYPE_TAG_INT16:
|
144
|
+
argument->v_int16 = NUM2INT(rb_argument);
|
145
|
+
break;
|
146
|
+
case GI_TYPE_TAG_UINT16:
|
147
|
+
argument->v_uint16 = NUM2UINT(rb_argument);
|
148
|
+
break;
|
149
|
+
case GI_TYPE_TAG_INT32:
|
150
|
+
argument->v_int32 = NUM2INT(rb_argument);
|
151
|
+
break;
|
152
|
+
case GI_TYPE_TAG_UINT32:
|
153
|
+
argument->v_uint32 = NUM2UINT(rb_argument);
|
154
|
+
break;
|
155
|
+
case GI_TYPE_TAG_INT64:
|
156
|
+
argument->v_int64 = NUM2LONG(rb_argument);
|
157
|
+
break;
|
158
|
+
case GI_TYPE_TAG_UINT64:
|
159
|
+
argument->v_uint64 = NUM2ULONG(rb_argument);
|
160
|
+
break;
|
161
|
+
case GI_TYPE_TAG_FLOAT:
|
162
|
+
argument->v_float = NUM2DBL(rb_argument);
|
163
|
+
break;
|
164
|
+
case GI_TYPE_TAG_DOUBLE:
|
165
|
+
argument->v_double = NUM2DBL(rb_argument);
|
166
|
+
break;
|
167
|
+
case GI_TYPE_TAG_GTYPE:
|
168
|
+
/* TODO: support GLib::Type and String as GType name. */
|
169
|
+
argument->v_size = NUM2ULONG(rb_argument);
|
170
|
+
break;
|
171
|
+
case GI_TYPE_TAG_UTF8:
|
172
|
+
/* TODO: support UTF-8 convert like rb_argument.encode("UTF-8"). */
|
173
|
+
argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
|
174
|
+
break;
|
175
|
+
case GI_TYPE_TAG_FILENAME:
|
176
|
+
argument->v_string = (gchar *)RVAL2CSTR(rb_argument);
|
177
|
+
break;
|
178
|
+
case GI_TYPE_TAG_ARRAY:
|
179
|
+
/* TODO */
|
180
|
+
break;
|
181
|
+
case GI_TYPE_TAG_INTERFACE:
|
182
|
+
{
|
183
|
+
GIBaseInfo *interface_info;
|
184
|
+
GIInfoType interface_type;
|
185
|
+
GType gtype;
|
186
|
+
|
187
|
+
interface_info = g_type_info_get_interface(type_info);
|
188
|
+
interface_type = g_base_info_get_type(interface_info);
|
189
|
+
|
190
|
+
gtype = g_registered_type_info_get_g_type(interface_info);
|
191
|
+
switch (interface_type) {
|
192
|
+
case GI_INFO_TYPE_ENUM:
|
193
|
+
argument->v_int32 = RVAL2GENUM(rb_argument, gtype);
|
194
|
+
break;
|
195
|
+
case GI_INFO_TYPE_FLAGS:
|
196
|
+
argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype);
|
197
|
+
break;
|
198
|
+
case GI_INFO_TYPE_OBJECT:
|
199
|
+
argument->v_pointer = RVAL2GOBJ(rb_argument);
|
200
|
+
break;
|
201
|
+
case GI_INFO_TYPE_STRUCT:
|
202
|
+
argument->v_pointer = RVAL2BOXED(rb_argument, gtype);
|
203
|
+
default:
|
204
|
+
break;
|
205
|
+
}
|
206
|
+
|
207
|
+
g_base_info_unref(interface_info);
|
208
|
+
}
|
209
|
+
break;
|
210
|
+
case GI_TYPE_TAG_GLIST:
|
211
|
+
case GI_TYPE_TAG_GSLIST:
|
212
|
+
case GI_TYPE_TAG_GHASH:
|
213
|
+
case GI_TYPE_TAG_ERROR:
|
214
|
+
case GI_TYPE_TAG_UNICHAR:
|
215
|
+
/* TODO */
|
216
|
+
break;
|
217
|
+
default:
|
218
|
+
g_assert_not_reached();
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
|
222
|
+
return argument;
|
223
|
+
}
|