glib2 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/glib2/extconf.rb +1 -0
- data/ext/glib2/glib2.def +23 -0
- data/ext/glib2/rbgcompat.h +19 -5
- data/ext/glib2/rbglib.c +607 -160
- data/ext/glib2/rbglib.h +81 -26
- data/ext/glib2/rbglib2conversions.h +57 -0
- data/ext/glib2/rbglib_bookmarkfile.c +117 -107
- data/ext/glib2/rbglib_completion.c +37 -26
- data/ext/glib2/rbglib_convert.c +42 -30
- data/ext/glib2/rbglib_error.c +20 -10
- data/ext/glib2/rbglib_fileutils.c +48 -37
- data/ext/glib2/rbglib_i18n.c +24 -14
- data/ext/glib2/rbglib_int64.c +24 -16
- data/ext/glib2/rbglib_iochannel.c +146 -204
- data/ext/glib2/rbglib_iochannel_win32_socket.c +56 -0
- data/ext/glib2/rbglib_iochannelerror.c +49 -0
- data/ext/glib2/rbglib_keyfile.c +171 -182
- data/ext/glib2/rbglib_maincontext.c +107 -92
- data/ext/glib2/rbglib_mainloop.c +34 -21
- data/ext/glib2/rbglib_messages.c +53 -44
- data/ext/glib2/rbglib_pollfd.c +37 -26
- data/ext/glib2/rbglib_shell.c +29 -22
- data/ext/glib2/rbglib_shellerror.c +34 -0
- data/ext/glib2/rbglib_source.c +49 -36
- data/ext/glib2/rbglib_spawn.c +50 -61
- data/ext/glib2/rbglib_spawnerror.c +53 -0
- data/ext/glib2/rbglib_threads.c +28 -16
- data/ext/glib2/rbglib_timer.c +35 -24
- data/ext/glib2/rbglib_ucs4.c +79 -0
- data/ext/glib2/rbglib_unichar.c +209 -0
- data/ext/glib2/rbglib_unicode.c +34 -584
- data/ext/glib2/rbglib_utf16.c +78 -0
- data/ext/glib2/rbglib_utf8.c +259 -0
- data/ext/glib2/rbglib_utils.c +95 -91
- data/ext/glib2/rbglib_win32.c +52 -45
- data/ext/glib2/rbglibdeprecated.c +56 -0
- data/ext/glib2/rbglibdeprecated.h +34 -0
- data/ext/glib2/rbgobj_boxed.c +40 -33
- data/ext/glib2/rbgobj_closure.c +45 -34
- data/ext/glib2/rbgobj_convert.c +19 -9
- data/ext/glib2/rbgobj_enumflags.c +109 -0
- data/ext/glib2/rbgobj_enums.c +67 -646
- data/ext/glib2/rbgobj_flags.c +522 -0
- data/ext/glib2/rbgobj_fundamental.c +19 -6
- data/ext/glib2/rbgobj_object.c +90 -81
- data/ext/glib2/rbgobj_param.c +78 -83
- data/ext/glib2/rbgobj_paramspecs.c +20 -12
- data/ext/glib2/rbgobj_signal.c +248 -193
- data/ext/glib2/rbgobj_strv.c +20 -10
- data/ext/glib2/rbgobj_type.c +153 -149
- data/ext/glib2/rbgobj_typeinstance.c +49 -39
- data/ext/glib2/rbgobj_typeinterface.c +37 -27
- data/ext/glib2/rbgobj_typemodule.c +39 -29
- data/ext/glib2/rbgobj_typeplugin.c +36 -26
- data/ext/glib2/rbgobj_value.c +41 -11
- data/ext/glib2/rbgobj_valuearray.c +59 -23
- data/ext/glib2/rbgobj_valuetypes.c +27 -17
- data/ext/glib2/rbgobject.c +26 -40
- data/ext/glib2/rbgobject.h +38 -20
- data/ext/glib2/rbgprivate.h +87 -5
- data/ext/glib2/rbgutil.c +52 -238
- data/ext/glib2/rbgutil.h +55 -42
- data/ext/glib2/rbgutil_callback.c +47 -12
- data/ext/glib2/rbgutil_list.c +173 -0
- data/ext/glib2/rbgutil_list.h +85 -0
- data/ext/glib2/rbgutildeprecated.c +252 -0
- data/ext/glib2/rbgutildeprecated.h +63 -0
- data/lib/glib-mkenums.rb +2 -2
- data/lib/glib2.rb +2 -25
- data/lib/glib2/deprecatable.rb +149 -0
- data/lib/gnome2-raketask.rb +45 -15
- data/lib/gnome2-win32-binary-downloader.rb +1 -1
- data/lib/mkmf-gnome2.rb +37 -18
- data/test/test_flags.rb +129 -0
- data/test/test_key_file.rb +6 -2
- data/test/test_spawn.rb +33 -0
- metadata +26 -7
- data/ChangeLog +0 -3513
data/ext/glib2/rbglib_win32.c
CHANGED
@@ -1,28 +1,39 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
34
|
-
|
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
|
-
|
49
|
+
rg_m_get_package_installation_directory(VALUE self, VALUE package, VALUE dll_name)
|
39
50
|
{
|
40
|
-
|
41
|
-
|
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
|
-
|
56
|
+
rg_m_get_package_installation_subdirectory(VALUE self, VALUE package, VALUE dll_name, VALUE subdir)
|
46
57
|
{
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
65
|
+
rg_m_version(VALUE self)
|
55
66
|
{
|
56
|
-
|
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
|
-
|
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
|
-
|
72
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
100
|
+
hmodule = NULL;
|
90
101
|
else
|
91
|
-
|
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
|
115
|
+
VALUE RG_TARGET_NAMESPACE = rb_define_module_under(mGLib, "Win32");
|
105
116
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
-
|
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
|
-
|
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__ */
|
data/ext/glib2/rbgobj_boxed.c
CHANGED
@@ -1,19 +1,29 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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(
|
233
|
-
rb_define_singleton_method(
|
234
|
-
rb_define_method(
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
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
|
+
}
|
data/ext/glib2/rbgobj_closure.c
CHANGED
@@ -1,18 +1,29 @@
|
|
1
1
|
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
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*
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
+
}
|