gio2 0.90.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/ChangeLog +60 -0
  2. data/README +34 -0
  3. data/Rakefile +76 -0
  4. data/ext/gio2/depend +5 -0
  5. data/ext/gio2/extconf.rb +91 -0
  6. data/ext/gio2/gappinfo.c +318 -0
  7. data/ext/gio2/gapplaunchcontext.c +79 -0
  8. data/ext/gio2/gasyncinitable.c +244 -0
  9. data/ext/gio2/gasyncresult.c +39 -0
  10. data/ext/gio2/gbufferedinputstream.c +184 -0
  11. data/ext/gio2/gbufferedoutputstream.c +82 -0
  12. data/ext/gio2/gcancellable.c +177 -0
  13. data/ext/gio2/gcharsetconverter.c +72 -0
  14. data/ext/gio2/gcontenttype.c +135 -0
  15. data/ext/gio2/gconverter.c +117 -0
  16. data/ext/gio2/gconverterinputstream.c +48 -0
  17. data/ext/gio2/gconverteroutputstream.c +48 -0
  18. data/ext/gio2/gdatainputstream.c +341 -0
  19. data/ext/gio2/gdataoutputstream.c +202 -0
  20. data/ext/gio2/gdesktopappinfo.c +90 -0
  21. data/ext/gio2/gdrive.c +267 -0
  22. data/ext/gio2/gemblem.c +71 -0
  23. data/ext/gio2/gemblemedicon.c +63 -0
  24. data/ext/gio2/gfile.c +2058 -0
  25. data/ext/gio2/gfileattribute.c +263 -0
  26. data/ext/gio2/gfileattributematcher.c +90 -0
  27. data/ext/gio2/gfiledescriptorbased.c +42 -0
  28. data/ext/gio2/gfileenumerator.c +167 -0
  29. data/ext/gio2/gfileicon.c +46 -0
  30. data/ext/gio2/gfileinfo.c +641 -0
  31. data/ext/gio2/gfileinputstream.c +92 -0
  32. data/ext/gio2/gfileiostream.c +98 -0
  33. data/ext/gio2/gfilemonitor.c +63 -0
  34. data/ext/gio2/gfilenamecompleter.c +72 -0
  35. data/ext/gio2/gfileoutputstream.c +100 -0
  36. data/ext/gio2/gfilterinputstream.c +56 -0
  37. data/ext/gio2/gfilteroutputstream.c +56 -0
  38. data/ext/gio2/gicon.c +69 -0
  39. data/ext/gio2/ginetaddress.c +188 -0
  40. data/ext/gio2/ginetsocketaddress.c +54 -0
  41. data/ext/gio2/ginitable.c +195 -0
  42. data/ext/gio2/ginputstream.c +341 -0
  43. data/ext/gio2/gio2.c +120 -0
  44. data/ext/gio2/gio2.def +2 -0
  45. data/ext/gio2/gio2.h +343 -0
  46. data/ext/gio2/gioerror.c +67 -0
  47. data/ext/gio2/giomodule.c +63 -0
  48. data/ext/gio2/gioscheduler.c +195 -0
  49. data/ext/gio2/giostream.c +129 -0
  50. data/ext/gio2/gloadableicon.c +91 -0
  51. data/ext/gio2/gmemoryinputstream.c +65 -0
  52. data/ext/gio2/gmemoryoutputstream.c +65 -0
  53. data/ext/gio2/gmount.c +283 -0
  54. data/ext/gio2/gmountoperation.c +168 -0
  55. data/ext/gio2/gnetworkaddress.c +71 -0
  56. data/ext/gio2/gnetworkservice.c +64 -0
  57. data/ext/gio2/goutputstream.c +343 -0
  58. data/ext/gio2/gresolver.c +230 -0
  59. data/ext/gio2/gseekable.c +89 -0
  60. data/ext/gio2/gsimpleasyncresult.c +153 -0
  61. data/ext/gio2/gsocket.c +451 -0
  62. data/ext/gio2/gsocketaddress.c +45 -0
  63. data/ext/gio2/gsocketclient.c +273 -0
  64. data/ext/gio2/gsocketconnectable.c +97 -0
  65. data/ext/gio2/gsocketconnection.c +82 -0
  66. data/ext/gio2/gsocketcontrolmessage.c +82 -0
  67. data/ext/gio2/gsocketlistener.c +239 -0
  68. data/ext/gio2/gsocketservice.c +64 -0
  69. data/ext/gio2/gsrvtarget.c +77 -0
  70. data/ext/gio2/gtcpconnection.c +48 -0
  71. data/ext/gio2/gthemedicon.c +86 -0
  72. data/ext/gio2/gthreadedsocketservice.c +39 -0
  73. data/ext/gio2/gunixconnection.c +69 -0
  74. data/ext/gio2/gunixfdlist.c +112 -0
  75. data/ext/gio2/gunixfdmessage.c +81 -0
  76. data/ext/gio2/gunixinputstream.c +73 -0
  77. data/ext/gio2/gunixmounts.c +346 -0
  78. data/ext/gio2/gunixoutputstream.c +73 -0
  79. data/ext/gio2/gunixsocketaddress.c +79 -0
  80. data/ext/gio2/gvfs.c +84 -0
  81. data/ext/gio2/gvolume.c +191 -0
  82. data/ext/gio2/gvolumemonitor.c +77 -0
  83. data/ext/gio2/gzlibcompressor.c +47 -0
  84. data/ext/gio2/gzlibdecompressor.c +43 -0
  85. data/ext/gio2/util.c +323 -0
  86. data/extconf.rb +49 -0
  87. data/lib/gio2.rb +141 -0
  88. metadata +184 -0
@@ -0,0 +1,79 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) RVAL2GAPPLAUNCHCONTEXT(value)
24
+
25
+ static VALUE
26
+ applaunchcontext_initialize(VALUE self)
27
+ {
28
+ G_INITIALIZE(self, g_app_launch_context_new());
29
+
30
+ return Qnil;
31
+ }
32
+
33
+ typedef char *(*GetMethod)(GAppLaunchContext *, GAppInfo *, GList *);
34
+
35
+ static VALUE
36
+ get_value_by(GetMethod method, int argc, VALUE *argv, VALUE self)
37
+ {
38
+ VALUE info, rbfiles;
39
+ GList *files;
40
+ char *value;
41
+
42
+ rb_scan_args(argc, argv, "11", &info, &rbfiles);
43
+ files = GFILEARY2GLIST_ACCEPT_NIL(rbfiles);
44
+ value = method(_SELF(self), RVAL2GAPPINFO(info), files);
45
+ g_list_free(files);
46
+
47
+ return CSTR2RVAL_FREE(value);
48
+ }
49
+
50
+ static VALUE
51
+ applaunchcontext_get_display(int argc, VALUE *argv, VALUE self)
52
+ {
53
+ return get_value_by(g_app_launch_context_get_display, argc, argv, self);
54
+ }
55
+
56
+ static VALUE
57
+ applaunchcontext_get_startup_notify_id(int argc, VALUE *argv, VALUE self)
58
+ {
59
+ return get_value_by(g_app_launch_context_get_startup_notify_id, argc, argv, self);
60
+ }
61
+
62
+ static VALUE
63
+ applaunchcontext_launch_failed(VALUE self, VALUE sn_id)
64
+ {
65
+ g_app_launch_context_launch_failed(_SELF(self), RVAL2CSTR(sn_id));
66
+
67
+ return self;
68
+ }
69
+
70
+ void
71
+ Init_gapplaunchcontext(VALUE glib)
72
+ {
73
+ VALUE applaunchcontext = G_DEF_CLASS(G_TYPE_APP_LAUNCH_CONTEXT, "AppLaunchContext", glib);
74
+
75
+ rb_define_method(applaunchcontext, "initialize", applaunchcontext_initialize, 0);
76
+ rb_define_method(applaunchcontext, "get_display", applaunchcontext_get_display, -1);
77
+ rb_define_method(applaunchcontext, "get_startup_notify_id", applaunchcontext_get_startup_notify_id, -1);
78
+ rb_define_method(applaunchcontext, "launch_failed", applaunchcontext_launch_failed, 1);
79
+ }
@@ -0,0 +1,244 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) G_ASYNC_INITABLE(RVAL2GOBJ(value))
24
+
25
+ static VALUE
26
+ asyncinitable_init_async(int argc, VALUE *argv, VALUE self)
27
+ {
28
+ VALUE rbio_priority, rbcancellable, block;
29
+ int io_priority;
30
+ GCancellable *cancellable;
31
+
32
+ rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
33
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
34
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
35
+ SAVE_BLOCK(block);
36
+ g_async_initable_init_async(_SELF(self),
37
+ io_priority,
38
+ cancellable,
39
+ rbgio_async_ready_callback,
40
+ (gpointer)block);
41
+
42
+ return self;
43
+ }
44
+
45
+ static VALUE
46
+ asyncinitable_init_finish(VALUE self, VALUE result)
47
+ {
48
+ GError *error = NULL;
49
+
50
+ if (!g_async_initable_init_finish(_SELF(self),
51
+ RVAL2GASYNCRESULT(result),
52
+ &error))
53
+ rbgio_raise_error(error);
54
+
55
+ return self;
56
+ }
57
+
58
+ /* NOTE: We don’t implement g_async_initable_new_async. */
59
+
60
+ /* NOTE: We don’t implement g_async_initable_new_valist_async. */
61
+
62
+ struct rbgio_gasyncinitable_new_async_data {
63
+ GObjectClass *gclass;
64
+ int io_priority;
65
+ GCancellable *cancellable;
66
+ VALUE block;
67
+ VALUE rbparameters;
68
+ guint index;
69
+ guint n_parameters;
70
+ GParameter *parameters;
71
+ };
72
+
73
+ static VALUE
74
+ rbgio_gasyncinitiable_new_async_parameters_initialize(VALUE key_value,
75
+ struct rbgio_gasyncinitable_new_async_data *data)
76
+ {
77
+ VALUE key, value;
78
+ GParamSpec *spec;
79
+
80
+ if (data->index >= data->n_parameters)
81
+ rb_raise(rb_eArgError,
82
+ "too many parameters (%d >= %d)",
83
+ data->index, data->n_parameters);
84
+
85
+ key = rb_ary_entry(key_value, 0);
86
+ value = rb_ary_entry(key_value, 1);
87
+
88
+ data->parameters[data->index].name = SYMBOL_P(key) ?
89
+ rb_id2name(SYM2ID(key)) :
90
+ StringValuePtr(key);
91
+ spec = g_object_class_find_property(data->gclass,
92
+ data->parameters[data->index].name);
93
+ if (spec == NULL)
94
+ rb_raise(rb_eArgError,
95
+ "%s: no such property",
96
+ data->parameters[data->index].name);
97
+ g_value_init(&(data->parameters[data->index].value),
98
+ G_PARAM_SPEC_VALUE_TYPE(spec));
99
+ rbgobj_rvalue_to_gvalue(value, &(data->parameters[data->index].value));
100
+
101
+ data->index++;
102
+
103
+ return Qnil;
104
+ }
105
+
106
+ static VALUE
107
+ rbgio_gasyncinitable_new_async_body(struct rbgio_gasyncinitable_new_async_data *data)
108
+ {
109
+ rb_iterate(rb_each,
110
+ data->rbparameters,
111
+ rbgio_gasyncinitiable_new_async_parameters_initialize,
112
+ (VALUE)data);
113
+
114
+ SAVE_BLOCK(data->block);
115
+
116
+ g_async_initable_newv_async(G_TYPE_FROM_CLASS(data->gclass),
117
+ data->n_parameters,
118
+ data->parameters,
119
+ data->io_priority,
120
+ data->cancellable,
121
+ rbgio_async_ready_callback,
122
+ (gpointer)data->block);
123
+
124
+ return Qnil;
125
+ }
126
+
127
+ static VALUE
128
+ rbgio_gasyncinitable_new_async_ensure(struct rbgio_gasyncinitable_new_async_data *data)
129
+ {
130
+ guint i;
131
+
132
+ g_type_class_unref(data->gclass);
133
+ for (i = 0; i < data->n_parameters; i++)
134
+ if (G_IS_VALUE(&data->parameters[i].value))
135
+ g_value_unset(&data->parameters[i].value);
136
+
137
+ return Qnil;
138
+ }
139
+
140
+ void
141
+ rbgio_gasyncinitable_new_async(GType type,
142
+ VALUE parameters,
143
+ VALUE io_priority,
144
+ VALUE cancellable,
145
+ VALUE block)
146
+ {
147
+ static ID s_id_length;
148
+ struct rbgio_gasyncinitable_new_async_data data;
149
+
150
+ if (s_id_length == 0)
151
+ s_id_length = rb_intern("length");
152
+
153
+ if (!g_type_is_a(type, G_TYPE_OBJECT))
154
+ rb_raise(rb_eArgError,
155
+ "%s is not a descendant of GObject",
156
+ g_type_name(type));
157
+
158
+ if (NIL_P(parameters)) {
159
+ SAVE_BLOCK(block);
160
+ g_async_initable_newv_async(type,
161
+ 0,
162
+ NULL,
163
+ RVAL2IOPRIORITYDEFAULT(io_priority),
164
+ RVAL2GCANCELLABLE(cancellable),
165
+ rbgio_async_ready_callback,
166
+ (gpointer)block);
167
+
168
+ return;
169
+ } else {
170
+ parameters = rb_convert_type(parameters,
171
+ T_HASH,
172
+ "Hash",
173
+ "to_hash");
174
+ }
175
+
176
+ data.gclass = G_OBJECT_CLASS(g_type_class_ref(type));
177
+ data.io_priority = RVAL2IOPRIORITYDEFAULT(io_priority);
178
+ data.cancellable = RVAL2GCANCELLABLE(cancellable);
179
+ data.block = block;
180
+ data.rbparameters = parameters;
181
+ data.index = 0;
182
+ data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0));
183
+ data.parameters = ALLOCA_N(GParameter, data.n_parameters);
184
+
185
+ rb_ensure(rbgio_gasyncinitable_new_async_body, (VALUE)&data,
186
+ rbgio_gasyncinitable_new_async_ensure, (VALUE)&data);
187
+
188
+ return;
189
+ }
190
+
191
+ static VALUE
192
+ asyncinitable_initialize(int argc, VALUE *argv, VALUE self)
193
+ {
194
+ const RGObjClassInfo* info;
195
+ VALUE io_priority, cancellable, parameters, block;
196
+
197
+ rb_scan_args(argc, argv, "03&", &io_priority, &cancellable, &parameters, &block);
198
+
199
+ info = CLASS2CINFO(self);
200
+ if (info->klass != self)
201
+ rb_raise(rb_eTypeError,
202
+ "%s: class not registered with GLib",
203
+ rb_class2name(self));
204
+
205
+ rbgio_gasyncinitable_new_async(info->gtype,
206
+ parameters,
207
+ io_priority,
208
+ cancellable,
209
+ block);
210
+
211
+ return self;
212
+ }
213
+
214
+
215
+ static VALUE
216
+ asyncinitable_initialize_finish(VALUE self, VALUE result)
217
+ {
218
+ GError *error = NULL;
219
+ GObject *object;
220
+ VALUE rbobject;
221
+
222
+ object = g_async_initable_new_finish(_SELF(self),
223
+ RVAL2GASYNCRESULT(result),
224
+ &error);
225
+ if (object == NULL)
226
+ rbgio_raise_error(error);
227
+
228
+ rbobject = GOBJ2RVAL(object);
229
+ g_object_unref(object);
230
+
231
+ return rbobject;
232
+ }
233
+
234
+ void
235
+ Init_gasyncinitable(VALUE glib)
236
+ {
237
+ VALUE asyncinitable = G_DEF_INTERFACE(G_TYPE_ASYNC_INITABLE, "AsyncInitable", glib);
238
+
239
+ rb_define_method(asyncinitable, "init_async", asyncinitable_init_async, -1);
240
+ rb_define_method(asyncinitable, "init_finish", asyncinitable_init_finish, 1);
241
+ rb_define_method(asyncinitable, "initialize", asyncinitable_initialize, -1);
242
+ /* TODO: Ruby name? */
243
+ rb_define_method(asyncinitable, "initialize_finish", asyncinitable_initialize_finish, 1);
244
+ }
@@ -0,0 +1,39 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) RVAL2GASYNCRESULT(value)
24
+
25
+ /* NOTE: g_async_result_get_user_data isn’t of any use from Ruby. */
26
+
27
+ static VALUE
28
+ asyncresult_get_source_object(VALUE self)
29
+ {
30
+ return GOBJ2RVAL_UNREF(g_async_result_get_source_object(_SELF(self)));
31
+ }
32
+
33
+ void
34
+ Init_gasyncresult(VALUE glib)
35
+ {
36
+ VALUE asyncresult = G_DEF_INTERFACE(G_TYPE_ASYNC_RESULT, "AsyncResult", glib);
37
+
38
+ rb_define_method(asyncresult, "source_object", asyncresult_get_source_object, 0);
39
+ }
@@ -0,0 +1,184 @@
1
+ /* -*- c-file-style: "ruby" -*- */
2
+ /*
3
+ * Ruby/GIO: a Ruby binding of gio-2.0.x.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ */
20
+
21
+ #include "gio2.h"
22
+
23
+ #define _SELF(value) G_BUFFERED_INPUT_STREAM(RVAL2GOBJ(value))
24
+
25
+ static VALUE
26
+ bufferedinputstream_initialize(int argc, VALUE *argv, VALUE self)
27
+ {
28
+ VALUE rbbase_stream, size;
29
+ GInputStream *base_stream, *stream;
30
+
31
+ rb_scan_args(argc, argv, "11", &rbbase_stream, &size);
32
+ base_stream = RVAL2GINPUTSTREAM(rbbase_stream);
33
+
34
+ stream = NIL_P(size) ?
35
+ g_buffered_input_stream_new(base_stream) :
36
+ g_buffered_input_stream_new_sized(base_stream, RVAL2GSIZE(size));
37
+ G_INITIALIZE(self, stream);
38
+
39
+ return Qnil;
40
+ }
41
+
42
+ static VALUE
43
+ bufferedinputstream_get_buffer_size(VALUE self)
44
+ {
45
+ return GSIZE2RVAL(g_buffered_input_stream_get_buffer_size(_SELF(self)));
46
+ }
47
+
48
+ static VALUE
49
+ bufferedinputstream_set_buffer_size(VALUE self, VALUE size)
50
+ {
51
+ g_buffered_input_stream_set_buffer_size(_SELF(self), RVAL2GSIZE(size));
52
+
53
+ return self;
54
+ }
55
+
56
+ static VALUE
57
+ bufferedinputstream_get_available(VALUE self)
58
+ {
59
+ return GSIZE2RVAL(g_buffered_input_stream_get_available(_SELF(self)));
60
+ }
61
+
62
+ static VALUE
63
+ bufferedinputstream_peek_buffer(VALUE self)
64
+ {
65
+ gsize size;
66
+ const void *buffer;
67
+
68
+ buffer = g_buffered_input_stream_peek_buffer(_SELF(self), &size);
69
+
70
+ return CSTR2RVAL_TAINTED(buffer, size);
71
+ }
72
+
73
+ static VALUE
74
+ bufferedinputstream_peek(VALUE self, VALUE rboffset, VALUE rbcount)
75
+ {
76
+ gsize offset = RVAL2GSIZE(rboffset);
77
+ gsize count = RVAL2GSIZE(rbcount);
78
+ VALUE result = rb_str_new(NULL, count);
79
+ gsize bytes_peeked = g_buffered_input_stream_peek(_SELF(self),
80
+ RSTRING_PTR(result),
81
+ offset,
82
+ count);
83
+ if (bytes_peeked == (gsize)-1)
84
+ rb_raise(rb_eIOError, "cannot peek"); /* TODO: Better class and message */
85
+
86
+ rb_str_set_len(result, bytes_peeked);
87
+ rb_str_resize(result, bytes_peeked);
88
+ OBJ_TAINT(result);
89
+
90
+ return result;
91
+ }
92
+
93
+ static VALUE
94
+ bufferedinputstream_fill(int argc, VALUE *argv, VALUE self)
95
+ {
96
+ VALUE count, cancellable;
97
+ GError *error = NULL;
98
+ gsize bytes_read;
99
+
100
+ rb_scan_args(argc, argv, "02", &count, &cancellable);
101
+ bytes_read = g_buffered_input_stream_fill(_SELF(self),
102
+ NIL_P(count) ?
103
+ -1 :
104
+ RVAL2GSSIZE(count),
105
+ RVAL2GCANCELLABLE(cancellable),
106
+ &error);
107
+ if (error != NULL)
108
+ rbgio_raise_error(error);
109
+
110
+ return GSSIZE2RVAL(bytes_read);
111
+ }
112
+
113
+ static VALUE
114
+ bufferedinputstream_fill_async(int argc, VALUE *argv, VALUE self)
115
+ {
116
+ VALUE rbcount, rbio_priority, rbcancellable, block;
117
+ gssize count;
118
+ int io_priority;
119
+ GCancellable *cancellable;
120
+
121
+ rb_scan_args(argc, argv, "03&", &rbcount, &rbio_priority, &rbcancellable, &block);
122
+ count = NIL_P(rbcount) ? -1 : RVAL2GSSIZE(rbcount);
123
+ io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
124
+ cancellable = RVAL2GCANCELLABLE(rbcancellable);
125
+ SAVE_BLOCK(block);
126
+ g_buffered_input_stream_fill_async(_SELF(self),
127
+ count,
128
+ io_priority,
129
+ cancellable,
130
+ rbgio_async_ready_callback,
131
+ (gpointer)block);
132
+
133
+ return self;
134
+ }
135
+
136
+ static VALUE
137
+ bufferedinputstream_fill_finish(VALUE self, VALUE result)
138
+ {
139
+ GError *error = NULL;
140
+ gsize bytes_read;
141
+
142
+ bytes_read = g_buffered_input_stream_fill_finish(_SELF(self),
143
+ RVAL2GASYNCRESULT(result),
144
+ &error);
145
+ if (error != NULL)
146
+ rbgio_raise_error(error);
147
+
148
+ return GSSIZE2RVAL(bytes_read);
149
+ }
150
+
151
+ static VALUE
152
+ bufferedinputstream_read_byte(int argc, VALUE *argv, VALUE self)
153
+ {
154
+ VALUE cancellable;
155
+ GError *error = NULL;
156
+ int byte;
157
+
158
+ rb_scan_args(argc, argv, "01", &cancellable);
159
+ byte = g_buffered_input_stream_read_byte(_SELF(self),
160
+ RVAL2GCANCELLABLE(cancellable),
161
+ &error);
162
+ if (error != NULL)
163
+ rbgio_raise_error(error);
164
+
165
+ return INT2FIX(byte);
166
+ }
167
+
168
+ void
169
+ Init_gbufferedinputstream(VALUE glib)
170
+ {
171
+ VALUE bufferedinputstream = G_DEF_CLASS(G_TYPE_BUFFERED_INPUT_STREAM, "BufferedInputStream", glib);
172
+
173
+ rb_define_method(bufferedinputstream, "initialize", bufferedinputstream_initialize, -1);
174
+ rb_define_method(bufferedinputstream, "buffer_size", bufferedinputstream_get_buffer_size, 0);
175
+ rb_define_method(bufferedinputstream, "set_buffer_size", bufferedinputstream_set_buffer_size, 1);
176
+ G_DEF_SETTER(bufferedinputstream, "buffer_size");
177
+ rb_define_method(bufferedinputstream, "available", bufferedinputstream_get_available, 0);
178
+ rb_define_method(bufferedinputstream, "peek_buffer", bufferedinputstream_peek_buffer, 0);
179
+ rb_define_method(bufferedinputstream, "peek", bufferedinputstream_peek, 2);
180
+ rb_define_method(bufferedinputstream, "fill", bufferedinputstream_fill, -1);
181
+ rb_define_method(bufferedinputstream, "fill_async", bufferedinputstream_fill_async, -1);
182
+ rb_define_method(bufferedinputstream, "fill_finish", bufferedinputstream_fill_finish, 1);
183
+ rb_define_method(bufferedinputstream, "read_byte", bufferedinputstream_read_byte, -1);
184
+ }