gio2 2.1.0 → 2.2.0

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 (140) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +26 -9
  3. data/ext/gio2/extconf.rb +38 -28
  4. data/ext/gio2/rb-gio2-pollable-source.c +59 -0
  5. data/ext/gio2/{rbgiofilteroutputstream.c → rb-gio2.c} +9 -5
  6. data/ext/gio2/{gio2.c → rb-gio2.h} +5 -10
  7. data/extconf.rb +22 -6
  8. data/lib/gio2.rb +38 -143
  9. data/lib/gio2/deprecated.rb +16 -0
  10. data/lib/gio2/inet-address.rb +33 -0
  11. data/lib/gio2/input-stream.rb +39 -0
  12. data/lib/gio2/loader.rb +244 -0
  13. data/lib/gio2/output-stream.rb +24 -0
  14. data/lib/gio2/pollable-input-stream.rb +51 -0
  15. data/lib/gio2/pollable-output-stream.rb +32 -0
  16. data/lib/gio2/resources.rb +62 -0
  17. data/test/fixture/content-type/x-content/unix-software/autorun.sh +1 -0
  18. data/test/fixture/resource/Rakefile +32 -0
  19. data/test/fixture/resource/logo.png +0 -0
  20. data/test/fixture/resource/ruby-gio2.gresource +0 -0
  21. data/test/fixture/resource/ruby-gio2.gresource.xml +6 -0
  22. data/test/gio2-test-utils.rb +21 -0
  23. data/test/gio2-test-utils/fixture.rb +24 -0
  24. data/test/gio2-test-utils/socket-client.rb +59 -0
  25. data/test/run-test.rb +45 -9
  26. data/test/test-buffered-input-stream.rb +23 -0
  27. data/test/test-charset-converter.rb +23 -0
  28. data/test/test-content-type.rb +31 -0
  29. data/test/test-data-input-stream.rb +21 -0
  30. data/test/test-file-enumerator.rb +26 -0
  31. data/test/test-file-monitor.rb +33 -0
  32. data/test/test-file.rb +28 -0
  33. data/test/test-inet-address.rb +34 -0
  34. data/test/test-input-stream.rb +36 -0
  35. data/test/test-output-stream.rb +39 -0
  36. data/test/test-pollable-input-stream.rb +54 -0
  37. data/test/test-pollable-output-stream.rb +53 -0
  38. data/test/test-resources.rb +58 -0
  39. metadata +49 -107
  40. data/README +0 -34
  41. data/ext/gio2/depend +0 -11
  42. data/ext/gio2/gio2.def +0 -2
  43. data/ext/gio2/gio2.h +0 -30
  44. data/ext/gio2/rbgio.c +0 -133
  45. data/ext/gio2/rbgio2.h +0 -158
  46. data/ext/gio2/rbgio2conversions.h +0 -154
  47. data/ext/gio2/rbgio2private.h +0 -148
  48. data/ext/gio2/rbgioappinfo.c +0 -317
  49. data/ext/gio2/rbgioapplaunchcontext.c +0 -81
  50. data/ext/gio2/rbgioasyncinitable.c +0 -246
  51. data/ext/gio2/rbgioasyncresult.c +0 -41
  52. data/ext/gio2/rbgiobufferedinputstream.c +0 -167
  53. data/ext/gio2/rbgiobufferedoutputstream.c +0 -50
  54. data/ext/gio2/rbgiocancellable.c +0 -180
  55. data/ext/gio2/rbgiocharsetconverter.c +0 -57
  56. data/ext/gio2/rbgiocontenttype.c +0 -131
  57. data/ext/gio2/rbgioconverter.c +0 -113
  58. data/ext/gio2/rbgioconverterinputstream.c +0 -43
  59. data/ext/gio2/rbgioconverteroutputstream.c +0 -43
  60. data/ext/gio2/rbgiodatainputstream.c +0 -309
  61. data/ext/gio2/rbgiodataoutputstream.c +0 -186
  62. data/ext/gio2/rbgiodesktopappinfo.c +0 -87
  63. data/ext/gio2/rbgiodrive.c +0 -266
  64. data/ext/gio2/rbgioemblem.c +0 -52
  65. data/ext/gio2/rbgioemblemedicon.c +0 -65
  66. data/ext/gio2/rbgiofile.c +0 -2045
  67. data/ext/gio2/rbgiofileattribute.c +0 -114
  68. data/ext/gio2/rbgiofileattributeinfo.c +0 -86
  69. data/ext/gio2/rbgiofileattributeinfolist.c +0 -108
  70. data/ext/gio2/rbgiofileattributematcher.c +0 -95
  71. data/ext/gio2/rbgiofiledescriptorbased.c +0 -45
  72. data/ext/gio2/rbgiofileenumerator.c +0 -166
  73. data/ext/gio2/rbgiofileicon.c +0 -41
  74. data/ext/gio2/rbgiofileinfo.c +0 -617
  75. data/ext/gio2/rbgiofileinputstream.c +0 -91
  76. data/ext/gio2/rbgiofileiostream.c +0 -98
  77. data/ext/gio2/rbgiofilemonitor.c +0 -46
  78. data/ext/gio2/rbgiofilenamecompleter.c +0 -73
  79. data/ext/gio2/rbgiofileoutputstream.c +0 -98
  80. data/ext/gio2/rbgiofilterinputstream.c +0 -28
  81. data/ext/gio2/rbgioicon.c +0 -69
  82. data/ext/gio2/rbgioinetaddress.c +0 -118
  83. data/ext/gio2/rbgioinetsocketaddress.c +0 -41
  84. data/ext/gio2/rbgioinitable.c +0 -199
  85. data/ext/gio2/rbgioinputstream.c +0 -341
  86. data/ext/gio2/rbgioio.c +0 -73
  87. data/ext/gio2/rbgioiomodule.c +0 -45
  88. data/ext/gio2/rbgioiomodules.c +0 -47
  89. data/ext/gio2/rbgioioscheduler.c +0 -102
  90. data/ext/gio2/rbgioioschedulerjob.c +0 -121
  91. data/ext/gio2/rbgioiostream.c +0 -107
  92. data/ext/gio2/rbgioloadableicon.c +0 -92
  93. data/ext/gio2/rbgiomemoryinputstream.c +0 -67
  94. data/ext/gio2/rbgiomemoryoutputstream.c +0 -44
  95. data/ext/gio2/rbgiomount.c +0 -286
  96. data/ext/gio2/rbgiomountoperation.c +0 -53
  97. data/ext/gio2/rbgionetworkaddress.c +0 -59
  98. data/ext/gio2/rbgionetworkservice.c +0 -45
  99. data/ext/gio2/rbgiooutputstream.c +0 -331
  100. data/ext/gio2/rbgioresolver.c +0 -230
  101. data/ext/gio2/rbgioseekable.c +0 -91
  102. data/ext/gio2/rbgiosimpleasyncresult.c +0 -152
  103. data/ext/gio2/rbgiosocket.c +0 -390
  104. data/ext/gio2/rbgiosocketaddress.c +0 -34
  105. data/ext/gio2/rbgiosocketaddressenumerator.c +0 -83
  106. data/ext/gio2/rbgiosocketclient.c +0 -207
  107. data/ext/gio2/rbgiosocketconnectable.c +0 -41
  108. data/ext/gio2/rbgiosocketconnection.c +0 -66
  109. data/ext/gio2/rbgiosocketconnectionfactory.c +0 -39
  110. data/ext/gio2/rbgiosocketcontrolmessage.c +0 -82
  111. data/ext/gio2/rbgiosocketlistener.c +0 -246
  112. data/ext/gio2/rbgiosocketservice.c +0 -66
  113. data/ext/gio2/rbgiosrvtarget.c +0 -76
  114. data/ext/gio2/rbgiotcpconnection.c +0 -28
  115. data/ext/gio2/rbgiothemedicon.c +0 -83
  116. data/ext/gio2/rbgiothreadedsocketservice.c +0 -43
  117. data/ext/gio2/rbgiotlscertificate.c +0 -89
  118. data/ext/gio2/rbgiounixconnection.c +0 -71
  119. data/ext/gio2/rbgiounixfdlist.c +0 -115
  120. data/ext/gio2/rbgiounixfdmessage.c +0 -74
  121. data/ext/gio2/rbgiounixinputstream.c +0 -51
  122. data/ext/gio2/rbgiounixmount.c +0 -164
  123. data/ext/gio2/rbgiounixmountmonitor.c +0 -65
  124. data/ext/gio2/rbgiounixmountpoint.c +0 -136
  125. data/ext/gio2/rbgiounixmountpoints.c +0 -58
  126. data/ext/gio2/rbgiounixmounts.c +0 -58
  127. data/ext/gio2/rbgiounixoutputstream.c +0 -51
  128. data/ext/gio2/rbgiounixsocketaddress.c +0 -69
  129. data/ext/gio2/rbgiovfs.c +0 -84
  130. data/ext/gio2/rbgiovolume.c +0 -193
  131. data/ext/gio2/rbgiovolumemonitor.c +0 -77
  132. data/ext/gio2/rbgiozlibcompressor.c +0 -52
  133. data/ext/gio2/rbgiozlibdecompressor.c +0 -45
  134. data/ext/gio2/util.c +0 -303
  135. data/test/test_bufferedinputstream.rb +0 -9
  136. data/test/test_charsetconverter.rb +0 -9
  137. data/test/test_datainputstream.rb +0 -7
  138. data/test/test_fileenumerator.rb +0 -8
  139. data/test/test_filemonitor.rb +0 -17
  140. data/test/test_inetaddress.rb +0 -8
@@ -1,53 +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 cMountOperation
25
- #define _SELF(value) RVAL2GMOUNTOPERATION(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self)
29
- {
30
- G_INITIALIZE(self, g_mount_operation_new());
31
-
32
- return Qnil;
33
- }
34
-
35
- static VALUE
36
- rg_reply(VALUE self, VALUE value)
37
- {
38
- g_mount_operation_reply(_SELF(self), RVAL2GMOUNTOPERATIONRESULT(value));
39
-
40
- return self;
41
- }
42
-
43
- void
44
- Init_gmountoperation(VALUE mGio)
45
- {
46
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_MOUNT_OPERATION, "MountOperation", mGio);
47
-
48
- G_DEF_CLASS(G_TYPE_MOUNT_OPERATION_RESULT, "Result", RG_TARGET_NAMESPACE);
49
- G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_MOUNT_OPERATION_RESULT, "G_MOUNT_OPERATION_");
50
-
51
- RG_DEF_METHOD(initialize, 0);
52
- RG_DEF_METHOD(reply, 1);
53
- }
@@ -1,59 +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 cNetworkAddress
25
- #define _SELF(value) RVAL2GNETWORKADDRESS(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self, VALUE hostname, VALUE port)
29
- {
30
- G_INITIALIZE(self, g_network_address_new(RVAL2CSTR(hostname),
31
- RVAL2GUINT16(port)));
32
-
33
- return Qnil;
34
- }
35
-
36
- static VALUE
37
- rg_s_parse(G_GNUC_UNUSED VALUE self, VALUE host_and_port, VALUE default_port)
38
- {
39
- GError *error = NULL;
40
- GSocketConnectable *connectable;
41
-
42
- connectable = g_network_address_parse(RVAL2CSTR(host_and_port),
43
- RVAL2GUINT16(default_port),
44
- &error);
45
- if (connectable == NULL)
46
- rbgio_raise_error(error);
47
-
48
- return GOBJ2RVAL_UNREF(connectable);
49
- }
50
-
51
- void
52
- Init_gnetworkaddress(VALUE mGio)
53
- {
54
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_NETWORK_ADDRESS, "NetworkAddress", mGio);
55
-
56
- RG_DEF_SMETHOD(parse, 2);
57
-
58
- RG_DEF_METHOD(initialize, 2);
59
- }
@@ -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 cNetworkService
25
- #define _SELF(value) RVAL2GNETWORKSERVICE(value)
26
-
27
- static VALUE
28
- rg_initialize(VALUE self, VALUE service, VALUE protocol, VALUE domain)
29
- {
30
- /* TODO: If these are infected, so should they be when returned. How
31
- * do we deal with that? */
32
- G_INITIALIZE(self, g_network_service_new(RVAL2CSTR(service),
33
- RVAL2CSTR(protocol),
34
- RVAL2CSTR(domain)));
35
-
36
- return Qnil;
37
- }
38
-
39
- void
40
- Init_gnetworkservice(VALUE mGio)
41
- {
42
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_NETWORK_SERVICE, "NetworkService", mGio);
43
-
44
- RG_DEF_METHOD(initialize, 3);
45
- }
@@ -1,331 +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 cOutputStream
25
- #define _SELF(value) RVAL2GOUTPUTSTREAM(value)
26
-
27
- #define RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(value) \
28
- RVAL2TYPE_WITH_DEFAULT((value), \
29
- RVAL2GOUTPUTSTREAMSPLICEFLAGS, \
30
- G_OUTPUT_STREAM_SPLICE_NONE)
31
-
32
- static VALUE
33
- rg_write(int argc, VALUE *argv, VALUE self)
34
- {
35
- VALUE rbbuffer, cancellable;
36
- const char *buffer;
37
- GError *error = NULL;
38
- gssize bytes_written;
39
-
40
- rb_scan_args(argc, argv, "11", &rbbuffer, &cancellable);
41
- buffer = RVAL2CSTR(rbbuffer);
42
- bytes_written = g_output_stream_write(_SELF(self),
43
- buffer,
44
- (gsize)RSTRING_LEN(rbbuffer),
45
- RVAL2GCANCELLABLE(cancellable),
46
- &error);
47
- if (bytes_written == -1)
48
- rbgio_raise_error(error);
49
-
50
- return GSSIZE2RVAL(bytes_written);
51
- }
52
-
53
- static VALUE
54
- rg_write_all(int argc, VALUE *argv, VALUE self)
55
- {
56
- VALUE rbbuffer, cancellable;
57
- const char *buffer;
58
- gsize bytes_written;
59
- GError *error = NULL;
60
-
61
- rb_scan_args(argc, argv, "11", &rbbuffer, &cancellable);
62
- buffer = RVAL2CSTR(rbbuffer);
63
- if (!g_output_stream_write_all(_SELF(self),
64
- buffer,
65
- (gsize)RSTRING_LEN(rbbuffer),
66
- &bytes_written,
67
- RVAL2GCANCELLABLE(cancellable),
68
- &error))
69
- rbgio_raise_error(error);
70
-
71
- return GSIZE2RVAL(bytes_written);
72
- }
73
-
74
- static VALUE
75
- rg_splice(int argc, VALUE *argv, VALUE self)
76
- {
77
- VALUE source, flags, cancellable;
78
- GError *error = NULL;
79
- gssize bytes_spliced;
80
-
81
- rb_scan_args(argc, argv, "12", &source, &flags, &cancellable);
82
- bytes_spliced = g_output_stream_splice(_SELF(self),
83
- RVAL2GINPUTSTREAM(source),
84
- RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(flags),
85
- RVAL2GCANCELLABLE(cancellable),
86
- &error);
87
- if (bytes_spliced == -1)
88
- rbgio_raise_error(error);
89
-
90
- return GSSIZE2RVAL(bytes_spliced);
91
- }
92
-
93
- typedef gboolean (*CancellableMethod)(GOutputStream *, GCancellable *, GError **);
94
-
95
- static VALUE
96
- cancellable_method(CancellableMethod method, int argc, VALUE *argv, VALUE self)
97
- {
98
- VALUE cancellable;
99
- GError *error = NULL;
100
-
101
- rb_scan_args(argc, argv, "01", &cancellable);
102
- if (!method(_SELF(self), RVAL2GCANCELLABLE(cancellable), &error))
103
- rbgio_raise_error(error);
104
-
105
- return self;
106
- }
107
-
108
- static VALUE
109
- rg_flush(int argc, VALUE *argv, VALUE self)
110
- {
111
- return cancellable_method(g_output_stream_flush, argc, argv, self);
112
- }
113
-
114
- static VALUE
115
- rg_close(int argc, VALUE *argv, VALUE self)
116
- {
117
- return cancellable_method(g_output_stream_close, argc, argv, self);
118
- }
119
-
120
- /* TODO: Does it make sense to use buffer and count? We should probably
121
- * provide a better wrapper that simply pumps out buffer while count hasn't
122
- * been reached, calling the callback with the bytes written, then with the
123
- * result. */
124
- static VALUE
125
- rg_write_async(int argc, VALUE *argv, VALUE self)
126
- {
127
- VALUE rbbuffer, rbcount, rbio_priority, rbcancellable, block;
128
- const gchar *buffer;
129
- gsize count;
130
- int io_priority;
131
- GCancellable *cancellable;
132
-
133
- rb_scan_args(argc, argv, "22&", &rbbuffer, &rbcount, &rbio_priority, &rbcancellable, &block);
134
- buffer = RVAL2CSTR(rbbuffer);
135
- count = RVAL2GSIZE(rbcount);
136
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
137
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
138
- SAVE_BLOCK(block);
139
- g_output_stream_write_async(_SELF(self),
140
- buffer,
141
- count,
142
- io_priority,
143
- cancellable,
144
- rbgio_async_ready_callback,
145
- (gpointer)block);
146
-
147
- return self;
148
- }
149
-
150
- typedef gssize (*SSizeFinishMethod)(GOutputStream *, GAsyncResult *, GError **);
151
-
152
- static VALUE
153
- ssize_finish_method(SSizeFinishMethod method, VALUE self, VALUE result)
154
- {
155
- GError *error = NULL;
156
- gssize bytes_read;
157
-
158
- bytes_read = method(_SELF(self), RVAL2GASYNCRESULT(result), &error);
159
- if (error != NULL)
160
- rbgio_raise_error(error);
161
-
162
- return GSSIZE2RVAL(bytes_read);
163
- }
164
-
165
- static VALUE
166
- rg_write_finish(VALUE self, VALUE result)
167
- {
168
- return ssize_finish_method(g_output_stream_write_finish, self, result);
169
- }
170
-
171
- static VALUE
172
- rg_splice_async(int argc, VALUE *argv, VALUE self)
173
- {
174
- VALUE rbsource, rbflags, rbio_priority, rbcancellable, block;
175
- GInputStream *source;
176
- GOutputStreamSpliceFlags flags;
177
- int io_priority;
178
- GCancellable *cancellable;
179
-
180
- rb_scan_args(argc, argv, "12&", &rbsource, &rbflags, &rbio_priority, &rbcancellable, &block);
181
- source = RVAL2GINPUTSTREAM(rbsource);
182
- flags = RVAL2GOUTPUTSTREAMSPLICEFLAGSDEFAULT(rbflags);
183
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
184
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
185
- SAVE_BLOCK(block);
186
- g_output_stream_splice_async(_SELF(self),
187
- source,
188
- flags,
189
- io_priority,
190
- cancellable,
191
- rbgio_async_ready_callback,
192
- (gpointer)block);
193
-
194
- return self;
195
- }
196
-
197
- static VALUE
198
- rg_splice_finish(VALUE self, VALUE result)
199
- {
200
- return ssize_finish_method(g_output_stream_splice_finish, self, result);
201
- }
202
-
203
- static VALUE
204
- rg_flush_async(int argc, VALUE *argv, VALUE self)
205
- {
206
- VALUE rbio_priority, rbcancellable, block;
207
- int io_priority;
208
- GCancellable *cancellable;
209
-
210
- rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
211
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
212
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
213
- SAVE_BLOCK(block);
214
- g_output_stream_flush_async(_SELF(self),
215
- io_priority,
216
- cancellable,
217
- rbgio_async_ready_callback,
218
- (gpointer)block);
219
-
220
- return self;
221
- }
222
-
223
- typedef gboolean (*BooleanFinishMethod)(GOutputStream *, GAsyncResult *, GError **);
224
-
225
- static VALUE
226
- boolean_finish_method(BooleanFinishMethod method, VALUE self, VALUE result)
227
- {
228
- GError *error = NULL;
229
-
230
- if (!method(_SELF(self), RVAL2GASYNCRESULT(result), &error))
231
- rbgio_raise_error(error);
232
-
233
- return self;
234
- }
235
-
236
- static VALUE
237
- rg_flush_finish(VALUE self, VALUE result)
238
- {
239
- return boolean_finish_method(g_output_stream_flush_finish, self, result);
240
- }
241
-
242
- static VALUE
243
- rg_close_async(int argc, VALUE *argv, VALUE self)
244
- {
245
- VALUE rbio_priority, rbcancellable, block;
246
- int io_priority;
247
- GCancellable *cancellable;
248
-
249
- rb_scan_args(argc, argv, "02&", &rbio_priority, &rbcancellable, &block);
250
- io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority);
251
- cancellable = RVAL2GCANCELLABLE(rbcancellable);
252
- SAVE_BLOCK(block);
253
- g_output_stream_close_async(_SELF(self),
254
- io_priority,
255
- cancellable,
256
- rbgio_async_ready_callback,
257
- (gpointer)block);
258
-
259
- return self;
260
- }
261
-
262
- static VALUE
263
- rg_close_finish(VALUE self, VALUE result)
264
- {
265
- return boolean_finish_method(g_output_stream_close_finish, self, result);
266
- }
267
-
268
- static VALUE
269
- rg_closing_p(VALUE self)
270
- {
271
- return CBOOL2RVAL(g_output_stream_is_closing(_SELF(self)));
272
- }
273
-
274
- static VALUE
275
- rg_closed_p(VALUE self)
276
- {
277
- return CBOOL2RVAL(g_output_stream_is_closed(_SELF(self)));
278
- }
279
-
280
- static VALUE
281
- rg_has_pending_p(VALUE self)
282
- {
283
- return CBOOL2RVAL(g_output_stream_has_pending(_SELF(self)));
284
- }
285
-
286
- static VALUE
287
- rg_set_pending(VALUE self)
288
- {
289
- GError *error = NULL;
290
-
291
- if (!g_output_stream_set_pending(_SELF(self), &error))
292
- rbgio_raise_error(error);
293
-
294
- return self;
295
- }
296
-
297
- static VALUE
298
- rg_clear_pending(VALUE self)
299
- {
300
- g_output_stream_clear_pending(_SELF(self));
301
-
302
- return self;
303
- }
304
-
305
- void
306
- Init_goutputstream(VALUE mGio)
307
- {
308
- VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(G_TYPE_OUTPUT_STREAM, "OutputStream", mGio);
309
-
310
- G_DEF_CLASS(G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "SpliceFlags", RG_TARGET_NAMESPACE);
311
- G_DEF_CONSTANTS(RG_TARGET_NAMESPACE, G_TYPE_OUTPUT_STREAM_SPLICE_FLAGS, "G_OUTPUT_STREAM_");
312
-
313
- RG_DEF_METHOD(write, -1);
314
- RG_DEF_METHOD(write_all, -1);
315
- RG_DEF_METHOD(splice, -1);
316
- RG_DEF_METHOD(flush, -1);
317
- RG_DEF_METHOD(close, -1);
318
- RG_DEF_METHOD(write_async, -1);
319
- RG_DEF_METHOD(write_finish, 1);
320
- RG_DEF_METHOD(splice_async, -1);
321
- RG_DEF_METHOD(splice_finish, 1);
322
- RG_DEF_METHOD(flush_async, -1);
323
- RG_DEF_METHOD(flush_finish, 1);
324
- RG_DEF_METHOD(close_async, -1);
325
- RG_DEF_METHOD(close_finish, 0);
326
- RG_DEF_METHOD_P(closing, 0);
327
- RG_DEF_METHOD_P(closed, 0);
328
- RG_DEF_METHOD_P(has_pending, 0);
329
- RG_DEF_METHOD(set_pending, 0);
330
- RG_DEF_METHOD(clear_pending, 0);
331
- }