glib2 1.0.0-x86-mingw32 → 1.0.1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +107 -0
- data/ext/glib2/glib2.def +12 -1
- data/ext/glib2/rbglib.c +258 -69
- data/ext/glib2/rbglib.h +25 -5
- data/ext/glib2/rbglib_bookmarkfile.c +507 -519
- data/ext/glib2/rbglib_completion.c +4 -4
- data/ext/glib2/rbglib_error.c +1 -1
- data/ext/glib2/rbglib_i18n.c +1 -10
- data/ext/glib2/rbglib_iochannel.c +5 -1
- data/ext/glib2/rbglib_keyfile.c +103 -114
- data/ext/glib2/rbglib_maincontext.c +45 -13
- data/ext/glib2/rbglib_messages.c +2 -1
- data/ext/glib2/rbglib_shell.c +11 -19
- data/ext/glib2/rbglib_spawn.c +28 -110
- data/ext/glib2/rbglib_utils.c +5 -20
- data/ext/glib2/rbgobj_closure.c +3 -2
- data/ext/glib2/rbgobj_enums.c +37 -17
- data/ext/glib2/rbgobj_object.c +3 -3
- data/ext/glib2/rbgobj_param.c +2 -1
- data/ext/glib2/rbgobj_signal.c +9 -10
- data/ext/glib2/rbgobj_strv.c +9 -32
- data/ext/glib2/rbgobj_type.c +7 -6
- data/ext/glib2/rbgobj_typeinterface.c +142 -142
- data/ext/glib2/rbgobj_value.c +2 -1
- data/ext/glib2/rbgobj_valuearray.c +20 -15
- data/ext/glib2/rbgobj_valuetypes.c +3 -2
- data/ext/glib2/rbgobject.c +12 -12
- data/ext/glib2/rbgprivate.h +4 -0
- data/ext/glib2/rbgutil.h +14 -0
- data/ext/glib2/rbgutil_callback.c +22 -14
- data/lib/1.8/glib2.so +0 -0
- data/lib/1.9/glib2.so +0 -0
- data/lib/glib2.rb +30 -20
- data/lib/mkmf-gnome2.rb +6 -2
- data/test/glib-test-init.rb +1 -0
- metadata +4 -4
data/ChangeLog
CHANGED
@@ -1,3 +1,110 @@
|
|
1
|
+
2011-09-18 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
|
3
|
+
* ext/glib2/rbgutil_callback.c: don't include unistd.h on Win32
|
4
|
+
environment.
|
5
|
+
|
6
|
+
* ext/glib2/rbgutil_callback.c (queue_callback_request): use
|
7
|
+
G_GSSIZE_FORMAT instead of 'z' for portability.
|
8
|
+
|
9
|
+
* lib/glib2.rb (GLib#__add_one_arg_setter): cleanup.
|
10
|
+
|
11
|
+
* ext/glib2/rbgutil_callback.c (queue_callback_request): add
|
12
|
+
missing 'z' for size_t format parameter.
|
13
|
+
|
14
|
+
* lib/glib2.rb (GLib.__add_one_arg_setter): convert method names
|
15
|
+
to String not Symbol to work on Ruby 1.8.
|
16
|
+
|
17
|
+
* test/glib-test-init.rb: require "rubygems".
|
18
|
+
|
19
|
+
* ext/glib2/rbgutil_callback.c (queue_callback_request): suppress
|
20
|
+
a warning. (variable ‘written’ set but not used
|
21
|
+
[-Wunused-but-set-variable])
|
22
|
+
|
23
|
+
* ext/glib2/rbgutil_callback.c, ext/glib2/rbgprivate.h: work
|
24
|
+
rb_errinfo() on Ruby 1.8 in all files.
|
25
|
+
|
26
|
+
* ext/glib2/rbglib.c, ext/glib2/rbglib.h, ext/glib2/glib2.def:
|
27
|
+
rbg_cstr2rval_with_free() -> rbg_cstr2rval_free().
|
28
|
+
|
29
|
+
* ext/glib2/rbglib.c: don't export internal functions.
|
30
|
+
|
31
|
+
* ext/glib2/rbglib.c (rbg_filename_to_ruby_body)
|
32
|
+
(rbg_filename_to_ruby_ensure): don't define on Ruby 1.8.
|
33
|
+
|
34
|
+
* ext/glib2/rbglib.c (rbg_filename_to_ruby): use
|
35
|
+
rb_external_str_new_with_enc().
|
36
|
+
|
37
|
+
* ext/glib2/rbglib.h: 1.0.0 -> 1.0.1.
|
38
|
+
|
39
|
+
2011-09-16 Nikolai Weibull <now@bitwi.se>
|
40
|
+
|
41
|
+
* lib/glib2.rb: Remove unused variable.
|
42
|
+
* ext/glib2/rbglib.c: Don’t use ALLOCA_N() on user-supplied input.
|
43
|
+
* ext/glib2/rbglib.c, ext/glib2/rbglib.h, ext/glib2/glib2.def: Remove
|
44
|
+
rbg_rval2argv() and RVAL2ARGV().
|
45
|
+
* glib2/ext/glib2/rbglib_spawn.c: Use RVAL2STRV() instead of
|
46
|
+
RVAL2ARGV().
|
47
|
+
|
48
|
+
2011-09-15 Nikolai Weibull <now@bitwi.se>
|
49
|
+
|
50
|
+
* ext/glib2/rbgobj_strv.c: Plug memory leak.
|
51
|
+
* ext/glib2/rbgutil.h: Add G_REPLACE_SET_PROPERTY(),
|
52
|
+
G_REPLACE_GET_PROPERTY(), and G_REPLACE_ACTION() macros for replacing
|
53
|
+
automatically defined property getters and setters and actions (from
|
54
|
+
G_SIGNAL_ACTION). These are primarily useful for making it clear why
|
55
|
+
we’re undefining a method and then redefining it.
|
56
|
+
|
57
|
+
2011-09-14 Nikolai Weibull <now@bitwi.se>
|
58
|
+
|
59
|
+
* ext/glib2/rbglib_iochannel.c: Fix broken code under Win32.
|
60
|
+
* ext/glib2/*.c: Fix warnings on Win32.
|
61
|
+
* ext/glib2/glib2.def: Add new externs.
|
62
|
+
|
63
|
+
2011-09-12 Nikolai Weibull <now@bitwi.se>
|
64
|
+
|
65
|
+
* lib/glib2.rb (__add_one_arg_setter): Ruby 1.9-proof this method.
|
66
|
+
* ext/glib2/rbglib.c: Fix coding style.
|
67
|
+
* ext/glib2/rbglib.c: Don’t use StringValue(RARRAY_PTR(ary)[i]), as
|
68
|
+
that changes the Array.
|
69
|
+
* ext/glib2/rbglib.c: Add rbg_strv2rval().
|
70
|
+
* ext/glib2/rbglib.h: Add RVAL2STRV and STRV2RVAL().
|
71
|
+
* ext/glib2/rbgobj_strv.c: Use RVAL2STRV() and STRV2RVAL().
|
72
|
+
* ext/glib2/rbglib.c: Ensure that memory is freed.
|
73
|
+
* ext/glib2/rbglib.h: Add CSTRFILENAME2RVAL().
|
74
|
+
* ext/glib2/rbglib.c: Add rbg_strv2rval_free().
|
75
|
+
* ext/glib2/rbglib.h: Add RVAL2STRV_FREE().
|
76
|
+
|
77
|
+
2011-09-10 Nikolai Weibull <now@bitwi.se>
|
78
|
+
|
79
|
+
* ChangeLog: Fix date header for previous entry.
|
80
|
+
* lib/mkmf-gnome2.rb: Make last change backwards compatible with older
|
81
|
+
RubyGems. I don’t like RubyGems.
|
82
|
+
* ext/glib2/rbglib.c (rbg_rval2cstr_filename): Fix allocation.
|
83
|
+
* ext/glib2/rbglib_bookmarkfile.c: Fix RVAL2CSTRFILENAME calls.
|
84
|
+
|
85
|
+
2011-09-09 Nikolai Weibull <now@bitwi.se>
|
86
|
+
|
87
|
+
* lib/mkmf-gnome2.rb: Use new RubyGems APIs.
|
88
|
+
* ext/glib2/*.c: Fix all warnings generated with gcc 4.4.5.
|
89
|
+
* ext/glib2/*.c: Fix all RVAL2CSTR calls.
|
90
|
+
|
91
|
+
2011-08-04 Kouhei Sutou <kou@cozmixng.org>
|
92
|
+
|
93
|
+
* ext/glib2/rbglib_iochannel.c (ioc_win32_socket_initialize): use
|
94
|
+
rb_w32_get_osfhandle() to get raw socket handle on Windows.
|
95
|
+
Suggested by NAKAMURA Usaku. Thanks!!!
|
96
|
+
|
97
|
+
2011-08-03 Kouhei Sutou <kou@cozmixng.org>
|
98
|
+
|
99
|
+
* ext/glib2/rbglib_iochannel.c (ioc_s_open): add missing Windows
|
100
|
+
support.
|
101
|
+
Reported by OBATA Akio. Thanks!!!
|
102
|
+
|
103
|
+
2011-07-13 Kouhei Sutou <kou@cozmixng.org>
|
104
|
+
|
105
|
+
* ext/glib2/rbglib_iochannel.c (ioc_win32_socket_initialize): fix
|
106
|
+
variable name.
|
107
|
+
|
1
108
|
2011-06-30 Kouhei Sutou <kou@cozmixng.org>
|
2
109
|
|
3
110
|
* ext/glib2/rbglib_iochannel.c: bind g_io_channel_win32_new_socket().
|
data/ext/glib2/glib2.def
CHANGED
@@ -56,14 +56,25 @@ EXPORTS
|
|
56
56
|
g_value_set_ruby_value
|
57
57
|
g_key_file_get_type
|
58
58
|
rbg_rval_inspect
|
59
|
+
rbg_string_value_ptr
|
59
60
|
rbg_rval2cstr
|
60
61
|
rbg_rval2cstr_accept_nil
|
61
62
|
rbg_cstr2rval
|
63
|
+
rbg_cstr2rval_len
|
64
|
+
rbg_cstr2rval_with_encoding
|
65
|
+
rbg_cstr2rval_len_with_encoding
|
66
|
+
rbg_cstr2rval_free
|
62
67
|
rbg_cstr2rval_with_free
|
68
|
+
rbg_filename_to_ruby
|
63
69
|
rbg_filename_to_ruby_free
|
64
70
|
rbg_filename_from_ruby
|
65
71
|
rbg_filename_gslist_to_array_free
|
66
|
-
|
72
|
+
rbg_rval2strv
|
73
|
+
rbg_rval2strv_accept_nil
|
74
|
+
rbg_rval2strv_dup
|
75
|
+
rbg_rval2strv_dup_accept_nil
|
76
|
+
rbg_strv2rval
|
77
|
+
rbg_strv2rval_free
|
67
78
|
rbgutil_id_module_eval DATA
|
68
79
|
rbgutil_def_setters
|
69
80
|
rbgutil_glist2ary
|
data/ext/glib2/rbglib.c
CHANGED
@@ -43,24 +43,24 @@ extern void Init_glib_unicode();
|
|
43
43
|
extern void Init_glib_keyfile();
|
44
44
|
extern void Init_glib_bookmark_file();
|
45
45
|
|
46
|
-
gchar *
|
46
|
+
const gchar *
|
47
47
|
rbg_rval2cstr(VALUE *str)
|
48
48
|
{
|
49
49
|
StringValue(*str);
|
50
|
+
|
50
51
|
#ifdef HAVE_RUBY_ENCODING_H
|
51
|
-
if (rb_enc_get(*str) != rb_utf8_encoding())
|
52
|
+
if (rb_enc_get(*str) != rb_utf8_encoding())
|
52
53
|
*str = rb_str_export_to_enc(*str, rb_utf8_encoding());
|
53
|
-
}
|
54
54
|
#endif
|
55
|
+
|
55
56
|
return RSTRING_PTR(*str);
|
56
57
|
}
|
57
58
|
|
58
59
|
const gchar *
|
59
60
|
rbg_rval_inspect(VALUE object)
|
60
61
|
{
|
61
|
-
VALUE inspected;
|
62
|
+
VALUE inspected = rb_funcall(object, id_inspect, 0);
|
62
63
|
|
63
|
-
inspected = rb_funcall(object, id_inspect, 0);
|
64
64
|
return RVAL2CSTR(inspected);
|
65
65
|
}
|
66
66
|
|
@@ -70,25 +70,22 @@ rbg_string_value_ptr(volatile VALUE *ptr)
|
|
70
70
|
return rb_string_value_ptr(ptr);
|
71
71
|
}
|
72
72
|
|
73
|
-
gchar *
|
73
|
+
const gchar *
|
74
74
|
rbg_rval2cstr_accept_nil(VALUE *str)
|
75
75
|
{
|
76
76
|
return NIL_P(*str) ? NULL : RVAL2CSTR(*str);
|
77
77
|
}
|
78
78
|
|
79
79
|
VALUE
|
80
|
-
rbg_cstr2rval(const gchar*
|
80
|
+
rbg_cstr2rval(const gchar *str)
|
81
81
|
{
|
82
|
-
|
83
|
-
return Qnil;
|
84
|
-
|
85
|
-
return CSTR2RVAL_LEN(str, strlen(str));
|
82
|
+
return str != NULL ? CSTR2RVAL_LEN(str, strlen(str)) : Qnil;
|
86
83
|
}
|
87
84
|
|
88
85
|
VALUE
|
89
|
-
rbg_cstr2rval_len(const gchar*
|
86
|
+
rbg_cstr2rval_len(const gchar *str, gsize len)
|
90
87
|
{
|
91
|
-
if (
|
88
|
+
if (str == NULL)
|
92
89
|
return Qnil;
|
93
90
|
|
94
91
|
#ifdef HAVE_RUBY_ENCODING_H
|
@@ -99,76 +96,126 @@ rbg_cstr2rval_len(const gchar* str, gsize len)
|
|
99
96
|
}
|
100
97
|
|
101
98
|
VALUE
|
102
|
-
rbg_cstr2rval_with_encoding(const gchar*
|
99
|
+
rbg_cstr2rval_with_encoding(const gchar *str, const gchar *encoding)
|
103
100
|
{
|
104
|
-
|
105
|
-
return Qnil;
|
106
|
-
|
107
|
-
return CSTR2RVAL_LEN_ENC(str, strlen(str), encoding);
|
101
|
+
return str != NULL ? CSTR2RVAL_LEN_ENC(str, strlen(str), encoding) : Qnil;
|
108
102
|
}
|
109
103
|
|
110
104
|
VALUE
|
111
|
-
rbg_cstr2rval_len_with_encoding(const gchar*
|
105
|
+
rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
|
112
106
|
const gchar *encoding)
|
113
107
|
{
|
114
|
-
if (
|
108
|
+
if (str == NULL)
|
115
109
|
return Qnil;
|
116
110
|
|
117
111
|
#ifdef HAVE_RUBY_ENCODING_H
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
rb_encoding = rb_enc_find(encoding);
|
123
|
-
} else {
|
124
|
-
rb_encoding = rb_utf8_encoding();
|
125
|
-
}
|
126
|
-
return rb_external_str_new_with_enc(str, len, rb_encoding);
|
127
|
-
}
|
112
|
+
return rb_external_str_new_with_enc(str, len,
|
113
|
+
encoding != NULL ?
|
114
|
+
rb_enc_find(encoding) :
|
115
|
+
rb_utf8_encoding());
|
128
116
|
#else
|
129
117
|
return rb_str_new(str, len);
|
130
118
|
#endif
|
131
119
|
}
|
132
120
|
|
133
121
|
static VALUE
|
134
|
-
|
122
|
+
rbg_cstr2rval_free_body(VALUE str)
|
135
123
|
{
|
136
124
|
return CSTR2RVAL((const gchar *)str);
|
137
125
|
}
|
138
126
|
|
139
127
|
static VALUE
|
140
|
-
|
128
|
+
rbg_cstr2rval_free_ensure(VALUE str)
|
141
129
|
{
|
142
130
|
g_free((gchar *)str);
|
143
131
|
|
144
132
|
return Qnil;
|
145
133
|
}
|
146
134
|
|
135
|
+
VALUE
|
136
|
+
rbg_cstr2rval_free(gchar *str)
|
137
|
+
{
|
138
|
+
return str != NULL? rb_ensure(rbg_cstr2rval_free_body, (VALUE)str,
|
139
|
+
rbg_cstr2rval_free_ensure, (VALUE)str) : Qnil;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* just for backward compatibility. */
|
147
143
|
VALUE
|
148
144
|
rbg_cstr2rval_with_free(gchar *str)
|
149
145
|
{
|
150
|
-
return str
|
151
|
-
rbg_cstr2rval_with_free_ensure, (VALUE)str) : Qnil;
|
146
|
+
return rbg_cstr2rval_free(str);
|
152
147
|
}
|
153
148
|
|
154
149
|
#ifdef HAVE_RUBY_ENCODING_H
|
155
150
|
static rb_encoding *filename_encoding_if_not_utf8;
|
156
151
|
#endif
|
157
152
|
|
153
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
154
|
+
static VALUE
|
155
|
+
rbg_filename_to_ruby_body(VALUE filename)
|
156
|
+
{
|
157
|
+
const gchar *filename_utf8 = (const gchar *)filename;
|
158
|
+
VALUE rb_filename;
|
159
|
+
|
160
|
+
rb_filename = rb_external_str_new_with_enc(filename_utf8,
|
161
|
+
strlen(filename_utf8),
|
162
|
+
rb_utf8_encoding());
|
163
|
+
|
164
|
+
/* if needed, change encoding of Ruby String to filename encoding, so that
|
165
|
+
upcoming File operations will work properly */
|
166
|
+
return filename_encoding_if_not_utf8 != NULL ?
|
167
|
+
rb_str_export_to_enc(rb_filename, filename_encoding_if_not_utf8) :
|
168
|
+
rb_filename;
|
169
|
+
}
|
170
|
+
|
171
|
+
static VALUE
|
172
|
+
rbg_filename_to_ruby_ensure(VALUE filename)
|
173
|
+
{
|
174
|
+
g_free((gchar *)filename);
|
175
|
+
|
176
|
+
return Qnil;
|
177
|
+
}
|
178
|
+
#endif
|
179
|
+
|
158
180
|
VALUE
|
159
|
-
|
181
|
+
rbg_filename_to_ruby(const gchar *filename)
|
160
182
|
{
|
161
183
|
#ifdef HAVE_RUBY_ENCODING_H
|
162
184
|
gchar *filename_utf8;
|
185
|
+
gsize written;
|
163
186
|
GError *error = NULL;
|
187
|
+
|
188
|
+
if (filename == NULL)
|
189
|
+
return Qnil;
|
190
|
+
|
191
|
+
if (filename_encoding_if_not_utf8 == NULL)
|
192
|
+
return CSTR2RVAL(filename);
|
193
|
+
|
194
|
+
filename_utf8 = g_filename_to_utf8(filename, -1, NULL, &written, &error);
|
195
|
+
if (error != NULL)
|
196
|
+
RAISE_GERROR(error);
|
197
|
+
|
198
|
+
return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8,
|
199
|
+
rbg_filename_to_ruby_ensure, (VALUE)filename_utf8);
|
200
|
+
#else
|
201
|
+
return CSTR2RVAL(filename);
|
202
|
+
#endif
|
203
|
+
}
|
204
|
+
|
205
|
+
VALUE
|
206
|
+
rbg_filename_to_ruby_free(gchar *filename)
|
207
|
+
{
|
208
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
209
|
+
gchar *filename_utf8;
|
164
210
|
gsize written;
|
165
|
-
VALUE rb_filename = Qnil;
|
166
211
|
|
167
212
|
if (filename == NULL)
|
168
213
|
return Qnil;
|
169
|
-
|
214
|
+
|
170
215
|
/* convert filename to UTF-8 if needed */
|
171
216
|
if (filename_encoding_if_not_utf8 != NULL) {
|
217
|
+
GError *error = NULL;
|
218
|
+
|
172
219
|
filename_utf8 = g_filename_to_utf8(filename, -1, NULL, &written, &error);
|
173
220
|
g_free(filename);
|
174
221
|
if (error != NULL)
|
@@ -177,20 +224,8 @@ rbg_filename_to_ruby_free(gchar *filename)
|
|
177
224
|
filename_utf8 = filename;
|
178
225
|
}
|
179
226
|
|
180
|
-
|
181
|
-
|
182
|
-
strlen(filename_utf8),
|
183
|
-
rb_utf8_encoding());
|
184
|
-
g_free(filename_utf8);
|
185
|
-
|
186
|
-
/* if needed, change encoding of Ruby String to filename encoding, so that
|
187
|
-
upcoming File operations will work properly */
|
188
|
-
if (filename_encoding_if_not_utf8 != NULL) {
|
189
|
-
return rb_str_export_to_enc(rb_filename, filename_encoding_if_not_utf8);
|
190
|
-
} else {
|
191
|
-
return rb_filename;
|
192
|
-
}
|
193
|
-
|
227
|
+
return rb_ensure(rbg_filename_to_ruby_body, (VALUE)filename_utf8,
|
228
|
+
rbg_filename_to_ruby_ensure, (VALUE)filename_utf8);
|
194
229
|
#else
|
195
230
|
return CSTR2RVAL_FREE(filename);
|
196
231
|
#endif
|
@@ -200,44 +235,198 @@ gchar *
|
|
200
235
|
rbg_filename_from_ruby(VALUE filename)
|
201
236
|
{
|
202
237
|
#ifdef HAVE_RUBY_ENCODING_H
|
203
|
-
GError *error = NULL;
|
204
238
|
gchar *retval;
|
205
239
|
gsize written;
|
240
|
+
GError *error = NULL;
|
206
241
|
|
207
242
|
/* if needed, change encoding of Ruby String to UTF-8 */
|
208
243
|
StringValue(filename);
|
209
|
-
if (rb_enc_get(filename) != rb_utf8_encoding())
|
244
|
+
if (rb_enc_get(filename) != rb_utf8_encoding())
|
210
245
|
filename = rb_str_export_to_enc(filename, rb_utf8_encoding());
|
211
|
-
}
|
212
246
|
|
213
247
|
/* convert it to filename encoding if needed */
|
214
|
-
if (filename_encoding_if_not_utf8
|
215
|
-
|
216
|
-
if (error != NULL)
|
217
|
-
RAISE_GERROR(error);
|
218
|
-
} else {
|
219
|
-
retval = RSTRING_PTR(filename);
|
220
|
-
}
|
248
|
+
if (filename_encoding_if_not_utf8 == NULL)
|
249
|
+
return g_strdup(RSTRING_PTR(filename));
|
221
250
|
|
222
|
-
|
251
|
+
retval = g_filename_from_utf8(RSTRING_PTR(filename), -1, NULL, &written, &error);
|
252
|
+
if (error != NULL)
|
253
|
+
RAISE_GERROR(error);
|
223
254
|
|
255
|
+
return retval;
|
224
256
|
#else
|
225
|
-
return RVAL2CSTR(filename);
|
257
|
+
return g_strdup(RVAL2CSTR(filename));
|
226
258
|
#endif
|
227
259
|
}
|
228
260
|
|
229
|
-
VALUE
|
230
|
-
|
261
|
+
static VALUE
|
262
|
+
rbg_filename_gslist_to_array_free_body(VALUE list)
|
231
263
|
{
|
232
|
-
GSList *l;
|
233
264
|
VALUE ary = rb_ary_new();
|
234
|
-
|
235
|
-
|
236
|
-
|
265
|
+
GSList *p;
|
266
|
+
|
267
|
+
for (p = (GSList *)list; p != NULL; p = g_slist_next(p))
|
268
|
+
rb_ary_push(ary, CSTRFILENAME2RVAL(p->data));
|
269
|
+
|
270
|
+
return ary;
|
271
|
+
}
|
272
|
+
|
273
|
+
static VALUE
|
274
|
+
rbg_filename_gslist_to_array_free_ensure(VALUE val)
|
275
|
+
{
|
276
|
+
GSList *list = (GSList *)val;
|
277
|
+
GSList *p;
|
278
|
+
|
279
|
+
for (p = list; p != NULL; p = g_slist_next(p))
|
280
|
+
g_free((gchar *)p->data);
|
281
|
+
|
237
282
|
g_slist_free(list);
|
283
|
+
|
284
|
+
return Qnil;
|
285
|
+
}
|
286
|
+
|
287
|
+
VALUE
|
288
|
+
rbg_filename_gslist_to_array_free(GSList *list)
|
289
|
+
{
|
290
|
+
return rb_ensure(rbg_filename_gslist_to_array_free_body, (VALUE)list,
|
291
|
+
rbg_filename_gslist_to_array_free_ensure, (VALUE)list);
|
292
|
+
}
|
293
|
+
|
294
|
+
struct rval2strv_args {
|
295
|
+
VALUE ary;
|
296
|
+
long n;
|
297
|
+
const gchar **strings;
|
298
|
+
};
|
299
|
+
|
300
|
+
static VALUE
|
301
|
+
rbg_rval2strv_body(VALUE value)
|
302
|
+
{
|
303
|
+
long i;
|
304
|
+
struct rval2strv_args *args = (struct rval2strv_args *)value;
|
305
|
+
|
306
|
+
for (i = 0; i < args->n; i++)
|
307
|
+
args->strings[i] = RVAL2CSTR(RARRAY_PTR(args->ary)[i]);
|
308
|
+
args->strings[args->n] = NULL;
|
309
|
+
|
310
|
+
return Qnil;
|
311
|
+
}
|
312
|
+
|
313
|
+
static VALUE
|
314
|
+
rbg_rval2strv_rescue(VALUE value)
|
315
|
+
{
|
316
|
+
struct rval2strv_args *args = (struct rval2strv_args *)value;
|
317
|
+
|
318
|
+
g_free(args->strings);
|
319
|
+
|
320
|
+
rb_exc_raise(rb_errinfo());
|
321
|
+
}
|
322
|
+
|
323
|
+
const gchar **
|
324
|
+
rbg_rval2strv(VALUE value)
|
325
|
+
{
|
326
|
+
struct rval2strv_args args;
|
327
|
+
|
328
|
+
args.ary = rb_ary_to_ary(value);
|
329
|
+
args.n = RARRAY_LEN(args.ary);
|
330
|
+
args.strings = g_new(const gchar *, args.n + 1);
|
331
|
+
|
332
|
+
rb_rescue(rbg_rval2strv_body, (VALUE)&args,
|
333
|
+
rbg_rval2strv_rescue, (VALUE)&args);
|
334
|
+
|
335
|
+
return args.strings;
|
336
|
+
}
|
337
|
+
|
338
|
+
const gchar **
|
339
|
+
rbg_rval2strv_accept_nil(VALUE ary)
|
340
|
+
{
|
341
|
+
return NIL_P(ary) ? NULL : rbg_rval2strv(ary);
|
342
|
+
}
|
343
|
+
|
344
|
+
struct rval2strv_dup_args {
|
345
|
+
VALUE ary;
|
346
|
+
long n;
|
347
|
+
gchar **strings;
|
348
|
+
};
|
349
|
+
|
350
|
+
static VALUE
|
351
|
+
rbg_rval2strv_dup_body(VALUE value)
|
352
|
+
{
|
353
|
+
long i;
|
354
|
+
struct rval2strv_dup_args *args = (struct rval2strv_dup_args *)value;
|
355
|
+
|
356
|
+
for (i = 0; i < args->n; i++)
|
357
|
+
args->strings[i] = g_strdup(RVAL2CSTR(RARRAY_PTR(args->ary)[i]));
|
358
|
+
args->strings[args->n] = NULL;
|
359
|
+
|
360
|
+
return Qnil;
|
361
|
+
}
|
362
|
+
|
363
|
+
static VALUE
|
364
|
+
rbg_rval2strv_dup_rescue(VALUE value)
|
365
|
+
{
|
366
|
+
struct rval2strv_dup_args *args = (struct rval2strv_dup_args *)value;
|
367
|
+
|
368
|
+
g_free(args->strings);
|
369
|
+
|
370
|
+
rb_exc_raise(rb_errinfo());
|
371
|
+
}
|
372
|
+
|
373
|
+
gchar **
|
374
|
+
rbg_rval2strv_dup(VALUE value)
|
375
|
+
{
|
376
|
+
struct rval2strv_dup_args args;
|
377
|
+
|
378
|
+
args.ary = rb_ary_to_ary(value);
|
379
|
+
args.n = RARRAY_LEN(args.ary);
|
380
|
+
args.strings = g_new(gchar *, args.n + 1);
|
381
|
+
|
382
|
+
rb_rescue(rbg_rval2strv_dup_body, (VALUE)&args,
|
383
|
+
rbg_rval2strv_dup_rescue, (VALUE)&args);
|
384
|
+
|
385
|
+
return args.strings;
|
386
|
+
}
|
387
|
+
|
388
|
+
gchar **
|
389
|
+
rbg_rval2strv_dup_accept_nil(VALUE ary)
|
390
|
+
{
|
391
|
+
return NIL_P(ary) ? NULL : rbg_rval2strv_dup(ary);
|
392
|
+
}
|
393
|
+
|
394
|
+
VALUE
|
395
|
+
rbg_strv2rval(const gchar **strings)
|
396
|
+
{
|
397
|
+
VALUE ary;
|
398
|
+
const gchar **p;
|
399
|
+
|
400
|
+
if (strings == NULL)
|
401
|
+
return Qnil;
|
402
|
+
|
403
|
+
ary = rb_ary_new();
|
404
|
+
for (p = strings; *p != NULL; p++)
|
405
|
+
rb_ary_push(ary, CSTR2RVAL(*p));
|
406
|
+
|
238
407
|
return ary;
|
239
408
|
}
|
240
409
|
|
410
|
+
static VALUE
|
411
|
+
rbg_strv2rval_free_body(VALUE strings)
|
412
|
+
{
|
413
|
+
return STRV2RVAL((const gchar **)strings);
|
414
|
+
}
|
415
|
+
|
416
|
+
static VALUE
|
417
|
+
rbg_strv2rval_free_ensure(VALUE strings)
|
418
|
+
{
|
419
|
+
g_strfreev((gchar **)strings);
|
420
|
+
|
421
|
+
return Qnil;
|
422
|
+
}
|
423
|
+
|
424
|
+
VALUE
|
425
|
+
rbg_strv2rval_free(gchar **strings)
|
426
|
+
{
|
427
|
+
return rb_ensure(rbg_strv2rval_free_body, (VALUE)strings,
|
428
|
+
rbg_strv2rval_free_ensure, (VALUE)strings);
|
429
|
+
}
|
241
430
|
|
242
431
|
#if 0
|
243
432
|
/*
|