glib2 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/glib2/rbglib.c +1 -1
- data/ext/glib2/rbglib.h +6 -5
- data/ext/glib2/rbglib_error.c +90 -22
- data/ext/glib2/rbgobj_type.c +15 -10
- data/ext/glib2/rbgutil.h +10 -2
- data/test/test_key_file.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eb848d80c98299853e48020a8dd40d75621e5c8
|
4
|
+
data.tar.gz: e3adcc8d05626b832fbdadd7ab792f4d8bdd8cd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acf367073537e5e0d7428196406187e463ef5e8f055d3313c6ecba10ed7e9995151368f5dc285b380c200df0034ea342f2a8220b881d86d194d413a5e8e9e6cc
|
7
|
+
data.tar.gz: 54aebddcd2bdf934eabb00a771fd691a8f0384ff275754b38aa95c69dfeea5074688315f02c7148abc098d2de20f032f69853243d252e2adde57c2bf01b51176
|
data/Rakefile
CHANGED
@@ -72,7 +72,7 @@ package = GNOME2Package.new do |_package|
|
|
72
72
|
:name => "gnutls",
|
73
73
|
:download_base_url => "ftp://ftp.gnutls.org/gcrypt/gnutls/v3.2",
|
74
74
|
:label => "GnuTLS",
|
75
|
-
:version => "3.2.
|
75
|
+
:version => "3.2.12",
|
76
76
|
:compression_method => "xz",
|
77
77
|
:windows => {
|
78
78
|
:configure_args => [
|
data/ext/glib2/rbglib.c
CHANGED
data/ext/glib2/rbglib.h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
2
|
/*
|
3
|
-
* Copyright (C) 2011-
|
3
|
+
* Copyright (C) 2011-2014 Ruby-GNOME2 Project Team
|
4
4
|
* Copyright (C) 2002-2005 Ruby-GNOME2 Project
|
5
5
|
* Copyright (C) 2002,2003 Masahiro Sakai
|
6
6
|
*
|
@@ -20,7 +20,8 @@
|
|
20
20
|
* MA 02110-1301 USA
|
21
21
|
*/
|
22
22
|
|
23
|
-
#include <glib.h>
|
23
|
+
#include <glib-object.h>
|
24
|
+
|
24
25
|
#include "ruby.h"
|
25
26
|
|
26
27
|
#include "rbglibdeprecated.h"
|
@@ -34,7 +35,7 @@ extern "C" {
|
|
34
35
|
#endif /* __cplusplus */
|
35
36
|
|
36
37
|
#define RBGLIB_MAJOR_VERSION 2
|
37
|
-
#define RBGLIB_MINOR_VERSION
|
38
|
+
#define RBGLIB_MINOR_VERSION 2
|
38
39
|
#define RBGLIB_MICRO_VERSION 0
|
39
40
|
|
40
41
|
#ifndef RSTRING_PTR
|
@@ -123,7 +124,7 @@ extern "C" {
|
|
123
124
|
#define G_DEF_ERROR(domain, name, module, parent, gtype) \
|
124
125
|
rbgerr_define_gerror(domain, name, module, parent, gtype)
|
125
126
|
#define G_DEF_ERROR2(domain, name, module, parent) \
|
126
|
-
rbgerr_define_gerror(domain, name, module, parent,
|
127
|
+
rbgerr_define_gerror(domain, name, module, parent, G_TYPE_INVALID)
|
127
128
|
|
128
129
|
#if defined(G_PLATFORM_WIN32) && !defined(RUBY_GLIB2_STATIC_COMPILATION)
|
129
130
|
# ifdef RUBY_GLIB2_COMPILATION
|
@@ -187,7 +188,7 @@ extern void rbg_scan_options(VALUE options, ...);
|
|
187
188
|
|
188
189
|
/* rbgerror.h */
|
189
190
|
extern VALUE rbgerr_gerror2exception(GError *error);
|
190
|
-
extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent,
|
191
|
+
extern VALUE rbgerr_define_gerror(GQuark domain, const gchar* name, VALUE module, VALUE parent, GType gtype);
|
191
192
|
|
192
193
|
extern VALUE rbglib_int64_to_num(guint64 val);
|
193
194
|
extern VALUE rbglib_uint64_to_num(guint64 val);
|
data/ext/glib2/rbglib_error.c
CHANGED
@@ -24,8 +24,10 @@
|
|
24
24
|
|
25
25
|
static ID id_code;
|
26
26
|
static ID id_domain;
|
27
|
+
static ID id_code_classes;
|
27
28
|
static VALUE gerror_table;
|
28
29
|
static VALUE generic_error;
|
30
|
+
static VALUE error_info;
|
29
31
|
|
30
32
|
VALUE
|
31
33
|
rbgerr_gerror2exception(GError *error)
|
@@ -40,6 +42,16 @@ rbgerr_gerror2exception(GError *error)
|
|
40
42
|
exception_klass = rb_hash_aref(gerror_table, UINT2NUM(error->domain));
|
41
43
|
if (NIL_P(exception_klass)) {
|
42
44
|
exception_klass = generic_error;
|
45
|
+
} else {
|
46
|
+
VALUE code_class = Qnil;
|
47
|
+
VALUE code_classes;
|
48
|
+
code_classes = rb_ivar_get(exception_klass, id_code_classes);
|
49
|
+
if (!NIL_P(code_classes)) {
|
50
|
+
code_class = rb_hash_aref(code_classes, INT2NUM(error->code));
|
51
|
+
}
|
52
|
+
if (!NIL_P(code_class)) {
|
53
|
+
exception_klass = code_class;
|
54
|
+
}
|
43
55
|
}
|
44
56
|
exc = rb_exc_new_str(exception_klass, CSTR2RVAL(error->message));
|
45
57
|
rb_ivar_set(exc, id_domain, CSTR2RVAL(g_quark_to_string(error->domain)));
|
@@ -48,38 +60,90 @@ rbgerr_gerror2exception(GError *error)
|
|
48
60
|
return exc;
|
49
61
|
}
|
50
62
|
|
63
|
+
static gchar *
|
64
|
+
nick_to_constant_name(const gchar *nick)
|
65
|
+
{
|
66
|
+
GString *constant_name;
|
67
|
+
const gchar *current;
|
68
|
+
|
69
|
+
constant_name = g_string_new(NULL);
|
70
|
+
|
71
|
+
for (current = nick; *current; current++) {
|
72
|
+
if (*current == '-') {
|
73
|
+
g_string_append_c(constant_name, '_');
|
74
|
+
} else {
|
75
|
+
g_string_append_c(constant_name, g_ascii_toupper(*current));
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return g_string_free(constant_name, FALSE);
|
80
|
+
}
|
81
|
+
|
82
|
+
static gchar *
|
83
|
+
nick_to_class_name(const gchar *nick)
|
84
|
+
{
|
85
|
+
GString *class_name;
|
86
|
+
const gchar *current;
|
87
|
+
gboolean to_upper = TRUE;
|
88
|
+
|
89
|
+
class_name = g_string_new(NULL);
|
90
|
+
|
91
|
+
for (current = nick; *current; current++) {
|
92
|
+
if (to_upper) {
|
93
|
+
g_string_append_c(class_name, g_ascii_toupper(*current));
|
94
|
+
to_upper = FALSE;
|
95
|
+
} else if (*current == '-') {
|
96
|
+
to_upper = TRUE;
|
97
|
+
} else {
|
98
|
+
g_string_append_c(class_name, *current);
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
return g_string_free(class_name, FALSE);
|
103
|
+
}
|
104
|
+
|
51
105
|
VALUE
|
52
|
-
rbgerr_define_gerror(GQuark domain, const gchar *name, VALUE module, VALUE parent,
|
106
|
+
rbgerr_define_gerror(GQuark domain, const gchar *name, VALUE module, VALUE parent, GType gtype)
|
53
107
|
{
|
54
|
-
VALUE
|
55
|
-
|
56
|
-
rb_funcall(klass, rbgutil_id_module_eval, 1, CSTR2RVAL("def domain; @domain; end\n"));
|
108
|
+
VALUE error_class;
|
109
|
+
VALUE code_classes;
|
57
110
|
|
58
|
-
|
111
|
+
error_class = rb_define_class_under(module, name, parent);
|
112
|
+
rb_include_module(error_class, error_info);
|
59
113
|
|
60
|
-
|
114
|
+
rb_hash_aset(gerror_table, UINT2NUM(domain), error_class);
|
115
|
+
|
116
|
+
code_classes = rb_hash_new();
|
117
|
+
rb_ivar_set(error_class, id_code_classes, code_classes);
|
118
|
+
|
119
|
+
if (gtype != G_TYPE_INVALID) {
|
61
120
|
GEnumClass* gclass = g_type_class_ref(gtype);
|
62
121
|
guint i;
|
63
122
|
|
64
123
|
for (i = 0; i < gclass->n_values; i++) {
|
124
|
+
VALUE code_class;
|
65
125
|
GEnumValue* entry = &(gclass->values[i]);
|
66
|
-
gchar*
|
67
|
-
gchar*
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
126
|
+
gchar *code_constant_name;
|
127
|
+
gchar *code_class_name;
|
128
|
+
|
129
|
+
code_constant_name = nick_to_constant_name(entry->value_nick);
|
130
|
+
rbgobj_define_const(error_class,
|
131
|
+
code_constant_name,
|
132
|
+
INT2NUM(entry->value));
|
133
|
+
g_free(code_constant_name);
|
134
|
+
|
135
|
+
code_class_name = nick_to_class_name(entry->value_nick);
|
136
|
+
code_class = rb_define_class_under(error_class,
|
137
|
+
code_class_name,
|
138
|
+
error_class);
|
139
|
+
g_free(code_class_name);
|
140
|
+
rb_hash_aset(code_classes, INT2NUM(entry->value), code_class);
|
77
141
|
}
|
78
|
-
|
79
|
-
g_type_class_unref(gclass);
|
142
|
+
|
143
|
+
g_type_class_unref(gclass);
|
80
144
|
}
|
81
145
|
|
82
|
-
return
|
146
|
+
return error_class;
|
83
147
|
}
|
84
148
|
|
85
149
|
void
|
@@ -87,10 +151,14 @@ Init_glib_error(void)
|
|
87
151
|
{
|
88
152
|
id_code = rb_intern("@code");
|
89
153
|
id_domain = rb_intern("@domain");
|
154
|
+
id_code_classes = rb_intern("@code_classes");
|
90
155
|
gerror_table = rb_hash_new();
|
91
156
|
rb_global_variable(&gerror_table);
|
92
157
|
|
158
|
+
error_info = rb_define_module_under(mGLib, "ErrorInfo");
|
159
|
+
rb_define_attr(error_info, "code", TRUE, FALSE);
|
160
|
+
rb_define_attr(error_info, "domain", TRUE, FALSE);
|
161
|
+
|
93
162
|
generic_error = rb_define_class_under(mGLib, "Error", rb_eRuntimeError);
|
94
|
-
|
95
|
-
rb_funcall(generic_error, rbgutil_id_module_eval, 1, CSTR2RVAL("def domain; @domain; end\n"));
|
163
|
+
rb_include_module(generic_error, error_info);
|
96
164
|
}
|
data/ext/glib2/rbgobj_type.c
CHANGED
@@ -266,22 +266,27 @@ const RGObjClassInfo *
|
|
266
266
|
rbgobj_lookup_class_by_gtype_full(GType gtype, VALUE parent,
|
267
267
|
gboolean create_class)
|
268
268
|
{
|
269
|
+
const RGObjClassInfo *info;
|
269
270
|
RGObjClassByGtypeData data;
|
270
271
|
|
272
|
+
info = rbgobj_lookup_class_by_gtype_without_lock(gtype, parent, FALSE);
|
273
|
+
if (info) {
|
274
|
+
return info;
|
275
|
+
}
|
276
|
+
|
277
|
+
if (!create_class) {
|
278
|
+
return NULL;
|
279
|
+
}
|
280
|
+
|
271
281
|
data.gtype = gtype;
|
272
282
|
data.parent = parent;
|
273
283
|
data.create_class = create_class;
|
274
284
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
(VALUE)&data);
|
281
|
-
} else {
|
282
|
-
return rbgobj_lookup_class_by_gtype_without_lock(gtype, parent,
|
283
|
-
create_class);
|
284
|
-
}
|
285
|
+
rb_funcall(lookup_class_mutex, id_lock, 0);
|
286
|
+
return (RGObjClassInfo *)rb_ensure(rbgobj_lookup_class_by_gtype_body,
|
287
|
+
(VALUE)&data,
|
288
|
+
rbgobj_lookup_class_by_gtype_ensure,
|
289
|
+
(VALUE)&data);
|
285
290
|
}
|
286
291
|
|
287
292
|
VALUE
|
data/ext/glib2/rbgutil.h
CHANGED
@@ -66,11 +66,17 @@ extern "C" {
|
|
66
66
|
#define RG_REG_SYMBOL_GETTER(name) \
|
67
67
|
rbgobj_register_property_getter(CLASS2GTYPE(RG_TARGET_NAMESPACE), name, rbgutil_sym_g2r_func)
|
68
68
|
|
69
|
+
#define RG_REPLACE_SET_PROPERTY(name, args) \
|
70
|
+
G_REPLACE_SET_PROPERTY(RG_TARGET_NAMESPACE, #name, rg_set_ ## name, args)
|
71
|
+
#define RG_REPLACE_GET_PROPERTY(name, args) \
|
72
|
+
G_REPLACE_GET_PROPERTY(RG_TARGET_NAMESPACE, #name, rg_get_ ## name, args)
|
73
|
+
#define RG_REPLACE_ACTION(name, args) \
|
74
|
+
G_REPLACE_ACTION(RG_TARGET_NAMESPACE, #name, rg_ ## name, args)
|
75
|
+
|
69
76
|
#define G_REPLACE_SET_PROPERTY(klass, name, function, args) \
|
70
77
|
rb_undef_method(klass, "set_" name); \
|
71
|
-
rb_define_method(klass, "set_" name, function, args); \
|
72
78
|
rb_undef_method(klass, name "="); \
|
73
|
-
|
79
|
+
rbg_define_method(klass, "set_" name, function, args)
|
74
80
|
|
75
81
|
#define G_REPLACE_GET_PROPERTY(klass, name, function, args) \
|
76
82
|
rb_undef_method(klass, name); \
|
@@ -98,6 +104,8 @@ extern void rbgutil_stop_callback_dispatch_thread(void);
|
|
98
104
|
extern VALUE rbgutil_string_set_utf8_encoding(VALUE string);
|
99
105
|
extern gboolean rbgutil_key_equal(VALUE rb_string, const char *key);
|
100
106
|
|
107
|
+
extern const gchar *rbg_inspect(VALUE object);
|
108
|
+
|
101
109
|
/*< protected >*/
|
102
110
|
RUBY_GLIB2_VAR ID rbgutil_id_module_eval;
|
103
111
|
extern void rbgutil_glibid_r2g_func(VALUE from, GValue* to);
|
data/test/test_key_file.rb
CHANGED
@@ -9,20 +9,20 @@ class TestGLibKeyFile < Test::Unit::TestCase
|
|
9
9
|
only_glib_version(2, 14, 0)
|
10
10
|
|
11
11
|
key_file = GLib::KeyFile.new
|
12
|
-
assert_raise(GLib::KeyFileError) do
|
12
|
+
assert_raise(GLib::KeyFileError::NotFound) do
|
13
13
|
key_file.load_from_dirs("non-existent")
|
14
14
|
end
|
15
15
|
|
16
16
|
temp = Tempfile.new("key-file")
|
17
17
|
base_name = File.basename(temp.path)
|
18
18
|
search_dirs = [File.dirname(temp.path)]
|
19
|
-
assert_raise(GLib::KeyFileError) do
|
19
|
+
assert_raise(GLib::KeyFileError::NotFound) do
|
20
20
|
key_file.load_from_dirs("non-existent", search_dirs)
|
21
21
|
end
|
22
22
|
if GLib.check_version?(2, 31, 2)
|
23
23
|
assert_equal(temp.path, key_file.load_from_dirs(base_name, search_dirs))
|
24
24
|
else
|
25
|
-
assert_raise(GLib::KeyFileError) do
|
25
|
+
assert_raise(GLib::KeyFileError::NotFound) do
|
26
26
|
key_file.load_from_dirs(base_name, search_dirs)
|
27
27
|
end
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Ruby-GNOME2 Project Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pkg-config
|