gio2 2.1.0-x86-mingw32 → 2.2.0-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +26 -9
- data/ext/gio2/extconf.rb +38 -28
- data/ext/gio2/rb-gio2-pollable-source.c +59 -0
- data/ext/gio2/{rbgiofilteroutputstream.c → rb-gio2.c} +9 -5
- data/ext/gio2/{gio2.c → rb-gio2.h} +5 -10
- data/extconf.rb +22 -6
- data/lib/1.9/gio2.so +0 -0
- data/lib/2.0/gio2.so +0 -0
- data/lib/2.1/gio2.so +0 -0
- data/lib/gio2/deprecated.rb +16 -0
- data/lib/gio2/inet-address.rb +33 -0
- data/lib/gio2/input-stream.rb +39 -0
- data/lib/gio2/loader.rb +244 -0
- data/lib/gio2/output-stream.rb +24 -0
- data/lib/gio2/pollable-input-stream.rb +51 -0
- data/lib/gio2/pollable-output-stream.rb +32 -0
- data/lib/gio2/resources.rb +62 -0
- data/lib/gio2.rb +38 -143
- data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
- data/test/fixture/resource/Rakefile +32 -0
- data/test/fixture/resource/logo.png +0 -0
- data/test/fixture/resource/ruby-gio2.gresource +0 -0
- data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
- data/test/gio2-test-utils/fixture.rb +24 -0
- data/test/gio2-test-utils/socket-client.rb +59 -0
- data/test/gio2-test-utils.rb +21 -0
- data/test/run-test.rb +45 -9
- data/test/test-buffered-input-stream.rb +23 -0
- data/test/test-charset-converter.rb +23 -0
- data/test/test-content-type.rb +31 -0
- data/test/test-data-input-stream.rb +21 -0
- data/test/test-file-enumerator.rb +26 -0
- data/test/test-file-monitor.rb +33 -0
- data/test/test-file.rb +28 -0
- data/test/test-inet-address.rb +34 -0
- data/test/test-input-stream.rb +36 -0
- data/test/test-output-stream.rb +39 -0
- data/test/test-pollable-input-stream.rb +54 -0
- data/test/test-pollable-output-stream.rb +53 -0
- data/test/test-resources.rb +58 -0
- metadata +49 -107
- data/README +0 -34
- data/ext/gio2/depend +0 -11
- data/ext/gio2/gio2.def +0 -2
- data/ext/gio2/gio2.h +0 -30
- data/ext/gio2/rbgio.c +0 -133
- data/ext/gio2/rbgio2.h +0 -158
- data/ext/gio2/rbgio2conversions.h +0 -154
- data/ext/gio2/rbgio2private.h +0 -148
- data/ext/gio2/rbgioappinfo.c +0 -317
- data/ext/gio2/rbgioapplaunchcontext.c +0 -81
- data/ext/gio2/rbgioasyncinitable.c +0 -246
- data/ext/gio2/rbgioasyncresult.c +0 -41
- data/ext/gio2/rbgiobufferedinputstream.c +0 -167
- data/ext/gio2/rbgiobufferedoutputstream.c +0 -50
- data/ext/gio2/rbgiocancellable.c +0 -180
- data/ext/gio2/rbgiocharsetconverter.c +0 -57
- data/ext/gio2/rbgiocontenttype.c +0 -131
- data/ext/gio2/rbgioconverter.c +0 -113
- data/ext/gio2/rbgioconverterinputstream.c +0 -43
- data/ext/gio2/rbgioconverteroutputstream.c +0 -43
- data/ext/gio2/rbgiodatainputstream.c +0 -309
- data/ext/gio2/rbgiodataoutputstream.c +0 -186
- data/ext/gio2/rbgiodesktopappinfo.c +0 -87
- data/ext/gio2/rbgiodrive.c +0 -266
- data/ext/gio2/rbgioemblem.c +0 -52
- data/ext/gio2/rbgioemblemedicon.c +0 -65
- data/ext/gio2/rbgiofile.c +0 -2045
- data/ext/gio2/rbgiofileattribute.c +0 -114
- data/ext/gio2/rbgiofileattributeinfo.c +0 -86
- data/ext/gio2/rbgiofileattributeinfolist.c +0 -108
- data/ext/gio2/rbgiofileattributematcher.c +0 -95
- data/ext/gio2/rbgiofiledescriptorbased.c +0 -45
- data/ext/gio2/rbgiofileenumerator.c +0 -166
- data/ext/gio2/rbgiofileicon.c +0 -41
- data/ext/gio2/rbgiofileinfo.c +0 -617
- data/ext/gio2/rbgiofileinputstream.c +0 -91
- data/ext/gio2/rbgiofileiostream.c +0 -98
- data/ext/gio2/rbgiofilemonitor.c +0 -46
- data/ext/gio2/rbgiofilenamecompleter.c +0 -73
- data/ext/gio2/rbgiofileoutputstream.c +0 -98
- data/ext/gio2/rbgiofilterinputstream.c +0 -28
- data/ext/gio2/rbgioicon.c +0 -69
- data/ext/gio2/rbgioinetaddress.c +0 -118
- data/ext/gio2/rbgioinetsocketaddress.c +0 -41
- data/ext/gio2/rbgioinitable.c +0 -199
- data/ext/gio2/rbgioinputstream.c +0 -341
- data/ext/gio2/rbgioio.c +0 -73
- data/ext/gio2/rbgioiomodule.c +0 -45
- data/ext/gio2/rbgioiomodules.c +0 -47
- data/ext/gio2/rbgioioscheduler.c +0 -102
- data/ext/gio2/rbgioioschedulerjob.c +0 -121
- data/ext/gio2/rbgioiostream.c +0 -107
- data/ext/gio2/rbgioloadableicon.c +0 -92
- data/ext/gio2/rbgiomemoryinputstream.c +0 -67
- data/ext/gio2/rbgiomemoryoutputstream.c +0 -44
- data/ext/gio2/rbgiomount.c +0 -286
- data/ext/gio2/rbgiomountoperation.c +0 -53
- data/ext/gio2/rbgionetworkaddress.c +0 -59
- data/ext/gio2/rbgionetworkservice.c +0 -45
- data/ext/gio2/rbgiooutputstream.c +0 -331
- data/ext/gio2/rbgioresolver.c +0 -230
- data/ext/gio2/rbgioseekable.c +0 -91
- data/ext/gio2/rbgiosimpleasyncresult.c +0 -152
- data/ext/gio2/rbgiosocket.c +0 -390
- data/ext/gio2/rbgiosocketaddress.c +0 -34
- data/ext/gio2/rbgiosocketaddressenumerator.c +0 -83
- data/ext/gio2/rbgiosocketclient.c +0 -207
- data/ext/gio2/rbgiosocketconnectable.c +0 -41
- data/ext/gio2/rbgiosocketconnection.c +0 -66
- data/ext/gio2/rbgiosocketconnectionfactory.c +0 -39
- data/ext/gio2/rbgiosocketcontrolmessage.c +0 -82
- data/ext/gio2/rbgiosocketlistener.c +0 -246
- data/ext/gio2/rbgiosocketservice.c +0 -66
- data/ext/gio2/rbgiosrvtarget.c +0 -76
- data/ext/gio2/rbgiotcpconnection.c +0 -28
- data/ext/gio2/rbgiothemedicon.c +0 -83
- data/ext/gio2/rbgiothreadedsocketservice.c +0 -43
- data/ext/gio2/rbgiotlscertificate.c +0 -89
- data/ext/gio2/rbgiounixconnection.c +0 -71
- data/ext/gio2/rbgiounixfdlist.c +0 -115
- data/ext/gio2/rbgiounixfdmessage.c +0 -74
- data/ext/gio2/rbgiounixinputstream.c +0 -51
- data/ext/gio2/rbgiounixmount.c +0 -164
- data/ext/gio2/rbgiounixmountmonitor.c +0 -65
- data/ext/gio2/rbgiounixmountpoint.c +0 -136
- data/ext/gio2/rbgiounixmountpoints.c +0 -58
- data/ext/gio2/rbgiounixmounts.c +0 -58
- data/ext/gio2/rbgiounixoutputstream.c +0 -51
- data/ext/gio2/rbgiounixsocketaddress.c +0 -69
- data/ext/gio2/rbgiovfs.c +0 -84
- data/ext/gio2/rbgiovolume.c +0 -193
- data/ext/gio2/rbgiovolumemonitor.c +0 -77
- data/ext/gio2/rbgiozlibcompressor.c +0 -52
- data/ext/gio2/rbgiozlibdecompressor.c +0 -45
- data/ext/gio2/util.c +0 -303
- data/test/test_bufferedinputstream.rb +0 -9
- data/test/test_charsetconverter.rb +0 -9
- data/test/test_datainputstream.rb +0 -7
- data/test/test_fileenumerator.rb +0 -8
- data/test/test_filemonitor.rb +0 -17
- data/test/test_inetaddress.rb +0 -8
data/ext/gio2/rbgioinitable.c
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2008-2009 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
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE mInitable
|
25
|
-
#define _SELF(value) RVAL2GINITABLE(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_init(int argc, VALUE *argv, VALUE self)
|
29
|
-
{
|
30
|
-
VALUE cancellable;
|
31
|
-
GError *error = NULL;
|
32
|
-
|
33
|
-
rb_scan_args(argc, argv, "01", &cancellable);
|
34
|
-
if (!g_initable_init(_SELF(self),
|
35
|
-
RVAL2GCANCELLABLE(cancellable),
|
36
|
-
&error))
|
37
|
-
rbgio_raise_error(error);
|
38
|
-
|
39
|
-
return self;
|
40
|
-
}
|
41
|
-
|
42
|
-
struct rbgio_ginitable_new_data {
|
43
|
-
GObjectClass *gclass;
|
44
|
-
GCancellable *cancellable;
|
45
|
-
VALUE rbparameters;
|
46
|
-
guint index;
|
47
|
-
guint n_parameters;
|
48
|
-
GParameter *parameters;
|
49
|
-
GError *error;
|
50
|
-
};
|
51
|
-
|
52
|
-
static VALUE
|
53
|
-
rbgio_ginitiable_new_parameters_initialize(VALUE key_value,
|
54
|
-
struct rbgio_ginitable_new_data *data)
|
55
|
-
{
|
56
|
-
VALUE key, value;
|
57
|
-
GParamSpec *spec;
|
58
|
-
|
59
|
-
if (data->index >= data->n_parameters)
|
60
|
-
rb_raise(rb_eArgError,
|
61
|
-
"too many parameters (%d >= %d)",
|
62
|
-
data->index, data->n_parameters);
|
63
|
-
|
64
|
-
key = rb_ary_entry(key_value, 0);
|
65
|
-
value = rb_ary_entry(key_value, 1);
|
66
|
-
|
67
|
-
data->parameters[data->index].name = SYMBOL_P(key) ?
|
68
|
-
rb_id2name(SYM2ID(key)) :
|
69
|
-
StringValuePtr(key);
|
70
|
-
spec = g_object_class_find_property(data->gclass,
|
71
|
-
data->parameters[data->index].name);
|
72
|
-
if (spec == NULL)
|
73
|
-
rb_raise(rb_eArgError,
|
74
|
-
"%s: no such property",
|
75
|
-
data->parameters[data->index].name);
|
76
|
-
g_value_init(&(data->parameters[data->index].value),
|
77
|
-
G_PARAM_SPEC_VALUE_TYPE(spec));
|
78
|
-
rbgobj_rvalue_to_gvalue(value, &(data->parameters[data->index].value));
|
79
|
-
|
80
|
-
data->index++;
|
81
|
-
|
82
|
-
return Qnil;
|
83
|
-
}
|
84
|
-
|
85
|
-
static VALUE
|
86
|
-
rbgio_ginitable_new_body(struct rbgio_ginitable_new_data *data)
|
87
|
-
{
|
88
|
-
rb_iterate(rb_each,
|
89
|
-
data->rbparameters,
|
90
|
-
rbgio_ginitiable_new_parameters_initialize,
|
91
|
-
(VALUE)data);
|
92
|
-
|
93
|
-
return (VALUE)g_initable_newv(G_TYPE_FROM_CLASS(data->gclass),
|
94
|
-
data->n_parameters,
|
95
|
-
data->parameters,
|
96
|
-
data->cancellable,
|
97
|
-
&data->error);
|
98
|
-
}
|
99
|
-
|
100
|
-
static VALUE
|
101
|
-
rbgio_ginitable_new_ensure(struct rbgio_ginitable_new_data *data)
|
102
|
-
{
|
103
|
-
guint i;
|
104
|
-
|
105
|
-
g_type_class_unref(data->gclass);
|
106
|
-
for (i = 0; i < data->n_parameters; i++)
|
107
|
-
if (G_IS_VALUE(&data->parameters[i].value))
|
108
|
-
g_value_unset(&data->parameters[i].value);
|
109
|
-
|
110
|
-
g_free(data->parameters);
|
111
|
-
|
112
|
-
return Qnil;
|
113
|
-
}
|
114
|
-
|
115
|
-
GObject *
|
116
|
-
rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable)
|
117
|
-
{
|
118
|
-
static ID s_id_length;
|
119
|
-
GError *error = NULL;
|
120
|
-
GObject *object;
|
121
|
-
struct rbgio_ginitable_new_data data;
|
122
|
-
|
123
|
-
if (s_id_length == 0)
|
124
|
-
s_id_length = rb_intern("length");
|
125
|
-
|
126
|
-
if (!g_type_is_a(type, G_TYPE_OBJECT))
|
127
|
-
rb_raise(rb_eArgError,
|
128
|
-
"%s is not a descendant of GObject",
|
129
|
-
g_type_name(type));
|
130
|
-
|
131
|
-
if (NIL_P(parameters)) {
|
132
|
-
object = g_initable_newv(type,
|
133
|
-
0,
|
134
|
-
NULL,
|
135
|
-
RVAL2GCANCELLABLE(cancellable),
|
136
|
-
&error);
|
137
|
-
if (object == NULL)
|
138
|
-
rbgio_raise_error(error);
|
139
|
-
|
140
|
-
return object;
|
141
|
-
} else {
|
142
|
-
parameters = rb_convert_type(parameters,
|
143
|
-
T_HASH,
|
144
|
-
"Hash",
|
145
|
-
"to_hash");
|
146
|
-
}
|
147
|
-
|
148
|
-
data.gclass = G_OBJECT_CLASS(g_type_class_ref(type));
|
149
|
-
data.cancellable = RVAL2GCANCELLABLE(cancellable);
|
150
|
-
data.rbparameters = parameters;
|
151
|
-
data.index = 0;
|
152
|
-
data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0));
|
153
|
-
data.parameters = g_new(GParameter, data.n_parameters);
|
154
|
-
data.error = NULL;
|
155
|
-
|
156
|
-
object = (GObject *)rb_ensure(rbgio_ginitable_new_body, (VALUE)&data,
|
157
|
-
rbgio_ginitable_new_ensure, (VALUE)&data);
|
158
|
-
if (object == NULL)
|
159
|
-
rbgio_raise_error(data.error);
|
160
|
-
|
161
|
-
return object;
|
162
|
-
}
|
163
|
-
|
164
|
-
/* NOTE: We don't implement g_initable_new. */
|
165
|
-
|
166
|
-
/* NOTE: We don't implement g_initable_new_valist. */
|
167
|
-
|
168
|
-
static VALUE
|
169
|
-
rg_s_new(int argc, VALUE *argv, VALUE self)
|
170
|
-
{
|
171
|
-
const RGObjClassInfo* info;
|
172
|
-
VALUE cancellable, parameters;
|
173
|
-
GObject *object;
|
174
|
-
VALUE result;
|
175
|
-
|
176
|
-
rb_scan_args(argc, argv, "02", &cancellable, ¶meters);
|
177
|
-
|
178
|
-
info = CLASS2CINFO(self);
|
179
|
-
if (info->klass != self)
|
180
|
-
rb_raise(rb_eTypeError,
|
181
|
-
"%s: class not registered with GLib",
|
182
|
-
rb_class2name(self));
|
183
|
-
|
184
|
-
object = rbgio_ginitable_new(info->gtype, parameters, cancellable);
|
185
|
-
result = GOBJ2RVAL(object);
|
186
|
-
g_object_unref(object);
|
187
|
-
|
188
|
-
return result;
|
189
|
-
}
|
190
|
-
|
191
|
-
void
|
192
|
-
Init_ginitable(VALUE mGio)
|
193
|
-
{
|
194
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_INTERFACE(G_TYPE_INITABLE, "Initable", mGio);
|
195
|
-
|
196
|
-
RG_DEF_SMETHOD(new, -1);
|
197
|
-
|
198
|
-
RG_DEF_METHOD(init, -1);
|
199
|
-
}
|
data/ext/gio2/rbgioinputstream.c
DELETED
@@ -1,341 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2008-2009 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
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cInputStream
|
25
|
-
#define _SELF(value) RVAL2GINPUTSTREAM(value)
|
26
|
-
|
27
|
-
static VALUE s_cReadAsyncResult;
|
28
|
-
|
29
|
-
static VALUE
|
30
|
-
rg_read(int argc, VALUE *argv, VALUE self)
|
31
|
-
{
|
32
|
-
VALUE rbcount, cancellable, result;
|
33
|
-
gsize count;
|
34
|
-
GError *error = NULL;
|
35
|
-
gssize bytes_read;
|
36
|
-
|
37
|
-
rb_scan_args(argc, argv, "11", &rbcount, &cancellable);
|
38
|
-
count = RVAL2GSIZE(rbcount);
|
39
|
-
result = rb_str_new(NULL, count);
|
40
|
-
bytes_read = g_input_stream_read(_SELF(self),
|
41
|
-
RSTRING_PTR(result),
|
42
|
-
count,
|
43
|
-
RVAL2GCANCELLABLE(cancellable),
|
44
|
-
&error);
|
45
|
-
if (bytes_read == -1)
|
46
|
-
rbgio_raise_error(error);
|
47
|
-
|
48
|
-
rb_str_set_len(result, bytes_read);
|
49
|
-
rb_str_resize(result, bytes_read);
|
50
|
-
OBJ_TAINT(result);
|
51
|
-
|
52
|
-
return result;
|
53
|
-
}
|
54
|
-
|
55
|
-
static VALUE
|
56
|
-
rg_read_all(int argc, VALUE *argv, VALUE self)
|
57
|
-
{
|
58
|
-
VALUE rbcount, cancellable, result;
|
59
|
-
gsize count;
|
60
|
-
GError *error = NULL;
|
61
|
-
gsize bytes_read;
|
62
|
-
|
63
|
-
rb_scan_args(argc, argv, "11", &rbcount, &cancellable);
|
64
|
-
count = RVAL2GSIZE(rbcount);
|
65
|
-
result = rb_str_new(NULL, count);
|
66
|
-
if (!g_input_stream_read_all(_SELF(self),
|
67
|
-
RSTRING_PTR(result),
|
68
|
-
count,
|
69
|
-
&bytes_read,
|
70
|
-
RVAL2GCANCELLABLE(cancellable),
|
71
|
-
&error))
|
72
|
-
rbgio_raise_error(error);
|
73
|
-
|
74
|
-
rb_str_set_len(result, bytes_read);
|
75
|
-
rb_str_resize(result, bytes_read);
|
76
|
-
OBJ_TAINT(result);
|
77
|
-
|
78
|
-
return result;
|
79
|
-
}
|
80
|
-
|
81
|
-
static VALUE
|
82
|
-
rg_skip(int argc, VALUE *argv, VALUE self)
|
83
|
-
{
|
84
|
-
VALUE count, cancellable;
|
85
|
-
GError *error = NULL;
|
86
|
-
gssize bytes_skipped;
|
87
|
-
|
88
|
-
rb_scan_args(argc, argv, "11", &count, &cancellable);
|
89
|
-
bytes_skipped = g_input_stream_skip(_SELF(self),
|
90
|
-
RVAL2GSIZE(count),
|
91
|
-
RVAL2GCANCELLABLE(cancellable),
|
92
|
-
&error);
|
93
|
-
if (bytes_skipped == -1)
|
94
|
-
rbgio_raise_error(error);
|
95
|
-
|
96
|
-
return GSSIZE2RVAL(bytes_skipped);
|
97
|
-
}
|
98
|
-
|
99
|
-
static VALUE
|
100
|
-
rg_close(int argc, VALUE *argv, VALUE self)
|
101
|
-
{
|
102
|
-
VALUE cancellable;
|
103
|
-
GError *error = NULL;
|
104
|
-
|
105
|
-
rb_scan_args(argc, argv, "01", &cancellable);
|
106
|
-
if (!g_input_stream_close(_SELF(self),
|
107
|
-
RVAL2GCANCELLABLE(cancellable),
|
108
|
-
&error))
|
109
|
-
rbgio_raise_error(error);
|
110
|
-
|
111
|
-
return self;
|
112
|
-
}
|
113
|
-
|
114
|
-
struct read_async_result
|
115
|
-
{
|
116
|
-
VALUE string;
|
117
|
-
GAsyncResult *result;
|
118
|
-
};
|
119
|
-
|
120
|
-
static void
|
121
|
-
read_async_result_mark(struct read_async_result *result)
|
122
|
-
{
|
123
|
-
rb_gc_mark(result->string);
|
124
|
-
}
|
125
|
-
|
126
|
-
struct read_async_callback_data
|
127
|
-
{
|
128
|
-
GAsyncResult *result;
|
129
|
-
gpointer user_data;
|
130
|
-
};
|
131
|
-
|
132
|
-
static VALUE
|
133
|
-
read_async_callback_call(VALUE data)
|
134
|
-
{
|
135
|
-
static ID s_id_call;
|
136
|
-
struct read_async_callback_data *real;
|
137
|
-
VALUE ary;
|
138
|
-
struct read_async_result *result;
|
139
|
-
|
140
|
-
if (s_id_call == 0)
|
141
|
-
s_id_call = rb_intern("call");
|
142
|
-
|
143
|
-
real = (struct read_async_callback_data *)data;
|
144
|
-
|
145
|
-
ary = (VALUE)real->user_data;
|
146
|
-
G_CHILD_REMOVE(mGLib, ary);
|
147
|
-
if (NIL_P(RARRAY_PTR(ary)[1]))
|
148
|
-
return Qnil;
|
149
|
-
|
150
|
-
result = g_new(struct read_async_result, 1);
|
151
|
-
result->string = RARRAY_PTR(ary)[0];
|
152
|
-
result->result = real->result;
|
153
|
-
|
154
|
-
rb_funcall(RARRAY_PTR(ary)[1], s_id_call, 1,
|
155
|
-
Data_Wrap_Struct(s_cReadAsyncResult,
|
156
|
-
read_async_result_mark,
|
157
|
-
g_free,
|
158
|
-
result));
|
159
|
-
|
160
|
-
return Qnil;
|
161
|
-
}
|
162
|
-
|
163
|
-
static void
|
164
|
-
read_async_callback(G_GNUC_UNUSED GObject *source,
|
165
|
-
GAsyncResult *result,
|
166
|
-
gpointer user_data)
|
167
|
-
{
|
168
|
-
struct read_async_callback_data real = { result, user_data };
|
169
|
-
|
170
|
-
G_PROTECT_CALLBACK(read_async_callback_call, &real);
|
171
|
-
}
|
172
|
-
|
173
|
-
static VALUE
|
174
|
-
rg_read_async(int argc, VALUE *argv, VALUE self)
|
175
|
-
{
|
176
|
-
VALUE rbcount, rbio_priority, rbcancellable, block, data;
|
177
|
-
gsize count;
|
178
|
-
int io_priority;
|
179
|
-
GCancellable *cancellable;
|
180
|
-
|
181
|
-
rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block);
|
182
|
-
count = RVAL2GSIZE(rbcount);
|
183
|
-
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
184
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
185
|
-
data = rb_assoc_new(rb_str_new(NULL, count), block);
|
186
|
-
G_CHILD_ADD(mGLib, data);
|
187
|
-
g_input_stream_read_async(_SELF(self),
|
188
|
-
RSTRING_PTR(RARRAY_PTR(data)[0]),
|
189
|
-
count,
|
190
|
-
io_priority,
|
191
|
-
cancellable,
|
192
|
-
read_async_callback,
|
193
|
-
(gpointer)data);
|
194
|
-
|
195
|
-
return self;
|
196
|
-
}
|
197
|
-
|
198
|
-
static VALUE
|
199
|
-
rg_read_finish(VALUE self, VALUE rbresult)
|
200
|
-
{
|
201
|
-
struct read_async_result *result;
|
202
|
-
GError *error = NULL;
|
203
|
-
gssize bytes_read;
|
204
|
-
|
205
|
-
Data_Get_Struct(rbresult, struct read_async_result, result);
|
206
|
-
bytes_read = g_input_stream_read_finish(_SELF(self),
|
207
|
-
result->result,
|
208
|
-
&error);
|
209
|
-
if (bytes_read == -1)
|
210
|
-
rbgio_raise_error(error);
|
211
|
-
|
212
|
-
rb_str_set_len(result->string, bytes_read);
|
213
|
-
rb_str_resize(result->string, bytes_read);
|
214
|
-
OBJ_TAINT(result->string);
|
215
|
-
|
216
|
-
return result->string;
|
217
|
-
}
|
218
|
-
|
219
|
-
static VALUE
|
220
|
-
rg_skip_async(int argc, VALUE *argv, VALUE self)
|
221
|
-
{
|
222
|
-
VALUE rbcount, rbio_priority, rbcancellable, block;
|
223
|
-
gsize count;
|
224
|
-
int io_priority;
|
225
|
-
GCancellable *cancellable;
|
226
|
-
|
227
|
-
rb_scan_args(argc, argv, "12&", &rbcount, &rbio_priority, &rbcancellable, &block);
|
228
|
-
count = RVAL2GSIZE(rbcount);
|
229
|
-
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
230
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
231
|
-
SAVE_BLOCK(block);
|
232
|
-
g_input_stream_skip_async(_SELF(self),
|
233
|
-
count,
|
234
|
-
io_priority,
|
235
|
-
cancellable,
|
236
|
-
rbgio_async_ready_callback,
|
237
|
-
(gpointer)block);
|
238
|
-
|
239
|
-
return self;
|
240
|
-
}
|
241
|
-
|
242
|
-
static VALUE
|
243
|
-
rg_skip_finish(VALUE self, VALUE result)
|
244
|
-
{
|
245
|
-
GError *error = NULL;
|
246
|
-
gssize skipped_bytes;
|
247
|
-
|
248
|
-
skipped_bytes = g_input_stream_skip_finish(_SELF(self),
|
249
|
-
RVAL2GASYNCRESULT(result),
|
250
|
-
&error);
|
251
|
-
if (skipped_bytes == -1)
|
252
|
-
rbgio_raise_error(error);
|
253
|
-
|
254
|
-
return GSSIZE2RVAL(skipped_bytes);
|
255
|
-
}
|
256
|
-
|
257
|
-
static VALUE
|
258
|
-
rg_close_async(int argc, VALUE *argv, VALUE self)
|
259
|
-
{
|
260
|
-
VALUE rbio_priority, rbcancellable, block;
|
261
|
-
int io_priority;
|
262
|
-
GCancellable *cancellable;
|
263
|
-
|
264
|
-
rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
|
265
|
-
io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
|
266
|
-
cancellable = RVAL2GCANCELLABLE(rbcancellable);
|
267
|
-
SAVE_BLOCK(block);
|
268
|
-
g_input_stream_close_async(_SELF(self),
|
269
|
-
io_priority,
|
270
|
-
cancellable,
|
271
|
-
rbgio_async_ready_callback,
|
272
|
-
(gpointer)block);
|
273
|
-
|
274
|
-
return self;
|
275
|
-
}
|
276
|
-
|
277
|
-
static VALUE
|
278
|
-
rg_close_finish(VALUE self, VALUE result)
|
279
|
-
{
|
280
|
-
GError *error = NULL;
|
281
|
-
if (!g_input_stream_skip_finish(_SELF(self),
|
282
|
-
RVAL2GASYNCRESULT(result),
|
283
|
-
&error))
|
284
|
-
rbgio_raise_error(error);
|
285
|
-
|
286
|
-
return self;
|
287
|
-
}
|
288
|
-
|
289
|
-
static VALUE
|
290
|
-
rg_closed_p(VALUE self)
|
291
|
-
{
|
292
|
-
return CBOOL2RVAL(g_input_stream_is_closed(_SELF(self)));
|
293
|
-
}
|
294
|
-
|
295
|
-
static VALUE
|
296
|
-
rg_has_pending_p(VALUE self)
|
297
|
-
{
|
298
|
-
return CBOOL2RVAL(g_input_stream_has_pending(_SELF(self)));
|
299
|
-
}
|
300
|
-
|
301
|
-
static VALUE
|
302
|
-
rg_set_pending(VALUE self)
|
303
|
-
{
|
304
|
-
GError *error = NULL;
|
305
|
-
|
306
|
-
if (!g_input_stream_set_pending(_SELF(self), &error))
|
307
|
-
rbgio_raise_error(error);
|
308
|
-
|
309
|
-
return self;
|
310
|
-
}
|
311
|
-
|
312
|
-
static VALUE
|
313
|
-
rg_clear_pending(VALUE self)
|
314
|
-
{
|
315
|
-
g_input_stream_clear_pending(_SELF(self));
|
316
|
-
|
317
|
-
return self;
|
318
|
-
}
|
319
|
-
|
320
|
-
void
|
321
|
-
Init_ginputstream(VALUE mGio)
|
322
|
-
{
|
323
|
-
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_INPUT_STREAM, "InputStream", mGio);
|
324
|
-
|
325
|
-
s_cReadAsyncResult = rb_define_class_under(RG_TARGET_NAMESPACE, "ReadAsyncResult", rb_cObject);
|
326
|
-
|
327
|
-
RG_DEF_METHOD(read, -1);
|
328
|
-
RG_DEF_METHOD(read_all, -1);
|
329
|
-
RG_DEF_METHOD(skip, -1);
|
330
|
-
RG_DEF_METHOD(close, -1);
|
331
|
-
RG_DEF_METHOD(read_async, -1);
|
332
|
-
RG_DEF_METHOD(read_finish, 1);
|
333
|
-
RG_DEF_METHOD(skip_async, -1);
|
334
|
-
RG_DEF_METHOD(skip_finish, 1);
|
335
|
-
RG_DEF_METHOD(close_async, -1);
|
336
|
-
RG_DEF_METHOD(close_finish, 1);
|
337
|
-
RG_DEF_METHOD_P(closed, 0);
|
338
|
-
RG_DEF_METHOD_P(has_pending, 0);
|
339
|
-
RG_DEF_METHOD(set_pending, 0);
|
340
|
-
RG_DEF_METHOD(clear_pending, 0);
|
341
|
-
}
|
data/ext/gio2/rbgioio.c
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2008-2009 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
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE mIO
|
25
|
-
|
26
|
-
/* NOTE: g_io_error_from_errno doesn't make sense from Ruby. */
|
27
|
-
|
28
|
-
void
|
29
|
-
Init_gioerror(VALUE mGio)
|
30
|
-
{
|
31
|
-
VALUE RG_TARGET_NAMESPACE, error;
|
32
|
-
|
33
|
-
RG_TARGET_NAMESPACE = rb_define_module_under(mGio, "IO");
|
34
|
-
|
35
|
-
error = rbgio_define_domain_error(RG_TARGET_NAMESPACE, "Error", G_IO_ERROR, "GIOErrorEnum", rb_eIOError);
|
36
|
-
|
37
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "FailedError", G_IO_ERROR_FAILED, error);
|
38
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotFoundError", G_IO_ERROR_NOT_FOUND, error);
|
39
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "ExistsError", G_IO_ERROR_EXISTS, error);
|
40
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "IsDirectoryError", G_IO_ERROR_IS_DIRECTORY, error);
|
41
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotDirectoryError", G_IO_ERROR_NOT_DIRECTORY, error);
|
42
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotEmptyError", G_IO_ERROR_NOT_EMPTY, error);
|
43
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotRegularFileError", G_IO_ERROR_NOT_REGULAR_FILE, error);
|
44
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotSymbolicLinkError", G_IO_ERROR_NOT_SYMBOLIC_LINK, error);
|
45
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountableFileError", G_IO_ERROR_NOT_MOUNTABLE_FILE, error);
|
46
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "FilenameTooLongError", G_IO_ERROR_FILENAME_TOO_LONG, error);
|
47
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidFilenameError", G_IO_ERROR_INVALID_FILENAME, error);
|
48
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyLinksError", G_IO_ERROR_TOO_MANY_LINKS, error);
|
49
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NoSpaceError", G_IO_ERROR_NO_SPACE, error);
|
50
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidArgumentError", G_IO_ERROR_INVALID_ARGUMENT, error);
|
51
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "PermissionDeniedError", G_IO_ERROR_PERMISSION_DENIED, error);
|
52
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotSupportedError", G_IO_ERROR_NOT_SUPPORTED, error);
|
53
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotMountedError", G_IO_ERROR_NOT_MOUNTED, error);
|
54
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "AlreadyMountedError", G_IO_ERROR_ALREADY_MOUNTED, error);
|
55
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "ClosedError", G_IO_ERROR_CLOSED, error);
|
56
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "CancelledError", G_IO_ERROR_CANCELLED, error);
|
57
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "PendingError", G_IO_ERROR_PENDING, error);
|
58
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "ReadOnlyError", G_IO_ERROR_READ_ONLY, error);
|
59
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "CantCreateBackupError", G_IO_ERROR_CANT_CREATE_BACKUP, error);
|
60
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "WrongEtagError", G_IO_ERROR_WRONG_ETAG, error);
|
61
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "TimedOutError", G_IO_ERROR_TIMED_OUT, error);
|
62
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "WouldRecurseError", G_IO_ERROR_WOULD_RECURSE, error);
|
63
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "BusyError", G_IO_ERROR_BUSY, error);
|
64
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "WouldBlockError", G_IO_ERROR_WOULD_BLOCK, error);
|
65
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "HostNotFoundError", G_IO_ERROR_HOST_NOT_FOUND, error);
|
66
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "WouldMergeError", G_IO_ERROR_WOULD_MERGE, error);
|
67
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "FailedHandledError", G_IO_ERROR_FAILED_HANDLED, error);
|
68
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "TooManyOpenFilesError", G_IO_ERROR_TOO_MANY_OPEN_FILES, error);
|
69
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "NotInitializedError", G_IO_ERROR_NOT_INITIALIZED, error);
|
70
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "AddressInUseError", G_IO_ERROR_ADDRESS_IN_USE, error);
|
71
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "PartialInputError", G_IO_ERROR_PARTIAL_INPUT, error);
|
72
|
-
rbgio_define_error(RG_TARGET_NAMESPACE, "InvalidDataError", G_IO_ERROR_INVALID_DATA, error);
|
73
|
-
}
|
data/ext/gio2/rbgioiomodule.c
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
|
2
|
-
/*
|
3
|
-
* Copyright (C) 2011 Ruby-GNOME2 Project Team
|
4
|
-
* Copyright (C) 2008-2009 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
|
-
*/
|
21
|
-
|
22
|
-
#include "rbgio2private.h"
|
23
|
-
|
24
|
-
#define RG_TARGET_NAMESPACE cIOModule
|
25
|
-
#define _SELF(value) RVAL2GIOMODULE(value)
|
26
|
-
|
27
|
-
static VALUE
|
28
|
-
rg_initialize(VALUE self, VALUE filename)
|
29
|
-
{
|
30
|
-
G_INITIALIZE(self, g_io_module_new(RVAL2CSTR(filename)));
|
31
|
-
|
32
|
-
return Qnil;
|
33
|
-
}
|
34
|
-
|
35
|
-
/* NOTE: No point in implementing g_io_module_query. */
|
36
|
-
|
37
|
-
void
|
38
|
-
Init_giomodule(VALUE mGio)
|
39
|
-
{
|
40
|
-
VALUE RG_TARGET_NAMESPACE;
|
41
|
-
|
42
|
-
RG_TARGET_NAMESPACE = G_DEF_CLASS(G_IO_TYPE_MODULE, "IOModule", mGio);
|
43
|
-
|
44
|
-
RG_DEF_METHOD(initialize, 1);
|
45
|
-
}
|