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
@@ -1,28 +1,39 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
-
4
- rbglib_win32.c -
5
-
6
- $Author: mutoh $
7
- $Date: 2006/12/26 15:49:16 $
8
-
9
- Copyright (C) 2006 Kouhei Sutou
10
-
11
- **********************************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2006 Kouhei Sutou
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 "rbgprivate.h"
14
23
  #include "rbglib.h"
15
- #include <glib/gwin32.h>
16
24
 
17
25
  #ifdef G_OS_WIN32
26
+
27
+ #define RG_TARGET_NAMESPACE mWin32
28
+
18
29
  static VALUE
19
- rbglib_m_win32_error_message(VALUE self, VALUE error)
30
+ rg_m_error_message(VALUE self, VALUE error)
20
31
  {
21
32
  return CSTR2RVAL_FREE(g_win32_error_message(NUM2INT(error)));
22
33
  }
23
34
 
24
35
  static VALUE
25
- rbglib_m_win32_locale(VALUE self)
36
+ rg_m_locale(VALUE self)
26
37
  {
27
38
  return CSTR2RVAL_FREE(g_win32_getlocale());
28
39
  }
@@ -30,36 +41,36 @@ rbglib_m_win32_locale(VALUE self)
30
41
  static VALUE
31
42
  rbglib_m_win32_locale_deprecated(VALUE self)
32
43
  {
33
- rb_warn("GLib.win32_locale() is deprecated. Use GLib::Win32.locale instead");
34
- return rbglib_m_win32_locale(self);
44
+ rb_warn("GLib.win32_locale() is deprecated. Use GLib::Win32.locale instead");
45
+ return rg_m_locale(self);
35
46
  }
36
47
 
37
48
  static VALUE
38
- rbglib_m_win32_get_package_installation_directory(VALUE self, VALUE package, VALUE dll_name)
49
+ rg_m_get_package_installation_directory(VALUE self, VALUE package, VALUE dll_name)
39
50
  {
40
- return CSTR2RVAL_FREE(g_win32_get_package_installation_directory(RVAL2CSTR(package),
41
- RVAL2CSTR(dll_name)));
51
+ return CSTR2RVAL_FREE(g_win32_get_package_installation_directory(RVAL2CSTR(package),
52
+ RVAL2CSTR(dll_name)));
42
53
  }
43
54
 
44
55
  static VALUE
45
- rbglib_m_get_package_installation_subdirectory(VALUE self, VALUE package, VALUE dll_name, VALUE subdir)
56
+ rg_m_get_package_installation_subdirectory(VALUE self, VALUE package, VALUE dll_name, VALUE subdir)
46
57
  {
47
- return CSTR2RVAL_FREE(g_win32_get_package_installation_subdirectory(RVAL2CSTR(package),
48
- RVAL2CSTR(dll_name),
49
- RVAL2CSTR(subdir)));
58
+ return CSTR2RVAL_FREE(g_win32_get_package_installation_subdirectory(RVAL2CSTR(package),
59
+ RVAL2CSTR(dll_name),
60
+ RVAL2CSTR(subdir)));
50
61
  }
51
62
 
52
63
  #if GLIB_CHECK_VERSION(2,6,0)
53
64
  static VALUE
54
- rbglib_m_get_windows_version(VALUE self)
65
+ rg_m_version(VALUE self)
55
66
  {
56
- return UINT2NUM(g_win32_get_windows_version());
67
+ return UINT2NUM(g_win32_get_windows_version());
57
68
  }
58
69
  #endif
59
70
 
60
71
  #if GLIB_CHECK_VERSION(2,8,0)
61
72
  static VALUE
62
- rbglib_m_win32_locale_filename_from_utf8(VALUE self, VALUE utf8_filename)
73
+ rg_m_locale_filename_from_utf8(VALUE self, VALUE utf8_filename)
63
74
  {
64
75
  return CSTR2RVAL_FREE(g_win32_locale_filename_from_utf8(RVAL2CSTR(utf8_filename)));
65
76
  }
@@ -68,17 +79,17 @@ static VALUE
68
79
  rbglib_m_win32_locale_filename_from_utf8_deprecated(VALUE self,
69
80
  VALUE utf8_filename)
70
81
  {
71
- rb_warn("GLib.win32_locale_filename_from_utf8() is deprecated. Use GLib::Win32.locale_filename_from_utf8 instead");
72
- return rbglib_m_win32_locale_filename_from_utf8(self, utf8_filename);
82
+ rb_warn("GLib.win32_locale_filename_from_utf8() is deprecated. Use GLib::Win32.locale_filename_from_utf8 instead");
83
+ return rg_m_locale_filename_from_utf8(self, utf8_filename);
73
84
  }
74
85
 
75
86
  #endif
76
87
 
77
88
  # if GLIB_CHECK_VERSION(2, 16, 0)
78
89
  static VALUE
79
- rbglib_m_win32_get_package_installation_directory_of_module(int argc,
80
- VALUE *argv,
81
- VALUE self)
90
+ rg_m_get_package_installation_directory_of_module(int argc,
91
+ VALUE *argv,
92
+ VALUE self)
82
93
  {
83
94
  VALUE rb_module;
84
95
  gchar *directory;
@@ -86,9 +97,9 @@ rbglib_m_win32_get_package_installation_directory_of_module(int argc,
86
97
 
87
98
  rb_scan_args(argc, argv, "01", &rb_module);
88
99
  if (NIL_P(rb_module))
89
- hmodule = NULL;
100
+ hmodule = NULL;
90
101
  else
91
- hmodule = GINT_TO_POINTER(NUM2INT(rb_module));
102
+ hmodule = GINT_TO_POINTER(NUM2INT(rb_module));
92
103
 
93
104
  directory = g_win32_get_package_installation_directory_of_module(hmodule);
94
105
  return CSTR2RVAL_FREE(directory);
@@ -97,33 +108,29 @@ rbglib_m_win32_get_package_installation_directory_of_module(int argc,
97
108
  #endif
98
109
 
99
110
  void
100
- Init_glib_win32()
111
+ Init_glib_win32(void)
101
112
  {
102
113
  #ifdef G_OS_WIN32
103
114
  /* glib/gwin32.h */
104
- VALUE mWin32 = rb_define_module_under(mGLib, "Win32");
115
+ VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Win32");
105
116
 
106
- rb_define_module_function(mWin32, "error_message", rbglib_m_win32_error_message, 1);
107
- rb_define_module_function(mWin32, "locale", rbglib_m_win32_locale, 0);
108
- rb_define_module_function(mWin32, "get_package_installation_directory", rbglib_m_win32_get_package_installation_directory, 2);
109
- rb_define_module_function(mWin32, "get_package_installation_subdirectory", rbglib_m_get_package_installation_subdirectory, 3);
110
- rb_define_module_function(mWin32, "version", rbglib_m_get_windows_version, 0);
117
+ RG_DEF_MODFUNC(error_message, 1);
118
+ RG_DEF_MODFUNC(locale, 0);
119
+ RG_DEF_MODFUNC(get_package_installation_directory, 2);
120
+ RG_DEF_MODFUNC(get_package_installation_subdirectory, 3);
121
+ RG_DEF_MODFUNC(version, 0);
111
122
  /* Deprecated */
112
123
  rb_define_module_function(mGLib, "win32_locale", rbglib_m_win32_locale_deprecated, 0);
113
124
 
114
125
  # if GLIB_CHECK_VERSION(2,8,0)
115
- rb_define_module_function(mWin32, "locale_filename_from_utf8",
116
- rbglib_m_win32_locale_filename_from_utf8, 1);
126
+ RG_DEF_MODFUNC(locale_filename_from_utf8, 1);
117
127
  /* Deprecated */
118
128
  rb_define_module_function(mGLib, "win32_locale_filename_from_utf8",
119
129
  rbglib_m_win32_locale_filename_from_utf8_deprecated, 1);
120
130
  # endif
121
131
 
122
132
  # if GLIB_CHECK_VERSION(2, 16, 0)
123
- rb_define_module_function(mWin32,
124
- "get_package_installation_directory_of_module",
125
- rbglib_m_win32_get_package_installation_directory_of_module,
126
- -1);
133
+ RG_DEF_MODFUNC(get_package_installation_directory_of_module, -1);
127
134
  # endif
128
135
  #endif
129
136
  }
@@ -0,0 +1,56 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
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
+ */
21
+
22
+ #include "rbgprivate.h"
23
+
24
+ static VALUE
25
+ rbg_filename_gslist_to_array_free_body(VALUE list)
26
+ {
27
+ VALUE ary = rb_ary_new();
28
+ GSList *p;
29
+
30
+ for (p = (GSList *)list; p != NULL; p = g_slist_next(p))
31
+ rb_ary_push(ary, CSTRFILENAME2RVAL(p->data));
32
+
33
+ return ary;
34
+ }
35
+
36
+ static VALUE
37
+ rbg_filename_gslist_to_array_free_ensure(VALUE val)
38
+ {
39
+ GSList *list = (GSList *)val;
40
+ GSList *p;
41
+
42
+ for (p = list; p != NULL; p = g_slist_next(p))
43
+ g_free((gchar *)p->data);
44
+
45
+ g_slist_free(list);
46
+
47
+ return Qnil;
48
+ }
49
+
50
+ VALUE
51
+ rbg_filename_gslist_to_array_free(GSList *list)
52
+ {
53
+ return rb_ensure(rbg_filename_gslist_to_array_free_body, (VALUE)list,
54
+ rbg_filename_gslist_to_array_free_ensure, (VALUE)list);
55
+ }
56
+
@@ -0,0 +1,34 @@
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2005 Ruby-GNOME2 Project
5
+ * Copyright (C) 2002,2003 Masahiro Sakai
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
+ * MA 02110-1301 USA
21
+ */
22
+
23
+ #ifndef __RBGLIBDEPRECATED_H__
24
+ #define __RBGLIBDEPRECATED_H__
25
+
26
+ G_BEGIN_DECLS
27
+
28
+ #define CSTRFILENAMEARRAY2RVAL_FREE(s) (rbg_filename_gslist_to_array_free(s))
29
+
30
+ extern VALUE rbg_filename_gslist_to_array_free(GSList *list);
31
+
32
+ G_END_DECLS
33
+
34
+ #endif /* __RBGLIBDEPRECATED_H__ */
@@ -1,19 +1,29 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
-
4
- rbgobj_boxed.c -
5
-
6
- $Author: sakai $
7
- $Date: 2007/07/14 13:33:07 $
8
- created at: Sat Jul 27 16:56:01 JST 2002
9
-
10
- Copyright (C) 2002,2003 Masahiro Sakai
11
-
12
- **********************************************************************/
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
+ */
13
21
 
14
22
  #include "rbgprivate.h"
15
23
 
16
- VALUE rbgobj_cBoxed;
24
+ #define RG_TARGET_NAMESPACE rbgobj_cBoxed
25
+
26
+ VALUE RG_TARGET_NAMESPACE;
17
27
 
18
28
  static void
19
29
  boxed_mark(boxed_holder *holder)
@@ -61,15 +71,15 @@ rbgobj_boxed_s_allocate(VALUE klass)
61
71
  return result;
62
72
  }
63
73
 
64
- static VALUE
65
- rbgobj_boxed_init(VALUE self)
74
+ static G_GNUC_NORETURN VALUE
75
+ rg_initialize(VALUE self)
66
76
  {
67
77
  rb_raise(rb_eTypeError, "can't initialize %s",
68
78
  rb_class2name(CLASS_OF(self)));
69
79
  }
70
80
 
71
81
  static VALUE
72
- rbgobj_boxed_inspect(VALUE self)
82
+ rg_inspect(VALUE self)
73
83
  {
74
84
  boxed_holder* holder;
75
85
  gchar* s;
@@ -90,7 +100,7 @@ rbgobj_boxed_inspect(VALUE self)
90
100
  }
91
101
 
92
102
  static VALUE
93
- rbgobj_boxed_init_copy(VALUE self, VALUE orig)
103
+ rg_initialize_copy(VALUE self, VALUE orig)
94
104
  {
95
105
  boxed_holder* holder1;
96
106
  boxed_holder* holder2;
@@ -98,7 +108,7 @@ rbgobj_boxed_init_copy(VALUE self, VALUE orig)
98
108
  if (self == orig) return self;
99
109
 
100
110
  if (!rb_obj_is_instance_of(orig, rb_obj_class(self))) {
101
- rb_raise(rb_eTypeError, "wrong argument class");
111
+ rb_raise(rb_eTypeError, "wrong argument class");
102
112
  }
103
113
 
104
114
  Data_Get_Struct(self, boxed_holder, holder1);
@@ -160,12 +170,12 @@ rbgobj_make_boxed(gpointer p, GType gtype)
160
170
 
161
171
  if (!p)
162
172
  return Qnil;
163
-
173
+
164
174
  cinfo = GTYPE2CINFO(gtype);
165
175
  result = rbgobj_boxed_s_allocate(cinfo->klass);
166
-
176
+
167
177
  Data_Get_Struct(result, boxed_holder, holder);
168
-
178
+
169
179
  if (cinfo->flags & RBGOBJ_BOXED_NOT_COPY){
170
180
  holder->boxed = p;
171
181
  holder->own = FALSE;
@@ -219,21 +229,18 @@ boxed_from_ruby(VALUE from, GValue* to)
219
229
  /**********************************************************************/
220
230
 
221
231
  void
222
- Init_gobject_gboxed()
232
+ Init_gobject_gboxed(void)
223
233
  {
224
- VALUE gBoxed;
225
-
226
- rbgobj_cBoxed = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", mGLib);
227
- gBoxed = rbgobj_cBoxed;
234
+ RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_BOXED, "Boxed", mGLib);
228
235
 
229
236
  rbgobj_register_g2r_func(G_TYPE_BOXED, boxed_to_ruby);
230
237
  rbgobj_register_r2g_func(G_TYPE_BOXED, boxed_from_ruby);
231
238
 
232
- rb_define_alloc_func(gBoxed, (VALUE(*)_((VALUE)))rbgobj_boxed_s_allocate);
233
- rb_define_singleton_method(gBoxed, "gtype", generic_s_gtype, 0);
234
- rb_define_method(gBoxed, "gtype", generic_gtype, 0);
235
- rb_define_method(gBoxed, "initialize", rbgobj_boxed_init, 0);
236
- rb_define_method(gBoxed, "inspect", rbgobj_boxed_inspect, 0);
237
- rb_define_method(gBoxed, "initialize_copy", rbgobj_boxed_init_copy, 1);
238
- rb_define_alias(gBoxed, "copy", "dup");
239
- }
239
+ rb_define_alloc_func(RG_TARGET_NAMESPACE, (VALUE(*)_((VALUE)))rbgobj_boxed_s_allocate);
240
+ rb_define_singleton_method(RG_TARGET_NAMESPACE, "gtype", generic_s_gtype, 0);
241
+ rb_define_method(RG_TARGET_NAMESPACE, "gtype", generic_gtype, 0);
242
+ RG_DEF_METHOD(initialize, 0);
243
+ RG_DEF_METHOD(inspect, 0);
244
+ RG_DEF_METHOD(initialize_copy, 1);
245
+ RG_DEF_ALIAS("copy", "dup");
246
+ }
@@ -1,18 +1,29 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
-
4
- rbgobj_closure.c -
5
-
6
- $Author: ggc $
7
- $Date: 2007/07/13 14:27:06 $
8
-
9
- Copyright (C) 2002-2006 Ruby-GNOME2 Project
10
- Copyright (C) 2002,2003 Masahiro Sakai
11
-
12
- **********************************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2002-2006 Ruby-GNOME2 Project
5
+ * Copyright (C) 2002,2003 Masahiro Sakai
6
+ *
7
+ * This library is free software; you can redistribute it and/or
8
+ * modify it under the terms of the GNU Lesser General Public
9
+ * License as published by the Free Software Foundation; either
10
+ * version 2.1 of the License, or (at your option) any later version.
11
+ *
12
+ * This library is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
+ * Lesser General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU Lesser General Public
18
+ * License along with this library; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
+ * MA 02110-1301 USA
21
+ */
13
22
 
14
23
  #include "rbgprivate.h"
15
24
 
25
+ #define RG_TARGET_NAMESPACE cClosure
26
+
16
27
  static ID id_call, id_closures;
17
28
  static gboolean rclosure_initialized = FALSE;
18
29
 
@@ -148,15 +159,14 @@ rclosure_unref(GRClosure *rclosure)
148
159
  g_list_free(rclosure->objects);
149
160
  rclosure->objects = NULL;
150
161
  if (!NIL_P(rclosure->rb_holder)) {
151
- RDATA(rclosure->rb_holder)->dmark = NULL;
152
- RDATA(rclosure->rb_holder)->dfree = NULL;
162
+ DATA_PTR(rclosure->rb_holder) = NULL;
153
163
  rclosure->rb_holder = Qnil;
154
164
  }
155
165
  }
156
166
  }
157
167
 
158
168
  static void
159
- rclosure_invalidate(gpointer data, GClosure* closure)
169
+ rclosure_invalidate(G_GNUC_UNUSED gpointer data, GClosure *closure)
160
170
  {
161
171
  GRClosure *rclosure = (GRClosure*)closure;
162
172
 
@@ -178,6 +188,9 @@ rclosure_invalidate(gpointer data, GClosure* closure)
178
188
  static void
179
189
  gr_closure_holder_mark(GRClosure *rclosure)
180
190
  {
191
+ if (!rclosure)
192
+ return;
193
+
181
194
  rb_gc_mark(rclosure->callback);
182
195
  rb_gc_mark(rclosure->extra_args);
183
196
  }
@@ -185,6 +198,9 @@ gr_closure_holder_mark(GRClosure *rclosure)
185
198
  static void
186
199
  gr_closure_holder_free(GRClosure *rclosure)
187
200
  {
201
+ if (!rclosure)
202
+ return;
203
+
188
204
  if (rclosure->count > 0) {
189
205
  rclosure->count = 1;
190
206
 
@@ -264,13 +280,13 @@ g_rclosure_set_tag(GClosure *closure, const gchar *tag)
264
280
  }
265
281
 
266
282
  static void
267
- rclosure_end_proc(VALUE _)
283
+ rclosure_end_proc(G_GNUC_UNUSED VALUE _)
268
284
  {
269
285
  rclosure_initialized = FALSE;
270
286
  }
271
287
 
272
288
  static void
273
- Init_rclosure()
289
+ init_rclosure(void)
274
290
  {
275
291
  id_call = rb_intern("call");
276
292
  id_closures = rb_intern("closures");
@@ -281,7 +297,7 @@ Init_rclosure()
281
297
  /**********************************************************************/
282
298
 
283
299
  static VALUE
284
- closure_initialize(VALUE self)
300
+ rg_initialize(VALUE self)
285
301
  {
286
302
  GClosure* closure = g_rclosure_new(rb_block_proc(), Qnil, NULL);
287
303
  G_INITIALIZE(self, closure);
@@ -290,43 +306,38 @@ closure_initialize(VALUE self)
290
306
  }
291
307
 
292
308
  static VALUE
293
- closure_in_marshal(VALUE self)
309
+ rg_in_marshal_p(VALUE self)
294
310
  {
295
311
  GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE);
296
312
  return CBOOL2RVAL(closure->in_marshal);
297
313
  }
298
314
 
299
315
  static VALUE
300
- closure_is_invalid(VALUE self)
316
+ rg_invalid_p(VALUE self)
301
317
  {
302
318
  GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE);
303
319
  return CBOOL2RVAL(closure->is_invalid);
304
320
  }
305
321
 
306
322
  static VALUE
307
- closure_invalidate(VALUE self)
323
+ rg_invalidate(VALUE self)
308
324
  {
309
325
  GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE);
310
326
  g_closure_invalidate(closure);
311
327
  return self;
312
328
  }
313
329
 
314
- static void
315
- Init_closure()
316
- {
317
- VALUE cClosure = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", mGLib);
318
- rb_define_method(cClosure, "initialize", closure_initialize, 0);
319
- rb_define_method(cClosure, "in_marshal?", closure_in_marshal, 0);
320
- rb_define_method(cClosure, "invalid?", closure_is_invalid, 0);
321
- rb_define_method(cClosure, "invalidate", closure_invalidate, 0);
322
- }
323
-
324
330
  /**********************************************************************/
325
331
 
326
332
  void
327
- Init_gobject_gclosure()
333
+ Init_gobject_gclosure(void)
328
334
  {
329
- Init_rclosure();
330
- Init_closure();
331
- }
335
+ init_rclosure();
332
336
 
337
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_CLOSURE, "Closure", mGLib);
338
+
339
+ RG_DEF_METHOD(initialize, 0);
340
+ RG_DEF_METHOD_P(in_marshal, 0);
341
+ RG_DEF_METHOD_P(invalid, 0);
342
+ RG_DEF_METHOD(invalidate, 0);
343
+ }