glib2 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/ext/glib2/extconf.rb +1 -0
  2. data/ext/glib2/glib2.def +23 -0
  3. data/ext/glib2/rbgcompat.h +19 -5
  4. data/ext/glib2/rbglib.c +607 -160
  5. data/ext/glib2/rbglib.h +81 -26
  6. data/ext/glib2/rbglib2conversions.h +57 -0
  7. data/ext/glib2/rbglib_bookmarkfile.c +117 -107
  8. data/ext/glib2/rbglib_completion.c +37 -26
  9. data/ext/glib2/rbglib_convert.c +42 -30
  10. data/ext/glib2/rbglib_error.c +20 -10
  11. data/ext/glib2/rbglib_fileutils.c +48 -37
  12. data/ext/glib2/rbglib_i18n.c +24 -14
  13. data/ext/glib2/rbglib_int64.c +24 -16
  14. data/ext/glib2/rbglib_iochannel.c +146 -204
  15. data/ext/glib2/rbglib_iochannel_win32_socket.c +56 -0
  16. data/ext/glib2/rbglib_iochannelerror.c +49 -0
  17. data/ext/glib2/rbglib_keyfile.c +171 -182
  18. data/ext/glib2/rbglib_maincontext.c +107 -92
  19. data/ext/glib2/rbglib_mainloop.c +34 -21
  20. data/ext/glib2/rbglib_messages.c +53 -44
  21. data/ext/glib2/rbglib_pollfd.c +37 -26
  22. data/ext/glib2/rbglib_shell.c +29 -22
  23. data/ext/glib2/rbglib_shellerror.c +34 -0
  24. data/ext/glib2/rbglib_source.c +49 -36
  25. data/ext/glib2/rbglib_spawn.c +50 -61
  26. data/ext/glib2/rbglib_spawnerror.c +53 -0
  27. data/ext/glib2/rbglib_threads.c +28 -16
  28. data/ext/glib2/rbglib_timer.c +35 -24
  29. data/ext/glib2/rbglib_ucs4.c +79 -0
  30. data/ext/glib2/rbglib_unichar.c +209 -0
  31. data/ext/glib2/rbglib_unicode.c +34 -584
  32. data/ext/glib2/rbglib_utf16.c +78 -0
  33. data/ext/glib2/rbglib_utf8.c +259 -0
  34. data/ext/glib2/rbglib_utils.c +95 -91
  35. data/ext/glib2/rbglib_win32.c +52 -45
  36. data/ext/glib2/rbglibdeprecated.c +56 -0
  37. data/ext/glib2/rbglibdeprecated.h +34 -0
  38. data/ext/glib2/rbgobj_boxed.c +40 -33
  39. data/ext/glib2/rbgobj_closure.c +45 -34
  40. data/ext/glib2/rbgobj_convert.c +19 -9
  41. data/ext/glib2/rbgobj_enumflags.c +109 -0
  42. data/ext/glib2/rbgobj_enums.c +67 -646
  43. data/ext/glib2/rbgobj_flags.c +522 -0
  44. data/ext/glib2/rbgobj_fundamental.c +19 -6
  45. data/ext/glib2/rbgobj_object.c +90 -81
  46. data/ext/glib2/rbgobj_param.c +78 -83
  47. data/ext/glib2/rbgobj_paramspecs.c +20 -12
  48. data/ext/glib2/rbgobj_signal.c +248 -193
  49. data/ext/glib2/rbgobj_strv.c +20 -10
  50. data/ext/glib2/rbgobj_type.c +153 -149
  51. data/ext/glib2/rbgobj_typeinstance.c +49 -39
  52. data/ext/glib2/rbgobj_typeinterface.c +37 -27
  53. data/ext/glib2/rbgobj_typemodule.c +39 -29
  54. data/ext/glib2/rbgobj_typeplugin.c +36 -26
  55. data/ext/glib2/rbgobj_value.c +41 -11
  56. data/ext/glib2/rbgobj_valuearray.c +59 -23
  57. data/ext/glib2/rbgobj_valuetypes.c +27 -17
  58. data/ext/glib2/rbgobject.c +26 -40
  59. data/ext/glib2/rbgobject.h +38 -20
  60. data/ext/glib2/rbgprivate.h +87 -5
  61. data/ext/glib2/rbgutil.c +52 -238
  62. data/ext/glib2/rbgutil.h +55 -42
  63. data/ext/glib2/rbgutil_callback.c +47 -12
  64. data/ext/glib2/rbgutil_list.c +173 -0
  65. data/ext/glib2/rbgutil_list.h +85 -0
  66. data/ext/glib2/rbgutildeprecated.c +252 -0
  67. data/ext/glib2/rbgutildeprecated.h +63 -0
  68. data/lib/glib-mkenums.rb +2 -2
  69. data/lib/glib2.rb +2 -25
  70. data/lib/glib2/deprecatable.rb +149 -0
  71. data/lib/gnome2-raketask.rb +45 -15
  72. data/lib/gnome2-win32-binary-downloader.rb +1 -1
  73. data/lib/mkmf-gnome2.rb +37 -18
  74. data/test/test_flags.rb +129 -0
  75. data/test/test_key_file.rb +6 -2
  76. data/test/test_spawn.rb +33 -0
  77. metadata +26 -7
  78. data/ChangeLog +0 -3513
@@ -37,6 +37,7 @@ have_func("rb_sourceline", ruby_header)
37
37
  have_func("ruby_set_current_source", ruby_header)
38
38
  have_func("rb_thread_blocking_region", ruby_header)
39
39
  have_func("ruby_native_thread_p", ruby_header)
40
+ have_func("rb_thread_call_with_gvl", ruby_header)
40
41
 
41
42
  have_var("curr_thread", [ruby_header, "node.h"])
42
43
  have_var("rb_curr_thread", [ruby_header, "node.h"])
@@ -18,6 +18,7 @@ EXPORTS
18
18
  rbgobj_get_ruby_object_from_gobject
19
19
  rbgobj_create_object
20
20
  rbgobj_gobject_new
21
+ rbgobj_gobject_initialize
21
22
  rbgobj_boxed_create
22
23
  rbgobj_boxed_get
23
24
  rbgobj_boxed_not_copy_obj
@@ -26,6 +27,7 @@ EXPORTS
26
27
  rbgobj_gtype_get
27
28
  rbgobj_gtype_new
28
29
  rbgobj_gvalue_to_rvalue
30
+ rbgobj_gvalue_to_rvalue_unset
29
31
  rbgobj_rvalue_to_gvalue
30
32
  rbgobj_initialize_gvalue
31
33
  rbgobj_initialize_object
@@ -59,8 +61,12 @@ EXPORTS
59
61
  rbg_string_value_ptr
60
62
  rbg_rval2cstr
61
63
  rbg_rval2cstr_accept_nil
64
+ rbg_rval2cstr_accept_symbol
65
+ rbg_rval2cstr_accept_symbol_accept_nil
66
+ rbg_rval2glibid
62
67
  rbg_cstr2rval
63
68
  rbg_cstr2rval_len
69
+ rbg_cstr2rval_len_free
64
70
  rbg_cstr2rval_with_encoding
65
71
  rbg_cstr2rval_len_with_encoding
66
72
  rbg_cstr2rval_free
@@ -75,6 +81,22 @@ EXPORTS
75
81
  rbg_rval2strv_dup_accept_nil
76
82
  rbg_strv2rval
77
83
  rbg_strv2rval_free
84
+ rbg_rval2gbooleans
85
+ rbg_rval2gints
86
+ rbg_rval2gint8s
87
+ rbg_rval2guint8s
88
+ rbg_rval2guint16s
89
+ rbg_rval2guint32s
90
+ rbg_rval2gdoubles
91
+ rbg_gints2rval
92
+ rbg_gints2rval_free
93
+ rbg_glist2rval
94
+ rbg_gslist2rval
95
+ rbg_glist2rval_with_type
96
+ rbg_gslist2rval_with_type
97
+ rbg_define_method
98
+ rbg_define_singleton_method
99
+ rbg_scan_options
78
100
  rbgutil_id_module_eval DATA
79
101
  rbgutil_def_setters
80
102
  rbgutil_glist2ary
@@ -88,6 +110,7 @@ EXPORTS
88
110
  rbgutil_gslist2ary_and_free
89
111
  rbgutil_gslist2ary_boxed_and_free
90
112
  rbgutil_set_properties
113
+ rbgutil_glibid_r2g_func
91
114
  rbgutil_sym_g2r_func
92
115
  rbgutil_protect
93
116
  rbgutil_invoke_callback
@@ -1,9 +1,23 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
- rbgcompat.h -
4
-
5
- Copyright (C) 2007 Ruby-GNOME2 Project Team
6
- **********************************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2007 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
7
21
 
8
22
  #ifndef __RBGCOMPAT_H__
9
23
  #define __RBGCOMPAT_H__
@@ -1,47 +1,33 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
-
4
- rbglib.c -
5
-
6
- $Author: sakai $
7
- $Date: 2007/07/14 13:42:08 $
8
-
9
- Copyright (C) 2002,2003 Masahiro Sakai
10
-
11
- **********************************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002,2003 Masahiro Sakai
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
12
21
 
13
22
  #include <locale.h>
14
23
  #include "rbgprivate.h"
15
24
  #include "rbglib.h"
16
25
 
26
+ #define RG_TARGET_NAMESPACE mGLib
27
+
17
28
  static ID id_inspect;
18
29
 
19
- VALUE mGLib;
20
-
21
- extern void Init_gutil();
22
- extern void Init_gutil_callback();
23
- extern void Init_glib_int64();
24
- extern void Init_glib_error();
25
- extern void Init_glib_threads();
26
- extern void Init_glib_convert();
27
- extern void Init_glib_messages();
28
- extern void Init_glib_spawn();
29
- extern void Init_glib_fileutils();
30
- extern void Init_glib_utils();
31
- extern void Init_glib_i18n();
32
- extern void Init_glib_win32();
33
- extern void Init_gobject();
34
- extern void Init_glib_main_loop();
35
- extern void Init_glib_main_context();
36
- extern void Init_glib_source();
37
- extern void Init_glib_poll_fd();
38
- extern void Init_glib_io_channel();
39
- extern void Init_glib_shell();
40
- extern void Init_glib_completion();
41
- extern void Init_glib_timer();
42
- extern void Init_glib_unicode();
43
- extern void Init_glib_keyfile();
44
- extern void Init_glib_bookmark_file();
30
+ VALUE RG_TARGET_NAMESPACE;
45
31
 
46
32
  const gchar *
47
33
  rbg_rval2cstr(VALUE *str)
@@ -76,6 +62,46 @@ rbg_rval2cstr_accept_nil(VALUE *str)
76
62
  return NIL_P(*str) ? NULL : RVAL2CSTR(*str);
77
63
  }
78
64
 
65
+ /* TODO: How do we deal with encodings? */
66
+ const gchar *
67
+ rbg_rval2cstr_accept_symbol(volatile VALUE *value)
68
+ {
69
+ if (!SYMBOL_P(*value))
70
+ return rbg_rval2cstr((VALUE *)value);
71
+
72
+ return rb_id2name(SYM2ID(*value));
73
+ }
74
+
75
+ const gchar *
76
+ rbg_rval2cstr_accept_symbol_accept_nil(volatile VALUE *value)
77
+ {
78
+ return NIL_P(*value) ? NULL : rbg_rval2cstr_accept_symbol(value);
79
+ }
80
+
81
+ const gchar *
82
+ rbg_rval2glibid(volatile VALUE *value, volatile VALUE *buf, gboolean accept_nil)
83
+ {
84
+ gchar *id, *p;
85
+
86
+ if (accept_nil && NIL_P(*value))
87
+ return NULL;
88
+
89
+ if (SYMBOL_P(*value)) {
90
+ *buf = rb_String(*value);
91
+ } else {
92
+ StringValue(*value);
93
+ *buf = rb_str_dup(*value);
94
+ }
95
+ RB_GC_GUARD(*buf);
96
+
97
+ id = RSTRING_PTR(*buf);
98
+ for (p = id; *p; p++)
99
+ if (*p == '_')
100
+ *p = '-';
101
+
102
+ return id;
103
+ }
104
+
79
105
  VALUE
80
106
  rbg_cstr2rval(const gchar *str)
81
107
  {
@@ -95,12 +121,43 @@ rbg_cstr2rval_len(const gchar *str, gsize len)
95
121
  #endif
96
122
  }
97
123
 
124
+ struct rbg_cstr2rval_len_free_args {
125
+ gchar *str;
126
+ gsize len;
127
+ };
128
+
129
+ static VALUE
130
+ rbg_cstr2rval_len_free_body(VALUE value)
131
+ {
132
+ struct rbg_cstr2rval_len_free_args *args = (struct rbg_cstr2rval_len_free_args *)value;
133
+
134
+ return CSTR2RVAL_LEN(args->str, args->len);
135
+ }
136
+
137
+ static VALUE
138
+ rbg_cstr2rval_len_free_ensure(VALUE str)
139
+ {
140
+ g_free((gchar *)str);
141
+
142
+ return Qnil;
143
+ }
144
+
145
+ VALUE
146
+ rbg_cstr2rval_len_free(gchar *str, gsize len)
147
+ {
148
+ struct rbg_cstr2rval_len_free_args args = { str, len };
149
+
150
+ return str != NULL ? rb_ensure(rbg_cstr2rval_len_free_body, (VALUE)&args,
151
+ rbg_cstr2rval_len_free_ensure, (VALUE)str) : Qnil;
152
+ }
153
+
98
154
  VALUE
99
155
  rbg_cstr2rval_with_encoding(const gchar *str, const gchar *encoding)
100
156
  {
101
157
  return str != NULL ? CSTR2RVAL_LEN_ENC(str, strlen(str), encoding) : Qnil;
102
158
  }
103
159
 
160
+ #ifdef HAVE_RUBY_ENCODING_H
104
161
  VALUE
105
162
  rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
106
163
  const gchar *encoding)
@@ -108,15 +165,22 @@ rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
108
165
  if (str == NULL)
109
166
  return Qnil;
110
167
 
111
- #ifdef HAVE_RUBY_ENCODING_H
112
168
  return rb_external_str_new_with_enc(str, len,
113
169
  encoding != NULL ?
114
170
  rb_enc_find(encoding) :
115
171
  rb_utf8_encoding());
172
+ }
116
173
  #else
174
+ VALUE
175
+ rbg_cstr2rval_len_with_encoding(const gchar *str, gsize len,
176
+ G_GNUC_UNUSED const gchar *encoding)
177
+ {
178
+ if (str == NULL)
179
+ return Qnil;
180
+
117
181
  return rb_str_new(str, len);
118
- #endif
119
182
  }
183
+ #endif
120
184
 
121
185
  static VALUE
122
186
  rbg_cstr2rval_free_body(VALUE str)
@@ -258,43 +322,10 @@ rbg_filename_from_ruby(VALUE filename)
258
322
  #endif
259
323
  }
260
324
 
261
- static VALUE
262
- rbg_filename_gslist_to_array_free_body(VALUE list)
263
- {
264
- VALUE ary = rb_ary_new();
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
-
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
325
  struct rval2strv_args {
295
326
  VALUE ary;
296
327
  long n;
297
- const gchar **strings;
328
+ const gchar **result;
298
329
  };
299
330
 
300
331
  static VALUE
@@ -304,47 +335,54 @@ rbg_rval2strv_body(VALUE value)
304
335
  struct rval2strv_args *args = (struct rval2strv_args *)value;
305
336
 
306
337
  for (i = 0; i < args->n; i++)
307
- args->strings[i] = RVAL2CSTR(RARRAY_PTR(args->ary)[i]);
308
- args->strings[args->n] = NULL;
338
+ args->result[i] = RVAL2CSTR(RARRAY_PTR(args->ary)[i]);
339
+ args->result[args->n] = NULL;
309
340
 
310
341
  return Qnil;
311
342
  }
312
343
 
313
- static VALUE
344
+ static G_GNUC_NORETURN VALUE
314
345
  rbg_rval2strv_rescue(VALUE value)
315
346
  {
316
- struct rval2strv_args *args = (struct rval2strv_args *)value;
317
-
318
- g_free(args->strings);
347
+ g_free(((struct rval2strv_args *)value)->result);
319
348
 
320
349
  rb_exc_raise(rb_errinfo());
321
350
  }
322
351
 
323
352
  const gchar **
324
- rbg_rval2strv(VALUE value)
353
+ rbg_rval2strv(volatile VALUE *value, long *n)
325
354
  {
326
355
  struct rval2strv_args args;
327
356
 
328
- args.ary = rb_ary_to_ary(value);
357
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
329
358
  args.n = RARRAY_LEN(args.ary);
330
- args.strings = g_new(const gchar *, args.n + 1);
359
+ args.result = g_new(const gchar *, args.n + 1);
331
360
 
332
361
  rb_rescue(rbg_rval2strv_body, (VALUE)&args,
333
362
  rbg_rval2strv_rescue, (VALUE)&args);
334
363
 
335
- return args.strings;
364
+ if (n != NULL)
365
+ *n = args.n;
366
+
367
+ return args.result;
336
368
  }
337
369
 
338
370
  const gchar **
339
- rbg_rval2strv_accept_nil(VALUE ary)
371
+ rbg_rval2strv_accept_nil(volatile VALUE *value, long *n)
340
372
  {
341
- return NIL_P(ary) ? NULL : rbg_rval2strv(ary);
373
+ if (!NIL_P(*value))
374
+ return rbg_rval2strv(value, n);
375
+
376
+ if (n != NULL)
377
+ *n = 0;
378
+
379
+ return NULL;
342
380
  }
343
381
 
344
382
  struct rval2strv_dup_args {
345
383
  VALUE ary;
346
384
  long n;
347
- gchar **strings;
385
+ gchar **result;
348
386
  };
349
387
 
350
388
  static VALUE
@@ -354,41 +392,48 @@ rbg_rval2strv_dup_body(VALUE value)
354
392
  struct rval2strv_dup_args *args = (struct rval2strv_dup_args *)value;
355
393
 
356
394
  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;
395
+ args->result[i] = g_strdup(RVAL2CSTR(RARRAY_PTR(args->ary)[i]));
396
+ args->result[args->n] = NULL;
359
397
 
360
398
  return Qnil;
361
399
  }
362
400
 
363
- static VALUE
401
+ static G_GNUC_NORETURN VALUE
364
402
  rbg_rval2strv_dup_rescue(VALUE value)
365
403
  {
366
- struct rval2strv_dup_args *args = (struct rval2strv_dup_args *)value;
367
-
368
- g_free(args->strings);
404
+ g_free(((struct rval2strv_dup_args *)value)->result);
369
405
 
370
406
  rb_exc_raise(rb_errinfo());
371
407
  }
372
408
 
373
409
  gchar **
374
- rbg_rval2strv_dup(VALUE value)
410
+ rbg_rval2strv_dup(volatile VALUE *value, long *n)
375
411
  {
376
412
  struct rval2strv_dup_args args;
377
413
 
378
- args.ary = rb_ary_to_ary(value);
414
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
379
415
  args.n = RARRAY_LEN(args.ary);
380
- args.strings = g_new(gchar *, args.n + 1);
416
+ args.result = g_new(gchar *, args.n + 1);
381
417
 
382
418
  rb_rescue(rbg_rval2strv_dup_body, (VALUE)&args,
383
419
  rbg_rval2strv_dup_rescue, (VALUE)&args);
384
420
 
385
- return args.strings;
421
+ if (n != NULL)
422
+ *n = args.n;
423
+
424
+ return args.result;
386
425
  }
387
426
 
388
427
  gchar **
389
- rbg_rval2strv_dup_accept_nil(VALUE ary)
428
+ rbg_rval2strv_dup_accept_nil(volatile VALUE *value, long *n)
390
429
  {
391
- return NIL_P(ary) ? NULL : rbg_rval2strv_dup(ary);
430
+ if (!NIL_P(*value))
431
+ rbg_rval2strv_dup(value, n);
432
+
433
+ if (n != NULL)
434
+ *n = 0;
435
+
436
+ return NULL;
392
437
  }
393
438
 
394
439
  VALUE
@@ -428,6 +473,399 @@ rbg_strv2rval_free(gchar **strings)
428
473
  rbg_strv2rval_free_ensure, (VALUE)strings);
429
474
  }
430
475
 
476
+ struct rbg_rval2gbooleans_args {
477
+ VALUE ary;
478
+ long n;
479
+ gboolean *result;
480
+ };
481
+
482
+ static VALUE
483
+ rbg_rval2gbooleans_body(VALUE value)
484
+ {
485
+ long i;
486
+ struct rbg_rval2gbooleans_args *args = (struct rbg_rval2gbooleans_args *)value;
487
+
488
+ for (i = 0; i < args->n; i++)
489
+ args->result[i] = RVAL2CBOOL(RARRAY_PTR(args->ary)[i]);
490
+
491
+ return Qnil;
492
+ }
493
+
494
+ static G_GNUC_NORETURN VALUE
495
+ rbg_rval2gbooleans_rescue(VALUE value)
496
+ {
497
+ g_free(((struct rbg_rval2gbooleans_args *)value)->result);
498
+
499
+ rb_exc_raise(rb_errinfo());
500
+ }
501
+
502
+ gboolean *
503
+ rbg_rval2gbooleans(volatile VALUE *value, long *n)
504
+ {
505
+ struct rbg_rval2gbooleans_args args;
506
+
507
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
508
+ args.n = RARRAY_LEN(args.ary);
509
+ args.result = g_new(gboolean, args.n + 1);
510
+
511
+ rb_rescue(rbg_rval2gbooleans_body, (VALUE)&args,
512
+ rbg_rval2gbooleans_rescue, (VALUE)&args);
513
+
514
+ *n = args.n;
515
+
516
+ return args.result;
517
+ }
518
+
519
+ struct rbg_rval2gints_args {
520
+ VALUE ary;
521
+ long n;
522
+ gint *result;
523
+ };
524
+
525
+ static VALUE
526
+ rbg_rval2gints_body(VALUE value)
527
+ {
528
+ long i;
529
+ struct rbg_rval2gints_args *args = (struct rbg_rval2gints_args *)value;
530
+
531
+ for (i = 0; i < args->n; i++)
532
+ args->result[i] = NUM2INT(RARRAY_PTR(args->ary)[i]);
533
+
534
+ return Qnil;
535
+ }
536
+
537
+ static G_GNUC_NORETURN VALUE
538
+ rbg_rval2gints_rescue(VALUE value)
539
+ {
540
+ g_free(((struct rbg_rval2gints_args *)value)->result);
541
+
542
+ rb_exc_raise(rb_errinfo());
543
+ }
544
+
545
+ gint *
546
+ rbg_rval2gints(volatile VALUE *value, long *n)
547
+ {
548
+ struct rbg_rval2gints_args args;
549
+
550
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
551
+ args.n = RARRAY_LEN(args.ary);
552
+ args.result = g_new(gint, args.n + 1);
553
+
554
+ rb_rescue(rbg_rval2gints_body, (VALUE)&args,
555
+ rbg_rval2gints_rescue, (VALUE)&args);
556
+
557
+ *n = args.n;
558
+
559
+ return args.result;
560
+ }
561
+
562
+ struct rbg_rval2gint8s_args {
563
+ VALUE ary;
564
+ long n;
565
+ gint8 *result;
566
+ };
567
+
568
+ static VALUE
569
+ rbg_rval2gint8s_body(VALUE value)
570
+ {
571
+ long i;
572
+ struct rbg_rval2gint8s_args *args = (struct rbg_rval2gint8s_args *)value;
573
+
574
+ for (i = 0; i < args->n; i++)
575
+ args->result[i] = NUM2CHR(RARRAY_PTR(args->ary)[i]);
576
+
577
+ return Qnil;
578
+ }
579
+
580
+ static G_GNUC_NORETURN VALUE
581
+ rbg_rval2gint8s_rescue(VALUE value)
582
+ {
583
+ g_free(((struct rbg_rval2gint8s_args *)value)->result);
584
+
585
+ rb_exc_raise(rb_errinfo());
586
+ }
587
+
588
+ gint8 *
589
+ rbg_rval2gint8s(volatile VALUE *value, long *n)
590
+ {
591
+ struct rbg_rval2gint8s_args args;
592
+
593
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
594
+ args.n = RARRAY_LEN(args.ary);
595
+ args.result = g_new(gint8, args.n + 1);
596
+
597
+ rb_rescue(rbg_rval2gint8s_body, (VALUE)&args,
598
+ rbg_rval2gint8s_rescue, (VALUE)&args);
599
+
600
+ *n = args.n;
601
+
602
+ return args.result;
603
+ }
604
+
605
+ struct rbg_rval2guint8s_args {
606
+ VALUE ary;
607
+ long n;
608
+ guint8 *result;
609
+ };
610
+
611
+ static VALUE
612
+ rbg_rval2guint8s_body(VALUE value)
613
+ {
614
+ long i;
615
+ struct rbg_rval2guint8s_args *args = (struct rbg_rval2guint8s_args *)value;
616
+
617
+ for (i = 0; i < args->n; i++)
618
+ args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]);
619
+
620
+ return Qnil;
621
+ }
622
+
623
+ static G_GNUC_NORETURN VALUE
624
+ rbg_rval2guint8s_rescue(VALUE value)
625
+ {
626
+ g_free(((struct rbg_rval2guint8s_args *)value)->result);
627
+
628
+ rb_exc_raise(rb_errinfo());
629
+ }
630
+
631
+ guint8 *
632
+ rbg_rval2guint8s(volatile VALUE *value, long *n)
633
+ {
634
+ struct rbg_rval2guint8s_args args;
635
+
636
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
637
+ args.n = RARRAY_LEN(args.ary);
638
+ args.result = g_new(guint8, args.n + 1);
639
+
640
+ rb_rescue(rbg_rval2guint8s_body, (VALUE)&args,
641
+ rbg_rval2guint8s_rescue, (VALUE)&args);
642
+
643
+ *n = args.n;
644
+
645
+ return args.result;
646
+ }
647
+
648
+ struct rbg_rval2guint16s_args {
649
+ VALUE ary;
650
+ long n;
651
+ guint16 *result;
652
+ };
653
+
654
+ static VALUE
655
+ rbg_rval2guint16s_body(VALUE value)
656
+ {
657
+ long i;
658
+ struct rbg_rval2guint16s_args *args = (struct rbg_rval2guint16s_args *)value;
659
+
660
+ for (i = 0; i < args->n; i++)
661
+ args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]);
662
+
663
+ return Qnil;
664
+ }
665
+
666
+ static G_GNUC_NORETURN VALUE
667
+ rbg_rval2guint16s_rescue(VALUE value)
668
+ {
669
+ g_free(((struct rbg_rval2guint16s_args *)value)->result);
670
+
671
+ rb_exc_raise(rb_errinfo());
672
+ }
673
+
674
+ guint16 *
675
+ rbg_rval2guint16s(volatile VALUE *value, long *n)
676
+ {
677
+ struct rbg_rval2guint16s_args args;
678
+
679
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
680
+ args.n = RARRAY_LEN(args.ary);
681
+ args.result = g_new(guint16, args.n + 1);
682
+
683
+ rb_rescue(rbg_rval2guint16s_body, (VALUE)&args,
684
+ rbg_rval2guint16s_rescue, (VALUE)&args);
685
+
686
+ *n = args.n;
687
+
688
+ return args.result;
689
+ }
690
+
691
+ struct rbg_rval2guint32s_args {
692
+ VALUE ary;
693
+ long n;
694
+ guint32 *result;
695
+ };
696
+
697
+ static VALUE
698
+ rbg_rval2guint32s_body(VALUE value)
699
+ {
700
+ long i;
701
+ struct rbg_rval2guint32s_args *args = (struct rbg_rval2guint32s_args *)value;
702
+
703
+ for (i = 0; i < args->n; i++)
704
+ args->result[i] = NUM2UINT(RARRAY_PTR(args->ary)[i]);
705
+
706
+ return Qnil;
707
+ }
708
+
709
+ static G_GNUC_NORETURN VALUE
710
+ rbg_rval2guint32s_rescue(VALUE value)
711
+ {
712
+ g_free(((struct rbg_rval2guint32s_args *)value)->result);
713
+
714
+ rb_exc_raise(rb_errinfo());
715
+ }
716
+
717
+ guint32 *
718
+ rbg_rval2guint32s(volatile VALUE *value, long *n)
719
+ {
720
+ struct rbg_rval2guint32s_args args;
721
+
722
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
723
+ args.n = RARRAY_LEN(args.ary);
724
+ args.result = g_new(guint32, args.n + 1);
725
+
726
+ rb_rescue(rbg_rval2guint32s_body, (VALUE)&args,
727
+ rbg_rval2guint32s_rescue, (VALUE)&args);
728
+
729
+ *n = args.n;
730
+
731
+ return args.result;
732
+ }
733
+
734
+ struct rbg_rval2gdoubles_args {
735
+ VALUE ary;
736
+ long n;
737
+ gdouble *result;
738
+ };
739
+
740
+ static VALUE
741
+ rbg_rval2gdoubles_body(VALUE value)
742
+ {
743
+ long i;
744
+ struct rbg_rval2gdoubles_args *args = (struct rbg_rval2gdoubles_args *)value;
745
+
746
+ for (i = 0; i < args->n; i++)
747
+ args->result[i] = NUM2DBL(RARRAY_PTR(args->ary)[i]);
748
+
749
+ return Qnil;
750
+ }
751
+
752
+ static G_GNUC_NORETURN VALUE
753
+ rbg_rval2gdoubles_rescue(VALUE value)
754
+ {
755
+ g_free(((struct rbg_rval2gdoubles_args *)value)->result);
756
+
757
+ rb_exc_raise(rb_errinfo());
758
+ }
759
+
760
+ gdouble *
761
+ rbg_rval2gdoubles(volatile VALUE *value, long *n)
762
+ {
763
+ struct rbg_rval2gdoubles_args args;
764
+
765
+ args.ary = *value = rb_ary_dup(rb_ary_to_ary(*value));
766
+ args.n = RARRAY_LEN(args.ary);
767
+ args.result = g_new(gdouble, args.n + 1);
768
+
769
+ rb_rescue(rbg_rval2gdoubles_body, (VALUE)&args,
770
+ rbg_rval2gdoubles_rescue, (VALUE)&args);
771
+
772
+ *n = args.n;
773
+
774
+ return args.result;
775
+ }
776
+
777
+ VALUE
778
+ rbg_gints2rval(const gint *gints, long n)
779
+ {
780
+ long i;
781
+ VALUE ary = rb_ary_new();
782
+
783
+ for (i = 0; i < n; i++)
784
+ rb_ary_push(ary, INT2NUM(gints[i]));
785
+
786
+ return ary;
787
+ }
788
+
789
+ struct rbg_gints2rval_free_args {
790
+ gint *gints;
791
+ long n;
792
+ };
793
+
794
+ static VALUE
795
+ rbg_gints2rval_free_body(VALUE value)
796
+ {
797
+ struct rbg_gints2rval_free_args *args = (struct rbg_gints2rval_free_args *)value;
798
+
799
+ return rbg_gints2rval(args->gints, args->n);
800
+ }
801
+
802
+ static VALUE
803
+ rbg_gints2rval_free_ensure(VALUE value)
804
+ {
805
+ g_free(((struct rbg_gints2rval_free_args *)value)->gints);
806
+
807
+ return Qnil;
808
+ }
809
+
810
+ VALUE
811
+ rbg_gints2rval_free(gint *gints, long n)
812
+ {
813
+ struct rbg_gints2rval_free_args args = { gints, n };
814
+
815
+ return rb_ensure(rbg_gints2rval_free_body, (VALUE)&args,
816
+ rbg_gints2rval_free_ensure, (VALUE)&args);
817
+ }
818
+
819
+ static const char *
820
+ rbg_inspect (VALUE object)
821
+ {
822
+ VALUE inspected;
823
+
824
+ inspected = rb_funcall(object, rb_intern("inspect"), 0);
825
+ return StringValueCStr(inspected);
826
+ }
827
+
828
+
829
+ void
830
+ rbg_scan_options (VALUE options, ...)
831
+ {
832
+ VALUE original_options = options;
833
+ VALUE available_keys;
834
+ const char *key;
835
+ VALUE *value;
836
+ va_list args;
837
+
838
+ options = rb_check_convert_type(options, T_HASH, "Hash", "to_hash");
839
+ if (NIL_P(options)) {
840
+ options = rb_hash_new();
841
+ } else if (options == original_options) {
842
+ options = rb_funcall(options, rb_intern("dup"), 0);
843
+ }
844
+
845
+ available_keys = rb_ary_new();
846
+ va_start(args, options);
847
+ key = va_arg(args, const char *);
848
+ while (key) {
849
+ VALUE rb_key;
850
+ value = va_arg(args, VALUE *);
851
+
852
+ rb_key = ID2SYM(rb_intern(key));
853
+ rb_ary_push(available_keys, rb_key);
854
+ *value = rb_funcall(options, rb_intern("delete"), 1, rb_key);
855
+
856
+ key = va_arg(args, const char *);
857
+ }
858
+ va_end(args);
859
+
860
+ if (RVAL2CBOOL(rb_funcall(options, rb_intern("empty?"), 0)))
861
+ return;
862
+
863
+ rb_raise(rb_eArgError,
864
+ "unexpected key(s) exist: %s: available keys: %s",
865
+ rbg_inspect(rb_funcall(options, rb_intern("keys"), 0)),
866
+ rbg_inspect(available_keys));
867
+ }
868
+
431
869
  #if 0
432
870
  /*
433
871
  2004-04-15 Commented out by Masao.
@@ -476,7 +914,7 @@ Init_mem()
476
914
  #endif
477
915
 
478
916
  static VALUE
479
- rbg_s_os_win32(VALUE self)
917
+ rg_m_os_win32_p(G_GNUC_UNUSED VALUE self)
480
918
  {
481
919
  #ifdef G_OS_WIN32
482
920
  return Qtrue;
@@ -486,7 +924,7 @@ rbg_s_os_win32(VALUE self)
486
924
  }
487
925
 
488
926
  static VALUE
489
- rbg_s_os_beos(VALUE self)
927
+ rg_m_os_beos_p(G_GNUC_UNUSED VALUE self)
490
928
  {
491
929
  #ifdef G_OS_BEOS
492
930
  return Qtrue;
@@ -496,7 +934,7 @@ rbg_s_os_beos(VALUE self)
496
934
  }
497
935
 
498
936
  static VALUE
499
- rbg_s_os_unix(VALUE self)
937
+ rg_m_os_unix_p(G_GNUC_UNUSED VALUE self)
500
938
  {
501
939
  #ifdef G_OS_UNIX
502
940
  return Qtrue;
@@ -505,8 +943,10 @@ rbg_s_os_unix(VALUE self)
505
943
  #endif
506
944
  }
507
945
 
508
- void
509
- Init_glib2()
946
+ extern void Init_glib2(void);
947
+
948
+ void
949
+ Init_glib2(void)
510
950
  {
511
951
  #ifdef HAVE_RUBY_ENCODING_H
512
952
  const gchar **filename_charsets;
@@ -514,82 +954,82 @@ Init_glib2()
514
954
 
515
955
  id_inspect = rb_intern("inspect");
516
956
 
517
- mGLib = rb_define_module("GLib");
957
+ RG_TARGET_NAMESPACE = rb_define_module("GLib");
518
958
 
519
959
  setlocale (LC_CTYPE, "");
520
- #if LC_MESSAGES
960
+ #ifdef LC_MESSAGES
521
961
  setlocale (LC_MESSAGES, "");
522
962
  #endif
523
963
 
524
964
  /* Version Information */
525
- rb_define_const(mGLib, "VERSION",
965
+ rb_define_const(RG_TARGET_NAMESPACE, "VERSION",
526
966
  rb_ary_new3(3,
527
967
  INT2FIX(glib_major_version),
528
968
  INT2FIX(glib_minor_version),
529
969
  INT2FIX(glib_micro_version)));
530
- rb_define_const(mGLib, "MAJOR_VERSION", INT2FIX(glib_major_version));
531
- rb_define_const(mGLib, "MINOR_VERSION", INT2FIX(glib_minor_version));
532
- rb_define_const(mGLib, "MICRO_VERSION", INT2FIX(glib_micro_version));
533
- rb_define_const(mGLib, "INTERFACE_AGE", INT2FIX(glib_interface_age));
534
- rb_define_const(mGLib, "BINARY_AGE", INT2FIX(glib_binary_age));
970
+ rb_define_const(RG_TARGET_NAMESPACE, "MAJOR_VERSION", INT2FIX(glib_major_version));
971
+ rb_define_const(RG_TARGET_NAMESPACE, "MINOR_VERSION", INT2FIX(glib_minor_version));
972
+ rb_define_const(RG_TARGET_NAMESPACE, "MICRO_VERSION", INT2FIX(glib_micro_version));
973
+ rb_define_const(RG_TARGET_NAMESPACE, "INTERFACE_AGE", INT2FIX(glib_interface_age));
974
+ rb_define_const(RG_TARGET_NAMESPACE, "BINARY_AGE", INT2FIX(glib_binary_age));
535
975
 
536
- rb_define_const(mGLib, "BINDING_VERSION",
976
+ rb_define_const(RG_TARGET_NAMESPACE, "BINDING_VERSION",
537
977
  rb_ary_new3(3,
538
978
  INT2FIX(RBGLIB_MAJOR_VERSION),
539
979
  INT2FIX(RBGLIB_MINOR_VERSION),
540
980
  INT2FIX(RBGLIB_MICRO_VERSION)));
541
981
 
542
- rb_define_const(mGLib, "BUILD_VERSION",
982
+ rb_define_const(RG_TARGET_NAMESPACE, "BUILD_VERSION",
543
983
  rb_ary_new3(3,
544
984
  INT2FIX(GLIB_MAJOR_VERSION),
545
985
  INT2FIX(GLIB_MINOR_VERSION),
546
986
  INT2FIX(GLIB_MICRO_VERSION)));
547
987
 
548
988
  /* Limits of Basic Types */
549
- rb_define_const(mGLib, "MININT", INT2FIX(G_MININT));
550
- rb_define_const(mGLib, "MAXINT", INT2NUM(G_MAXINT));
551
- rb_define_const(mGLib, "MAXUINT", UINT2NUM(G_MAXUINT));
552
-
553
- rb_define_const(mGLib, "MINSHORT", INT2FIX(G_MINSHORT));
554
- rb_define_const(mGLib, "MAXSHORT", INT2FIX(G_MAXSHORT));
555
- rb_define_const(mGLib, "MAXUSHORT", UINT2NUM(G_MAXUSHORT));
556
-
557
- rb_define_const(mGLib, "MINLONG", INT2FIX(G_MINLONG));
558
- rb_define_const(mGLib, "MAXLONG", INT2NUM(G_MAXLONG));
559
- rb_define_const(mGLib, "MAXULONG", UINT2NUM(G_MAXULONG));
989
+ rb_define_const(RG_TARGET_NAMESPACE, "MININT", INT2FIX(G_MININT));
990
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXINT", INT2NUM(G_MAXINT));
991
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT", UINT2NUM(G_MAXUINT));
992
+
993
+ rb_define_const(RG_TARGET_NAMESPACE, "MINSHORT", INT2FIX(G_MINSHORT));
994
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXSHORT", INT2FIX(G_MAXSHORT));
995
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUSHORT", UINT2NUM(G_MAXUSHORT));
996
+
997
+ rb_define_const(RG_TARGET_NAMESPACE, "MINLONG", INT2FIX(G_MINLONG));
998
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXLONG", INT2NUM(G_MAXLONG));
999
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXULONG", UINT2NUM(G_MAXULONG));
560
1000
 
561
1001
  #if GLIB_CHECK_VERSION(2,4,0)
562
- rb_define_const(mGLib, "MININT8", INT2FIX(G_MININT8));
563
- rb_define_const(mGLib, "MAXINT8", INT2FIX(G_MAXINT8));
564
- rb_define_const(mGLib, "MAXUINT8", UINT2NUM(G_MAXUINT8));
1002
+ rb_define_const(RG_TARGET_NAMESPACE, "MININT8", INT2FIX(G_MININT8));
1003
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXINT8", INT2FIX(G_MAXINT8));
1004
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT8", UINT2NUM(G_MAXUINT8));
565
1005
 
566
- rb_define_const(mGLib, "MININT16", INT2FIX(G_MININT16));
567
- rb_define_const(mGLib, "MAXINT16", INT2FIX(G_MAXINT16));
568
- rb_define_const(mGLib, "MAXUINT16", UINT2NUM(G_MAXUINT16));
1006
+ rb_define_const(RG_TARGET_NAMESPACE, "MININT16", INT2FIX(G_MININT16));
1007
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXINT16", INT2FIX(G_MAXINT16));
1008
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT16", UINT2NUM(G_MAXUINT16));
569
1009
 
570
- rb_define_const(mGLib, "MININT32", INT2FIX(G_MININT32));
571
- rb_define_const(mGLib, "MAXINT32", INT2NUM(G_MAXINT32));
572
- rb_define_const(mGLib, "MAXUINT32", UINT2NUM(G_MAXUINT32));
1010
+ rb_define_const(RG_TARGET_NAMESPACE, "MININT32", INT2FIX(G_MININT32));
1011
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXINT32", INT2NUM(G_MAXINT32));
1012
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT32", UINT2NUM(G_MAXUINT32));
573
1013
  #endif
574
- rb_define_const(mGLib, "MININT64", INT2FIX(G_MININT64));
575
- rb_define_const(mGLib, "MAXINT64", LL2NUM(G_MAXINT64));
576
- rb_define_const(mGLib, "MAXUINT64", ULL2NUM(G_MAXUINT64));
1014
+ rb_define_const(RG_TARGET_NAMESPACE, "MININT64", INT2FIX(G_MININT64));
1015
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXINT64", LL2NUM(G_MAXINT64));
1016
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXUINT64", ULL2NUM(G_MAXUINT64));
577
1017
  #if GLIB_CHECK_VERSION(2,4,0)
578
- rb_define_const(mGLib, "MAXSIZE", UINT2NUM(G_MAXSIZE));
1018
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXSIZE", UINT2NUM(G_MAXSIZE));
579
1019
  #endif
580
- rb_define_const(mGLib, "MINFLOAT", INT2FIX(G_MINFLOAT));
581
- rb_define_const(mGLib, "MAXFLOAT", DBL2NUM(G_MAXFLOAT));
1020
+ rb_define_const(RG_TARGET_NAMESPACE, "MINFLOAT", INT2FIX(G_MINFLOAT));
1021
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXFLOAT", DBL2NUM(G_MAXFLOAT));
582
1022
 
583
- rb_define_const(mGLib, "MINDOUBLE", INT2FIX(G_MINDOUBLE));
584
- rb_define_const(mGLib, "MAXDOUBLE", DBL2NUM(G_MAXDOUBLE));
1023
+ rb_define_const(RG_TARGET_NAMESPACE, "MINDOUBLE", INT2FIX(G_MINDOUBLE));
1024
+ rb_define_const(RG_TARGET_NAMESPACE, "MAXDOUBLE", DBL2NUM(G_MAXDOUBLE));
585
1025
 
586
1026
  /* Standard Macros */
587
- rb_define_module_function(mGLib, "os_win32?", rbg_s_os_win32, 0);
588
- rb_define_module_function(mGLib, "os_beos?", rbg_s_os_beos, 0);
589
- rb_define_module_function(mGLib, "os_unix?", rbg_s_os_unix, 0);
1027
+ RG_DEF_MODFUNC_P(os_win32, 0);
1028
+ RG_DEF_MODFUNC_P(os_beos, 0);
1029
+ RG_DEF_MODFUNC_P(os_unix, 0);
590
1030
 
591
- rb_define_const(mGLib, "DIR_SEPARATOR", CSTR2RVAL(G_DIR_SEPARATOR_S));
592
- rb_define_const(mGLib, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S));
1031
+ rb_define_const(RG_TARGET_NAMESPACE, "DIR_SEPARATOR", CSTR2RVAL(G_DIR_SEPARATOR_S));
1032
+ rb_define_const(RG_TARGET_NAMESPACE, "SEARCHPATH_SEPARATOR", CSTR2RVAL(G_SEARCHPATH_SEPARATOR_S));
593
1033
 
594
1034
  /* discover and store glib filename encoding */
595
1035
  #ifdef HAVE_RUBY_ENCODING_H
@@ -631,22 +1071,21 @@ Init_glib2()
631
1071
  union GFloatIEEE754;
632
1072
  union GDoubleIEEE754;
633
1073
  */
634
- rb_define_const(mGLib, "E", CSTR2RVAL(G_STRINGIFY(G_E)));
635
- rb_define_const(mGLib, "LN2", CSTR2RVAL(G_STRINGIFY(G_LN2)));
636
- rb_define_const(mGLib, "LN10", CSTR2RVAL(G_STRINGIFY(G_LN10)));
637
- rb_define_const(mGLib, "PI", CSTR2RVAL(G_STRINGIFY(G_PI)));
638
- rb_define_const(mGLib, "PI_2", CSTR2RVAL(G_STRINGIFY(G_PI_2)));
639
- rb_define_const(mGLib, "PI_4", CSTR2RVAL(G_STRINGIFY(G_PI_4)));
640
- rb_define_const(mGLib, "SQRT2", CSTR2RVAL(G_STRINGIFY(G_SQRT2)));
641
- rb_define_const(mGLib, "LOG_2_BASE_10", CSTR2RVAL(G_STRINGIFY(G_LOG_2_BASE_10)));
1074
+ rb_define_const(RG_TARGET_NAMESPACE, "E", CSTR2RVAL(G_STRINGIFY(G_E)));
1075
+ rb_define_const(RG_TARGET_NAMESPACE, "LN2", CSTR2RVAL(G_STRINGIFY(G_LN2)));
1076
+ rb_define_const(RG_TARGET_NAMESPACE, "LN10", CSTR2RVAL(G_STRINGIFY(G_LN10)));
1077
+ rb_define_const(RG_TARGET_NAMESPACE, "PI", CSTR2RVAL(G_STRINGIFY(G_PI)));
1078
+ rb_define_const(RG_TARGET_NAMESPACE, "PI_2", CSTR2RVAL(G_STRINGIFY(G_PI_2)));
1079
+ rb_define_const(RG_TARGET_NAMESPACE, "PI_4", CSTR2RVAL(G_STRINGIFY(G_PI_4)));
1080
+ rb_define_const(RG_TARGET_NAMESPACE, "SQRT2", CSTR2RVAL(G_STRINGIFY(G_SQRT2)));
1081
+ rb_define_const(RG_TARGET_NAMESPACE, "LOG_2_BASE_10", CSTR2RVAL(G_STRINGIFY(G_LOG_2_BASE_10)));
642
1082
 
643
1083
  /* From "The Main Event Loop" */
644
- rb_define_const(mGLib, "PRIORITY_HIGH", INT2FIX(G_PRIORITY_HIGH));
645
- rb_define_const(mGLib, "PRIORITY_DEFAULT", INT2FIX(G_PRIORITY_DEFAULT));
646
- rb_define_const(mGLib, "PRIORITY_HIGH_IDLE", INT2FIX(G_PRIORITY_HIGH_IDLE));
647
- rb_define_const(mGLib, "PRIORITY_DEFAULT_IDLE", INT2FIX(G_PRIORITY_DEFAULT_IDLE));
648
- rb_define_const(mGLib, "PRIORITY_LOW", INT2FIX(G_PRIORITY_LOW));
649
-
1084
+ rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_HIGH", INT2FIX(G_PRIORITY_HIGH));
1085
+ rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_DEFAULT", INT2FIX(G_PRIORITY_DEFAULT));
1086
+ rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_HIGH_IDLE", INT2FIX(G_PRIORITY_HIGH_IDLE));
1087
+ rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_DEFAULT_IDLE", INT2FIX(G_PRIORITY_DEFAULT_IDLE));
1088
+ rb_define_const(RG_TARGET_NAMESPACE, "PRIORITY_LOW", INT2FIX(G_PRIORITY_LOW));
650
1089
 
651
1090
  /* Init_mem(); */
652
1091
  Init_gutil();
@@ -665,18 +1104,26 @@ union GDoubleIEEE754;
665
1104
  /* Require GBoxed/GObject */
666
1105
  Init_glib_utils();
667
1106
  Init_glib_spawn();
1107
+ Init_glib_spawnerror();
668
1108
  Init_glib_main_loop();
669
1109
  Init_glib_source();
670
1110
  Init_glib_main_context();
671
1111
  Init_glib_poll_fd();
672
1112
  Init_glib_io_channel();
1113
+ Init_glib_io_channelerror();
1114
+ Init_glib_io_channel_win32_socket();
673
1115
  Init_glib_shell();
1116
+ Init_glib_shellerror();
674
1117
  Init_glib_completion();
675
1118
  Init_glib_timer();
676
1119
  Init_glib_unicode();
1120
+ Init_glib_utf8();
1121
+ Init_glib_utf16();
1122
+ Init_glib_ucs4();
1123
+ Init_glib_unichar();
677
1124
  Init_glib_keyfile();
678
1125
  Init_glib_bookmark_file();
679
1126
 
680
1127
  /* This is called here once. */
681
- G_DEF_SETTERS(mGLib);
1128
+ G_DEF_SETTERS(RG_TARGET_NAMESPACE);
682
1129
  }