1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type OutputStreamClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xWriteFn uintptr
22
23 xSplice uintptr
24
25 xFlush uintptr
26
27 xCloseFn uintptr
28
29 xWriteAsync uintptr
30
31 xWriteFinish uintptr
32
33 xSpliceAsync uintptr
34
35 xSpliceFinish uintptr
36
37 xFlushAsync uintptr
38
39 xFlushFinish uintptr
40
41 xCloseAsync uintptr
42
43 xCloseFinish uintptr
44
45 xWritevFn uintptr
46
47 xWritevAsync uintptr
48
49 xWritevFinish uintptr
50
51 xGReserved4 uintptr
52
53 xGReserved5 uintptr
54
55 xGReserved6 uintptr
56
57 xGReserved7 uintptr
58
59 xGReserved8 uintptr
60}
61
62func (x *OutputStreamClass) GoPointer() uintptr {
63 return uintptr(unsafe.Pointer(x))
64}
65
66// OverrideWriteFn sets the "write_fn" callback function.
67func (x *OutputStreamClass) OverrideWriteFn(cb func(*OutputStream, []byte, uint, *Cancellable) int) {
68 if cb == nil {
69 x.xWriteFn = 0
70 } else {
71 x.xWriteFn = purego.NewCallback(func(StreamVarp uintptr, BufferVarp []byte, CountVarp uint, CancellableVarp uintptr) int {
72 return cb(OutputStreamNewFromInternalPtr(StreamVarp), BufferVarp, CountVarp, CancellableNewFromInternalPtr(CancellableVarp))
73 })
74 }
75}
76
77// GetWriteFn gets the "write_fn" callback function.
78func (x *OutputStreamClass) GetWriteFn() func(*OutputStream, []byte, uint, *Cancellable) int {
79 if x.xWriteFn == 0 {
80 return nil
81 }
82 var rawCallback func(StreamVarp uintptr, BufferVarp []byte, CountVarp uint, CancellableVarp uintptr) int
83 purego.RegisterFunc(&rawCallback, x.xWriteFn)
84 return func(StreamVar *OutputStream, BufferVar []byte, CountVar uint, CancellableVar *Cancellable) int {
85 return rawCallback(StreamVar.GoPointer(), BufferVar, CountVar, CancellableVar.GoPointer())
86 }
87}
88
89// OverrideSplice sets the "splice" callback function.
90func (x *OutputStreamClass) OverrideSplice(cb func(*OutputStream, *InputStream, OutputStreamSpliceFlags, *Cancellable) int) {
91 if cb == nil {
92 x.xSplice = 0
93 } else {
94 x.xSplice = purego.NewCallback(func(StreamVarp uintptr, SourceVarp uintptr, FlagsVarp OutputStreamSpliceFlags, CancellableVarp uintptr) int {
95 return cb(OutputStreamNewFromInternalPtr(StreamVarp), InputStreamNewFromInternalPtr(SourceVarp), FlagsVarp, CancellableNewFromInternalPtr(CancellableVarp))
96 })
97 }
98}
99
100// GetSplice gets the "splice" callback function.
101func (x *OutputStreamClass) GetSplice() func(*OutputStream, *InputStream, OutputStreamSpliceFlags, *Cancellable) int {
102 if x.xSplice == 0 {
103 return nil
104 }
105 var rawCallback func(StreamVarp uintptr, SourceVarp uintptr, FlagsVarp OutputStreamSpliceFlags, CancellableVarp uintptr) int
106 purego.RegisterFunc(&rawCallback, x.xSplice)
107 return func(StreamVar *OutputStream, SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, CancellableVar *Cancellable) int {
108 return rawCallback(StreamVar.GoPointer(), SourceVar.GoPointer(), FlagsVar, CancellableVar.GoPointer())
109 }
110}
111
112// OverrideFlush sets the "flush" callback function.
113func (x *OutputStreamClass) OverrideFlush(cb func(*OutputStream, *Cancellable) bool) {
114 if cb == nil {
115 x.xFlush = 0
116 } else {
117 x.xFlush = purego.NewCallback(func(StreamVarp uintptr, CancellableVarp uintptr) bool {
118 return cb(OutputStreamNewFromInternalPtr(StreamVarp), CancellableNewFromInternalPtr(CancellableVarp))
119 })
120 }
121}
122
123// GetFlush gets the "flush" callback function.
124func (x *OutputStreamClass) GetFlush() func(*OutputStream, *Cancellable) bool {
125 if x.xFlush == 0 {
126 return nil
127 }
128 var rawCallback func(StreamVarp uintptr, CancellableVarp uintptr) bool
129 purego.RegisterFunc(&rawCallback, x.xFlush)
130 return func(StreamVar *OutputStream, CancellableVar *Cancellable) bool {
131 return rawCallback(StreamVar.GoPointer(), CancellableVar.GoPointer())
132 }
133}
134
135// OverrideCloseFn sets the "close_fn" callback function.
136func (x *OutputStreamClass) OverrideCloseFn(cb func(*OutputStream, *Cancellable) bool) {
137 if cb == nil {
138 x.xCloseFn = 0
139 } else {
140 x.xCloseFn = purego.NewCallback(func(StreamVarp uintptr, CancellableVarp uintptr) bool {
141 return cb(OutputStreamNewFromInternalPtr(StreamVarp), CancellableNewFromInternalPtr(CancellableVarp))
142 })
143 }
144}
145
146// GetCloseFn gets the "close_fn" callback function.
147func (x *OutputStreamClass) GetCloseFn() func(*OutputStream, *Cancellable) bool {
148 if x.xCloseFn == 0 {
149 return nil
150 }
151 var rawCallback func(StreamVarp uintptr, CancellableVarp uintptr) bool
152 purego.RegisterFunc(&rawCallback, x.xCloseFn)
153 return func(StreamVar *OutputStream, CancellableVar *Cancellable) bool {
154 return rawCallback(StreamVar.GoPointer(), CancellableVar.GoPointer())
155 }
156}
157
158// OverrideWriteAsync sets the "write_async" callback function.
159func (x *OutputStreamClass) OverrideWriteAsync(cb func(*OutputStream, []byte, uint, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
160 if cb == nil {
161 x.xWriteAsync = 0
162 } else {
163 x.xWriteAsync = purego.NewCallback(func(StreamVarp uintptr, BufferVarp []byte, CountVarp uint, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
164 cb(OutputStreamNewFromInternalPtr(StreamVarp), BufferVarp, CountVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
165 })
166 }
167}
168
169// GetWriteAsync gets the "write_async" callback function.
170func (x *OutputStreamClass) GetWriteAsync() func(*OutputStream, []byte, uint, int, *Cancellable, *AsyncReadyCallback, uintptr) {
171 if x.xWriteAsync == 0 {
172 return nil
173 }
174 var rawCallback func(StreamVarp uintptr, BufferVarp []byte, CountVarp uint, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
175 purego.RegisterFunc(&rawCallback, x.xWriteAsync)
176 return func(StreamVar *OutputStream, BufferVar []byte, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
177 rawCallback(StreamVar.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
178 }
179}
180
181// OverrideWriteFinish sets the "write_finish" callback function.
182func (x *OutputStreamClass) OverrideWriteFinish(cb func(*OutputStream, AsyncResult) int) {
183 if cb == nil {
184 x.xWriteFinish = 0
185 } else {
186 x.xWriteFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) int {
187 return cb(OutputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp})
188 })
189 }
190}
191
192// GetWriteFinish gets the "write_finish" callback function.
193func (x *OutputStreamClass) GetWriteFinish() func(*OutputStream, AsyncResult) int {
194 if x.xWriteFinish == 0 {
195 return nil
196 }
197 var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) int
198 purego.RegisterFunc(&rawCallback, x.xWriteFinish)
199 return func(StreamVar *OutputStream, ResultVar AsyncResult) int {
200 return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer())
201 }
202}
203
204// OverrideSpliceAsync sets the "splice_async" callback function.
205func (x *OutputStreamClass) OverrideSpliceAsync(cb func(*OutputStream, *InputStream, OutputStreamSpliceFlags, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
206 if cb == nil {
207 x.xSpliceAsync = 0
208 } else {
209 x.xSpliceAsync = purego.NewCallback(func(StreamVarp uintptr, SourceVarp uintptr, FlagsVarp OutputStreamSpliceFlags, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
210 cb(OutputStreamNewFromInternalPtr(StreamVarp), InputStreamNewFromInternalPtr(SourceVarp), FlagsVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
211 })
212 }
213}
214
215// GetSpliceAsync gets the "splice_async" callback function.
216func (x *OutputStreamClass) GetSpliceAsync() func(*OutputStream, *InputStream, OutputStreamSpliceFlags, int, *Cancellable, *AsyncReadyCallback, uintptr) {
217 if x.xSpliceAsync == 0 {
218 return nil
219 }
220 var rawCallback func(StreamVarp uintptr, SourceVarp uintptr, FlagsVarp OutputStreamSpliceFlags, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
221 purego.RegisterFunc(&rawCallback, x.xSpliceAsync)
222 return func(StreamVar *OutputStream, SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
223 rawCallback(StreamVar.GoPointer(), SourceVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
224 }
225}
226
227// OverrideSpliceFinish sets the "splice_finish" callback function.
228func (x *OutputStreamClass) OverrideSpliceFinish(cb func(*OutputStream, AsyncResult) int) {
229 if cb == nil {
230 x.xSpliceFinish = 0
231 } else {
232 x.xSpliceFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) int {
233 return cb(OutputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp})
234 })
235 }
236}
237
238// GetSpliceFinish gets the "splice_finish" callback function.
239func (x *OutputStreamClass) GetSpliceFinish() func(*OutputStream, AsyncResult) int {
240 if x.xSpliceFinish == 0 {
241 return nil
242 }
243 var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) int
244 purego.RegisterFunc(&rawCallback, x.xSpliceFinish)
245 return func(StreamVar *OutputStream, ResultVar AsyncResult) int {
246 return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer())
247 }
248}
249
250// OverrideFlushAsync sets the "flush_async" callback function.
251func (x *OutputStreamClass) OverrideFlushAsync(cb func(*OutputStream, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
252 if cb == nil {
253 x.xFlushAsync = 0
254 } else {
255 x.xFlushAsync = purego.NewCallback(func(StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
256 cb(OutputStreamNewFromInternalPtr(StreamVarp), IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
257 })
258 }
259}
260
261// GetFlushAsync gets the "flush_async" callback function.
262func (x *OutputStreamClass) GetFlushAsync() func(*OutputStream, int, *Cancellable, *AsyncReadyCallback, uintptr) {
263 if x.xFlushAsync == 0 {
264 return nil
265 }
266 var rawCallback func(StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
267 purego.RegisterFunc(&rawCallback, x.xFlushAsync)
268 return func(StreamVar *OutputStream, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
269 rawCallback(StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
270 }
271}
272
273// OverrideFlushFinish sets the "flush_finish" callback function.
274func (x *OutputStreamClass) OverrideFlushFinish(cb func(*OutputStream, AsyncResult) bool) {
275 if cb == nil {
276 x.xFlushFinish = 0
277 } else {
278 x.xFlushFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) bool {
279 return cb(OutputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp})
280 })
281 }
282}
283
284// GetFlushFinish gets the "flush_finish" callback function.
285func (x *OutputStreamClass) GetFlushFinish() func(*OutputStream, AsyncResult) bool {
286 if x.xFlushFinish == 0 {
287 return nil
288 }
289 var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) bool
290 purego.RegisterFunc(&rawCallback, x.xFlushFinish)
291 return func(StreamVar *OutputStream, ResultVar AsyncResult) bool {
292 return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer())
293 }
294}
295
296// OverrideCloseAsync sets the "close_async" callback function.
297func (x *OutputStreamClass) OverrideCloseAsync(cb func(*OutputStream, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
298 if cb == nil {
299 x.xCloseAsync = 0
300 } else {
301 x.xCloseAsync = purego.NewCallback(func(StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
302 cb(OutputStreamNewFromInternalPtr(StreamVarp), IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
303 })
304 }
305}
306
307// GetCloseAsync gets the "close_async" callback function.
308func (x *OutputStreamClass) GetCloseAsync() func(*OutputStream, int, *Cancellable, *AsyncReadyCallback, uintptr) {
309 if x.xCloseAsync == 0 {
310 return nil
311 }
312 var rawCallback func(StreamVarp uintptr, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
313 purego.RegisterFunc(&rawCallback, x.xCloseAsync)
314 return func(StreamVar *OutputStream, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
315 rawCallback(StreamVar.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
316 }
317}
318
319// OverrideCloseFinish sets the "close_finish" callback function.
320func (x *OutputStreamClass) OverrideCloseFinish(cb func(*OutputStream, AsyncResult) bool) {
321 if cb == nil {
322 x.xCloseFinish = 0
323 } else {
324 x.xCloseFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) bool {
325 return cb(OutputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp})
326 })
327 }
328}
329
330// GetCloseFinish gets the "close_finish" callback function.
331func (x *OutputStreamClass) GetCloseFinish() func(*OutputStream, AsyncResult) bool {
332 if x.xCloseFinish == 0 {
333 return nil
334 }
335 var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) bool
336 purego.RegisterFunc(&rawCallback, x.xCloseFinish)
337 return func(StreamVar *OutputStream, ResultVar AsyncResult) bool {
338 return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer())
339 }
340}
341
342// OverrideWritevFn sets the "writev_fn" callback function.
343func (x *OutputStreamClass) OverrideWritevFn(cb func(*OutputStream, []OutputVector, uint, *uint, *Cancellable) bool) {
344 if cb == nil {
345 x.xWritevFn = 0
346 } else {
347 x.xWritevFn = purego.NewCallback(func(StreamVarp uintptr, VectorsVarp []OutputVector, NVectorsVarp uint, BytesWrittenVarp *uint, CancellableVarp uintptr) bool {
348 return cb(OutputStreamNewFromInternalPtr(StreamVarp), VectorsVarp, NVectorsVarp, BytesWrittenVarp, CancellableNewFromInternalPtr(CancellableVarp))
349 })
350 }
351}
352
353// GetWritevFn gets the "writev_fn" callback function.
354func (x *OutputStreamClass) GetWritevFn() func(*OutputStream, []OutputVector, uint, *uint, *Cancellable) bool {
355 if x.xWritevFn == 0 {
356 return nil
357 }
358 var rawCallback func(StreamVarp uintptr, VectorsVarp []OutputVector, NVectorsVarp uint, BytesWrittenVarp *uint, CancellableVarp uintptr) bool
359 purego.RegisterFunc(&rawCallback, x.xWritevFn)
360 return func(StreamVar *OutputStream, VectorsVar []OutputVector, NVectorsVar uint, BytesWrittenVar *uint, CancellableVar *Cancellable) bool {
361 return rawCallback(StreamVar.GoPointer(), VectorsVar, NVectorsVar, BytesWrittenVar, CancellableVar.GoPointer())
362 }
363}
364
365// OverrideWritevAsync sets the "writev_async" callback function.
366func (x *OutputStreamClass) OverrideWritevAsync(cb func(*OutputStream, []OutputVector, uint, int, *Cancellable, *AsyncReadyCallback, uintptr)) {
367 if cb == nil {
368 x.xWritevAsync = 0
369 } else {
370 x.xWritevAsync = purego.NewCallback(func(StreamVarp uintptr, VectorsVarp []OutputVector, NVectorsVarp uint, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) {
371 cb(OutputStreamNewFromInternalPtr(StreamVarp), VectorsVarp, NVectorsVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp)
372 })
373 }
374}
375
376// GetWritevAsync gets the "writev_async" callback function.
377func (x *OutputStreamClass) GetWritevAsync() func(*OutputStream, []OutputVector, uint, int, *Cancellable, *AsyncReadyCallback, uintptr) {
378 if x.xWritevAsync == 0 {
379 return nil
380 }
381 var rawCallback func(StreamVarp uintptr, VectorsVarp []OutputVector, NVectorsVarp uint, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr)
382 purego.RegisterFunc(&rawCallback, x.xWritevAsync)
383 return func(StreamVar *OutputStream, VectorsVar []OutputVector, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
384 rawCallback(StreamVar.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar)
385 }
386}
387
388// OverrideWritevFinish sets the "writev_finish" callback function.
389func (x *OutputStreamClass) OverrideWritevFinish(cb func(*OutputStream, AsyncResult, *uint) bool) {
390 if cb == nil {
391 x.xWritevFinish = 0
392 } else {
393 x.xWritevFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr, BytesWrittenVarp *uint) bool {
394 return cb(OutputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp}, BytesWrittenVarp)
395 })
396 }
397}
398
399// GetWritevFinish gets the "writev_finish" callback function.
400func (x *OutputStreamClass) GetWritevFinish() func(*OutputStream, AsyncResult, *uint) bool {
401 if x.xWritevFinish == 0 {
402 return nil
403 }
404 var rawCallback func(StreamVarp uintptr, ResultVarp uintptr, BytesWrittenVarp *uint) bool
405 purego.RegisterFunc(&rawCallback, x.xWritevFinish)
406 return func(StreamVar *OutputStream, ResultVar AsyncResult, BytesWrittenVar *uint) bool {
407 return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer(), BytesWrittenVar)
408 }
409}
410
411// OverrideGReserved4 sets the "_g_reserved4" callback function.
412func (x *OutputStreamClass) OverrideGReserved4(cb func()) {
413 if cb == nil {
414 x.xGReserved4 = 0
415 } else {
416 x.xGReserved4 = purego.NewCallback(func() {
417 cb()
418 })
419 }
420}
421
422// GetGReserved4 gets the "_g_reserved4" callback function.
423func (x *OutputStreamClass) GetGReserved4() func() {
424 if x.xGReserved4 == 0 {
425 return nil
426 }
427 var rawCallback func()
428 purego.RegisterFunc(&rawCallback, x.xGReserved4)
429 return func() {
430 rawCallback()
431 }
432}
433
434// OverrideGReserved5 sets the "_g_reserved5" callback function.
435func (x *OutputStreamClass) OverrideGReserved5(cb func()) {
436 if cb == nil {
437 x.xGReserved5 = 0
438 } else {
439 x.xGReserved5 = purego.NewCallback(func() {
440 cb()
441 })
442 }
443}
444
445// GetGReserved5 gets the "_g_reserved5" callback function.
446func (x *OutputStreamClass) GetGReserved5() func() {
447 if x.xGReserved5 == 0 {
448 return nil
449 }
450 var rawCallback func()
451 purego.RegisterFunc(&rawCallback, x.xGReserved5)
452 return func() {
453 rawCallback()
454 }
455}
456
457// OverrideGReserved6 sets the "_g_reserved6" callback function.
458func (x *OutputStreamClass) OverrideGReserved6(cb func()) {
459 if cb == nil {
460 x.xGReserved6 = 0
461 } else {
462 x.xGReserved6 = purego.NewCallback(func() {
463 cb()
464 })
465 }
466}
467
468// GetGReserved6 gets the "_g_reserved6" callback function.
469func (x *OutputStreamClass) GetGReserved6() func() {
470 if x.xGReserved6 == 0 {
471 return nil
472 }
473 var rawCallback func()
474 purego.RegisterFunc(&rawCallback, x.xGReserved6)
475 return func() {
476 rawCallback()
477 }
478}
479
480// OverrideGReserved7 sets the "_g_reserved7" callback function.
481func (x *OutputStreamClass) OverrideGReserved7(cb func()) {
482 if cb == nil {
483 x.xGReserved7 = 0
484 } else {
485 x.xGReserved7 = purego.NewCallback(func() {
486 cb()
487 })
488 }
489}
490
491// GetGReserved7 gets the "_g_reserved7" callback function.
492func (x *OutputStreamClass) GetGReserved7() func() {
493 if x.xGReserved7 == 0 {
494 return nil
495 }
496 var rawCallback func()
497 purego.RegisterFunc(&rawCallback, x.xGReserved7)
498 return func() {
499 rawCallback()
500 }
501}
502
503// OverrideGReserved8 sets the "_g_reserved8" callback function.
504func (x *OutputStreamClass) OverrideGReserved8(cb func()) {
505 if cb == nil {
506 x.xGReserved8 = 0
507 } else {
508 x.xGReserved8 = purego.NewCallback(func() {
509 cb()
510 })
511 }
512}
513
514// GetGReserved8 gets the "_g_reserved8" callback function.
515func (x *OutputStreamClass) GetGReserved8() func() {
516 if x.xGReserved8 == 0 {
517 return nil
518 }
519 var rawCallback func()
520 purego.RegisterFunc(&rawCallback, x.xGReserved8)
521 return func() {
522 rawCallback()
523 }
524}
525
526type OutputStreamPrivate struct {
527 _ structs.HostLayout
528}
529
530func (x *OutputStreamPrivate) GoPointer() uintptr {
531 return uintptr(unsafe.Pointer(x))
532}
533
534// `GOutputStream` is a base class for implementing streaming output.
535//
536// It has functions to write to a stream ([method@Gio.OutputStream.write]),
537// to close a stream ([method@Gio.OutputStream.close]) and to flush pending
538// writes ([method@Gio.OutputStream.flush]).
539//
540// To copy the content of an input stream to an output stream without
541// manually handling the reads and writes, use [method@Gio.OutputStream.splice].
542//
543// See the documentation for [class@Gio.IOStream] for details of thread safety
544// of streaming APIs.
545//
546// All of these functions have async variants too.
547//
548// All classes derived from `GOutputStream` *should* implement synchronous
549// writing, splicing, flushing and closing streams, but *may* implement
550// asynchronous versions.
551type OutputStream struct {
552 gobject.Object
553}
554
555var xOutputStreamGLibType func() types.GType
556
557func OutputStreamGLibType() types.GType {
558 return xOutputStreamGLibType()
559}
560
561func OutputStreamNewFromInternalPtr(ptr uintptr) *OutputStream {
562 cls := &OutputStream{}
563 cls.Ptr = ptr
564 return cls
565}
566
567var xOutputStreamClearPending func(uintptr)
568
569// Clears the pending flag on @stream.
570func (x *OutputStream) ClearPending() {
571
572 xOutputStreamClearPending(x.GoPointer())
573
574}
575
576var xOutputStreamClose func(uintptr, uintptr, **glib.Error) bool
577
578// Closes the stream, releasing resources related to it.
579//
580// Once the stream is closed, all other operations will return %G_IO_ERROR_CLOSED.
581// Closing a stream multiple times will not return an error.
582//
583// Closing a stream will automatically flush any outstanding buffers in the
584// stream.
585//
586// Streams will be automatically closed when the last reference
587// is dropped, but you might want to call this function to make sure
588// resources are released as early as possible.
589//
590// Some streams might keep the backing store of the stream (e.g. a file descriptor)
591// open after the stream is closed. See the documentation for the individual
592// stream for details.
593//
594// On failure the first error that happened will be reported, but the close
595// operation will finish as much as possible. A stream that failed to
596// close will still return %G_IO_ERROR_CLOSED for all operations. Still, it
597// is important to check and report the error to the user, otherwise
598// there might be a loss of data as all data might not be written.
599//
600// If @cancellable is not %NULL, then the operation can be cancelled by
601// triggering the cancellable object from another thread. If the operation
602// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
603// Cancelling a close will still leave the stream closed, but there some streams
604// can use a faster close that doesn't block to e.g. check errors. On
605// cancellation (as with any error) there is no guarantee that all written
606// data will reach the target.
607func (x *OutputStream) Close(CancellableVar *Cancellable) (bool, error) {
608 var cerr *glib.Error
609
610 cret := xOutputStreamClose(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
611 if cerr == nil {
612 return cret, nil
613 }
614 return cret, cerr
615
616}
617
618var xOutputStreamCloseAsync func(uintptr, int, uintptr, uintptr, uintptr)
619
620// Requests an asynchronous close of the stream, releasing resources
621// related to it. When the operation is finished @callback will be
622// called. You can then call g_output_stream_close_finish() to get
623// the result of the operation.
624//
625// For behaviour details see g_output_stream_close().
626//
627// The asynchronous methods have a default fallback that uses threads
628// to implement asynchronicity, so they are optional for inheriting
629// classes. However, if you override one you must override all.
630func (x *OutputStream) CloseAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
631
632 var CallbackVarRef uintptr
633 if CallbackVar != nil {
634 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
635 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
636 CallbackVarRef = cbRefPtr
637 } else {
638 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
639 cbFn := *CallbackVar
640 cbFn(arg0, arg1, arg2)
641 }
642 CallbackVarRef = purego.NewCallback(fcb)
643 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
644 }
645 }
646
647 xOutputStreamCloseAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
648
649}
650
651var xOutputStreamCloseFinish func(uintptr, uintptr, **glib.Error) bool
652
653// Closes an output stream.
654func (x *OutputStream) CloseFinish(ResultVar AsyncResult) (bool, error) {
655 var cerr *glib.Error
656
657 cret := xOutputStreamCloseFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
658 if cerr == nil {
659 return cret, nil
660 }
661 return cret, cerr
662
663}
664
665var xOutputStreamFlush func(uintptr, uintptr, **glib.Error) bool
666
667// Forces a write of all user-space buffered data for the given
668// @stream. Will block during the operation. Closing the stream will
669// implicitly cause a flush.
670//
671// This function is optional for inherited classes.
672//
673// If @cancellable is not %NULL, then the operation can be cancelled by
674// triggering the cancellable object from another thread. If the operation
675// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
676func (x *OutputStream) Flush(CancellableVar *Cancellable) (bool, error) {
677 var cerr *glib.Error
678
679 cret := xOutputStreamFlush(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
680 if cerr == nil {
681 return cret, nil
682 }
683 return cret, cerr
684
685}
686
687var xOutputStreamFlushAsync func(uintptr, int, uintptr, uintptr, uintptr)
688
689// Forces an asynchronous write of all user-space buffered data for
690// the given @stream.
691// For behaviour details see g_output_stream_flush().
692//
693// When the operation is finished @callback will be
694// called. You can then call g_output_stream_flush_finish() to get the
695// result of the operation.
696func (x *OutputStream) FlushAsync(IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
697
698 var CallbackVarRef uintptr
699 if CallbackVar != nil {
700 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
701 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
702 CallbackVarRef = cbRefPtr
703 } else {
704 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
705 cbFn := *CallbackVar
706 cbFn(arg0, arg1, arg2)
707 }
708 CallbackVarRef = purego.NewCallback(fcb)
709 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
710 }
711 }
712
713 xOutputStreamFlushAsync(x.GoPointer(), IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
714
715}
716
717var xOutputStreamFlushFinish func(uintptr, uintptr, **glib.Error) bool
718
719// Finishes flushing an output stream.
720func (x *OutputStream) FlushFinish(ResultVar AsyncResult) (bool, error) {
721 var cerr *glib.Error
722
723 cret := xOutputStreamFlushFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
724 if cerr == nil {
725 return cret, nil
726 }
727 return cret, cerr
728
729}
730
731var xOutputStreamHasPending func(uintptr) bool
732
733// Checks if an output stream has pending actions.
734func (x *OutputStream) HasPending() bool {
735
736 cret := xOutputStreamHasPending(x.GoPointer())
737 return cret
738}
739
740var xOutputStreamIsClosed func(uintptr) bool
741
742// Checks if an output stream has already been closed.
743func (x *OutputStream) IsClosed() bool {
744
745 cret := xOutputStreamIsClosed(x.GoPointer())
746 return cret
747}
748
749var xOutputStreamIsClosing func(uintptr) bool
750
751// Checks if an output stream is being closed. This can be
752// used inside e.g. a flush implementation to see if the
753// flush (or other i/o operation) is called from within
754// the closing operation.
755func (x *OutputStream) IsClosing() bool {
756
757 cret := xOutputStreamIsClosing(x.GoPointer())
758 return cret
759}
760
761var xOutputStreamPrintf func(uintptr, *uint, uintptr, **glib.Error, string, ...interface{}) bool
762
763// This is a utility function around g_output_stream_write_all(). It
764// uses g_strdup_vprintf() to turn @format and @... into a string that
765// is then written to @stream.
766//
767// See the documentation of g_output_stream_write_all() about the
768// behavior of the actual write operation.
769//
770// Note that partial writes cannot be properly checked with this
771// function due to the variable length of the written string, if you
772// need precise control over partial write failures, you need to
773// create you own printf()-like wrapper around g_output_stream_write()
774// or g_output_stream_write_all().
775func (x *OutputStream) Printf(BytesWrittenVar *uint, CancellableVar *Cancellable, ErrorVar **glib.Error, FormatVar string, varArgs ...interface{}) bool {
776
777 cret := xOutputStreamPrintf(x.GoPointer(), BytesWrittenVar, CancellableVar.GoPointer(), ErrorVar, FormatVar, varArgs...)
778 return cret
779}
780
781var xOutputStreamSetPending func(uintptr) bool
782
783// Sets @stream to have actions pending. If the pending flag is
784// already set or @stream is closed, it will return %FALSE and set
785// @error.
786func (x *OutputStream) SetPending() (bool, error) {
787 var cerr *glib.Error
788
789 cret := xOutputStreamSetPending(x.GoPointer())
790 if cerr == nil {
791 return cret, nil
792 }
793 return cret, cerr
794
795}
796
797var xOutputStreamSplice func(uintptr, uintptr, OutputStreamSpliceFlags, uintptr, **glib.Error) int
798
799// Splices an input stream into an output stream.
800func (x *OutputStream) Splice(SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, CancellableVar *Cancellable) (int, error) {
801 var cerr *glib.Error
802
803 cret := xOutputStreamSplice(x.GoPointer(), SourceVar.GoPointer(), FlagsVar, CancellableVar.GoPointer(), &cerr)
804 if cerr == nil {
805 return cret, nil
806 }
807 return cret, cerr
808
809}
810
811var xOutputStreamSpliceAsync func(uintptr, uintptr, OutputStreamSpliceFlags, int, uintptr, uintptr, uintptr)
812
813// Splices a stream asynchronously.
814// When the operation is finished @callback will be called.
815// You can then call g_output_stream_splice_finish() to get the
816// result of the operation.
817//
818// For the synchronous, blocking version of this function, see
819// g_output_stream_splice().
820func (x *OutputStream) SpliceAsync(SourceVar *InputStream, FlagsVar OutputStreamSpliceFlags, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
821
822 var CallbackVarRef uintptr
823 if CallbackVar != nil {
824 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
825 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
826 CallbackVarRef = cbRefPtr
827 } else {
828 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
829 cbFn := *CallbackVar
830 cbFn(arg0, arg1, arg2)
831 }
832 CallbackVarRef = purego.NewCallback(fcb)
833 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
834 }
835 }
836
837 xOutputStreamSpliceAsync(x.GoPointer(), SourceVar.GoPointer(), FlagsVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
838
839}
840
841var xOutputStreamSpliceFinish func(uintptr, uintptr, **glib.Error) int
842
843// Finishes an asynchronous stream splice operation.
844func (x *OutputStream) SpliceFinish(ResultVar AsyncResult) (int, error) {
845 var cerr *glib.Error
846
847 cret := xOutputStreamSpliceFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
848 if cerr == nil {
849 return cret, nil
850 }
851 return cret, cerr
852
853}
854
855var xOutputStreamVprintf func(uintptr, *uint, uintptr, **glib.Error, string, []interface{}) bool
856
857// This is a utility function around g_output_stream_write_all(). It
858// uses g_strdup_vprintf() to turn @format and @args into a string that
859// is then written to @stream.
860//
861// See the documentation of g_output_stream_write_all() about the
862// behavior of the actual write operation.
863//
864// Note that partial writes cannot be properly checked with this
865// function due to the variable length of the written string, if you
866// need precise control over partial write failures, you need to
867// create you own printf()-like wrapper around g_output_stream_write()
868// or g_output_stream_write_all().
869func (x *OutputStream) Vprintf(BytesWrittenVar *uint, CancellableVar *Cancellable, ErrorVar **glib.Error, FormatVar string, ArgsVar []interface{}) bool {
870
871 cret := xOutputStreamVprintf(x.GoPointer(), BytesWrittenVar, CancellableVar.GoPointer(), ErrorVar, FormatVar, ArgsVar)
872 return cret
873}
874
875var xOutputStreamWrite func(uintptr, []byte, uint, uintptr, **glib.Error) int
876
877// Tries to write @count bytes from @buffer into the stream. Will block
878// during the operation.
879//
880// If count is 0, returns 0 and does nothing. A value of @count
881// larger than %G_MAXSSIZE will cause a %G_IO_ERROR_INVALID_ARGUMENT error.
882//
883// On success, the number of bytes written to the stream is returned.
884// It is not an error if this is not the same as the requested size, as it
885// can happen e.g. on a partial I/O error, or if there is not enough
886// storage in the stream. All writes block until at least one byte
887// is written or an error occurs; 0 is never returned (unless
888// @count is 0).
889//
890// If @cancellable is not %NULL, then the operation can be cancelled by
891// triggering the cancellable object from another thread. If the operation
892// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
893// operation was partially finished when the operation was cancelled the
894// partial result will be returned, without an error.
895//
896// On error -1 is returned and @error is set accordingly.
897func (x *OutputStream) Write(BufferVar []byte, CountVar uint, CancellableVar *Cancellable) (int, error) {
898 var cerr *glib.Error
899
900 cret := xOutputStreamWrite(x.GoPointer(), BufferVar, CountVar, CancellableVar.GoPointer(), &cerr)
901 if cerr == nil {
902 return cret, nil
903 }
904 return cret, cerr
905
906}
907
908var xOutputStreamWriteAll func(uintptr, []byte, uint, *uint, uintptr, **glib.Error) bool
909
910// Tries to write @count bytes from @buffer into the stream. Will block
911// during the operation.
912//
913// This function is similar to g_output_stream_write(), except it tries to
914// write as many bytes as requested, only stopping on an error.
915//
916// On a successful write of @count bytes, %TRUE is returned, and @bytes_written
917// is set to @count.
918//
919// If there is an error during the operation %FALSE is returned and @error
920// is set to indicate the error status.
921//
922// As a special exception to the normal conventions for functions that
923// use #GError, if this function returns %FALSE (and sets @error) then
924// @bytes_written will be set to the number of bytes that were
925// successfully written before the error was encountered. This
926// functionality is only available from C. If you need it from another
927// language then you must write your own loop around
928// g_output_stream_write().
929func (x *OutputStream) WriteAll(BufferVar []byte, CountVar uint, BytesWrittenVar *uint, CancellableVar *Cancellable) (bool, error) {
930 var cerr *glib.Error
931
932 cret := xOutputStreamWriteAll(x.GoPointer(), BufferVar, CountVar, BytesWrittenVar, CancellableVar.GoPointer(), &cerr)
933 if cerr == nil {
934 return cret, nil
935 }
936 return cret, cerr
937
938}
939
940var xOutputStreamWriteAllAsync func(uintptr, []byte, uint, int, uintptr, uintptr, uintptr)
941
942// Request an asynchronous write of @count bytes from @buffer into
943// the stream. When the operation is finished @callback will be called.
944// You can then call g_output_stream_write_all_finish() to get the result of the
945// operation.
946//
947// This is the asynchronous version of g_output_stream_write_all().
948//
949// Call g_output_stream_write_all_finish() to collect the result.
950//
951// Any outstanding I/O request with higher priority (lower numerical
952// value) will be executed before an outstanding request with lower
953// priority. Default priority is %G_PRIORITY_DEFAULT.
954//
955// Note that no copy of @buffer will be made, so it must stay valid
956// until @callback is called.
957func (x *OutputStream) WriteAllAsync(BufferVar []byte, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
958
959 var CallbackVarRef uintptr
960 if CallbackVar != nil {
961 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
962 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
963 CallbackVarRef = cbRefPtr
964 } else {
965 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
966 cbFn := *CallbackVar
967 cbFn(arg0, arg1, arg2)
968 }
969 CallbackVarRef = purego.NewCallback(fcb)
970 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
971 }
972 }
973
974 xOutputStreamWriteAllAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
975
976}
977
978var xOutputStreamWriteAllFinish func(uintptr, uintptr, *uint, **glib.Error) bool
979
980// Finishes an asynchronous stream write operation started with
981// g_output_stream_write_all_async().
982//
983// As a special exception to the normal conventions for functions that
984// use #GError, if this function returns %FALSE (and sets @error) then
985// @bytes_written will be set to the number of bytes that were
986// successfully written before the error was encountered. This
987// functionality is only available from C. If you need it from another
988// language then you must write your own loop around
989// g_output_stream_write_async().
990func (x *OutputStream) WriteAllFinish(ResultVar AsyncResult, BytesWrittenVar *uint) (bool, error) {
991 var cerr *glib.Error
992
993 cret := xOutputStreamWriteAllFinish(x.GoPointer(), ResultVar.GoPointer(), BytesWrittenVar, &cerr)
994 if cerr == nil {
995 return cret, nil
996 }
997 return cret, cerr
998
999}
1000
1001var xOutputStreamWriteAsync func(uintptr, []byte, uint, int, uintptr, uintptr, uintptr)
1002
1003// Request an asynchronous write of @count bytes from @buffer into
1004// the stream. When the operation is finished @callback will be called.
1005// You can then call g_output_stream_write_finish() to get the result of the
1006// operation.
1007//
1008// During an async request no other sync and async calls are allowed,
1009// and will result in %G_IO_ERROR_PENDING errors.
1010//
1011// A value of @count larger than %G_MAXSSIZE will cause a
1012// %G_IO_ERROR_INVALID_ARGUMENT error.
1013//
1014// On success, the number of bytes written will be passed to the
1015// @callback. It is not an error if this is not the same as the
1016// requested size, as it can happen e.g. on a partial I/O error,
1017// but generally we try to write as many bytes as requested.
1018//
1019// You are guaranteed that this method will never fail with
1020// %G_IO_ERROR_WOULD_BLOCK - if @stream can't accept more data, the
1021// method will just wait until this changes.
1022//
1023// Any outstanding I/O request with higher priority (lower numerical
1024// value) will be executed before an outstanding request with lower
1025// priority. Default priority is %G_PRIORITY_DEFAULT.
1026//
1027// The asynchronous methods have a default fallback that uses threads
1028// to implement asynchronicity, so they are optional for inheriting
1029// classes. However, if you override one you must override all.
1030//
1031// For the synchronous, blocking version of this function, see
1032// g_output_stream_write().
1033//
1034// Note that no copy of @buffer will be made, so it must stay valid
1035// until @callback is called. See g_output_stream_write_bytes_async()
1036// for a #GBytes version that will automatically hold a reference to
1037// the contents (without copying) for the duration of the call.
1038func (x *OutputStream) WriteAsync(BufferVar []byte, CountVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
1039
1040 var CallbackVarRef uintptr
1041 if CallbackVar != nil {
1042 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
1043 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
1044 CallbackVarRef = cbRefPtr
1045 } else {
1046 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
1047 cbFn := *CallbackVar
1048 cbFn(arg0, arg1, arg2)
1049 }
1050 CallbackVarRef = purego.NewCallback(fcb)
1051 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
1052 }
1053 }
1054
1055 xOutputStreamWriteAsync(x.GoPointer(), BufferVar, CountVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
1056
1057}
1058
1059var xOutputStreamWriteBytes func(uintptr, *glib.Bytes, uintptr, **glib.Error) int
1060
1061// A wrapper function for g_output_stream_write() which takes a
1062// #GBytes as input. This can be more convenient for use by language
1063// bindings or in other cases where the refcounted nature of #GBytes
1064// is helpful over a bare pointer interface.
1065//
1066// However, note that this function may still perform partial writes,
1067// just like g_output_stream_write(). If that occurs, to continue
1068// writing, you will need to create a new #GBytes containing just the
1069// remaining bytes, using g_bytes_new_from_bytes(). Passing the same
1070// #GBytes instance multiple times potentially can result in duplicated
1071// data in the output stream.
1072func (x *OutputStream) WriteBytes(BytesVar *glib.Bytes, CancellableVar *Cancellable) (int, error) {
1073 var cerr *glib.Error
1074
1075 cret := xOutputStreamWriteBytes(x.GoPointer(), BytesVar, CancellableVar.GoPointer(), &cerr)
1076 if cerr == nil {
1077 return cret, nil
1078 }
1079 return cret, cerr
1080
1081}
1082
1083var xOutputStreamWriteBytesAsync func(uintptr, *glib.Bytes, int, uintptr, uintptr, uintptr)
1084
1085// This function is similar to g_output_stream_write_async(), but
1086// takes a #GBytes as input. Due to the refcounted nature of #GBytes,
1087// this allows the stream to avoid taking a copy of the data.
1088//
1089// However, note that this function may still perform partial writes,
1090// just like g_output_stream_write_async(). If that occurs, to continue
1091// writing, you will need to create a new #GBytes containing just the
1092// remaining bytes, using g_bytes_new_from_bytes(). Passing the same
1093// #GBytes instance multiple times potentially can result in duplicated
1094// data in the output stream.
1095//
1096// For the synchronous, blocking version of this function, see
1097// g_output_stream_write_bytes().
1098func (x *OutputStream) WriteBytesAsync(BytesVar *glib.Bytes, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
1099
1100 var CallbackVarRef uintptr
1101 if CallbackVar != nil {
1102 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
1103 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
1104 CallbackVarRef = cbRefPtr
1105 } else {
1106 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
1107 cbFn := *CallbackVar
1108 cbFn(arg0, arg1, arg2)
1109 }
1110 CallbackVarRef = purego.NewCallback(fcb)
1111 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
1112 }
1113 }
1114
1115 xOutputStreamWriteBytesAsync(x.GoPointer(), BytesVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
1116
1117}
1118
1119var xOutputStreamWriteBytesFinish func(uintptr, uintptr, **glib.Error) int
1120
1121// Finishes a stream write-from-#GBytes operation.
1122func (x *OutputStream) WriteBytesFinish(ResultVar AsyncResult) (int, error) {
1123 var cerr *glib.Error
1124
1125 cret := xOutputStreamWriteBytesFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
1126 if cerr == nil {
1127 return cret, nil
1128 }
1129 return cret, cerr
1130
1131}
1132
1133var xOutputStreamWriteFinish func(uintptr, uintptr, **glib.Error) int
1134
1135// Finishes a stream write operation.
1136func (x *OutputStream) WriteFinish(ResultVar AsyncResult) (int, error) {
1137 var cerr *glib.Error
1138
1139 cret := xOutputStreamWriteFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr)
1140 if cerr == nil {
1141 return cret, nil
1142 }
1143 return cret, cerr
1144
1145}
1146
1147var xOutputStreamWritev func(uintptr, []OutputVector, uint, *uint, uintptr, **glib.Error) bool
1148
1149// Tries to write the bytes contained in the @n_vectors @vectors into the
1150// stream. Will block during the operation.
1151//
1152// If @n_vectors is 0 or the sum of all bytes in @vectors is 0, returns 0 and
1153// does nothing.
1154//
1155// On success, the number of bytes written to the stream is returned.
1156// It is not an error if this is not the same as the requested size, as it
1157// can happen e.g. on a partial I/O error, or if there is not enough
1158// storage in the stream. All writes block until at least one byte
1159// is written or an error occurs; 0 is never returned (unless
1160// @n_vectors is 0 or the sum of all bytes in @vectors is 0).
1161//
1162// If @cancellable is not %NULL, then the operation can be cancelled by
1163// triggering the cancellable object from another thread. If the operation
1164// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
1165// operation was partially finished when the operation was cancelled the
1166// partial result will be returned, without an error.
1167//
1168// Some implementations of g_output_stream_writev() may have limitations on the
1169// aggregate buffer size, and will return %G_IO_ERROR_INVALID_ARGUMENT if these
1170// are exceeded. For example, when writing to a local file on UNIX platforms,
1171// the aggregate buffer size must not exceed %G_MAXSSIZE bytes.
1172func (x *OutputStream) Writev(VectorsVar []OutputVector, NVectorsVar uint, BytesWrittenVar *uint, CancellableVar *Cancellable) (bool, error) {
1173 var cerr *glib.Error
1174
1175 cret := xOutputStreamWritev(x.GoPointer(), VectorsVar, NVectorsVar, BytesWrittenVar, CancellableVar.GoPointer(), &cerr)
1176 if cerr == nil {
1177 return cret, nil
1178 }
1179 return cret, cerr
1180
1181}
1182
1183var xOutputStreamWritevAll func(uintptr, []OutputVector, uint, *uint, uintptr, **glib.Error) bool
1184
1185// Tries to write the bytes contained in the @n_vectors @vectors into the
1186// stream. Will block during the operation.
1187//
1188// This function is similar to g_output_stream_writev(), except it tries to
1189// write as many bytes as requested, only stopping on an error.
1190//
1191// On a successful write of all @n_vectors vectors, %TRUE is returned, and
1192// @bytes_written is set to the sum of all the sizes of @vectors.
1193//
1194// If there is an error during the operation %FALSE is returned and @error
1195// is set to indicate the error status.
1196//
1197// As a special exception to the normal conventions for functions that
1198// use #GError, if this function returns %FALSE (and sets @error) then
1199// @bytes_written will be set to the number of bytes that were
1200// successfully written before the error was encountered. This
1201// functionality is only available from C. If you need it from another
1202// language then you must write your own loop around
1203// g_output_stream_write().
1204//
1205// The content of the individual elements of @vectors might be changed by this
1206// function.
1207func (x *OutputStream) WritevAll(VectorsVar []OutputVector, NVectorsVar uint, BytesWrittenVar *uint, CancellableVar *Cancellable) (bool, error) {
1208 var cerr *glib.Error
1209
1210 cret := xOutputStreamWritevAll(x.GoPointer(), VectorsVar, NVectorsVar, BytesWrittenVar, CancellableVar.GoPointer(), &cerr)
1211 if cerr == nil {
1212 return cret, nil
1213 }
1214 return cret, cerr
1215
1216}
1217
1218var xOutputStreamWritevAllAsync func(uintptr, []OutputVector, uint, int, uintptr, uintptr, uintptr)
1219
1220// Request an asynchronous write of the bytes contained in the @n_vectors @vectors into
1221// the stream. When the operation is finished @callback will be called.
1222// You can then call g_output_stream_writev_all_finish() to get the result of the
1223// operation.
1224//
1225// This is the asynchronous version of g_output_stream_writev_all().
1226//
1227// Call g_output_stream_writev_all_finish() to collect the result.
1228//
1229// Any outstanding I/O request with higher priority (lower numerical
1230// value) will be executed before an outstanding request with lower
1231// priority. Default priority is %G_PRIORITY_DEFAULT.
1232//
1233// Note that no copy of @vectors will be made, so it must stay valid
1234// until @callback is called. The content of the individual elements
1235// of @vectors might be changed by this function.
1236func (x *OutputStream) WritevAllAsync(VectorsVar []OutputVector, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
1237
1238 var CallbackVarRef uintptr
1239 if CallbackVar != nil {
1240 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
1241 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
1242 CallbackVarRef = cbRefPtr
1243 } else {
1244 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
1245 cbFn := *CallbackVar
1246 cbFn(arg0, arg1, arg2)
1247 }
1248 CallbackVarRef = purego.NewCallback(fcb)
1249 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
1250 }
1251 }
1252
1253 xOutputStreamWritevAllAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
1254
1255}
1256
1257var xOutputStreamWritevAllFinish func(uintptr, uintptr, *uint, **glib.Error) bool
1258
1259// Finishes an asynchronous stream write operation started with
1260// g_output_stream_writev_all_async().
1261//
1262// As a special exception to the normal conventions for functions that
1263// use #GError, if this function returns %FALSE (and sets @error) then
1264// @bytes_written will be set to the number of bytes that were
1265// successfully written before the error was encountered. This
1266// functionality is only available from C. If you need it from another
1267// language then you must write your own loop around
1268// g_output_stream_writev_async().
1269func (x *OutputStream) WritevAllFinish(ResultVar AsyncResult, BytesWrittenVar *uint) (bool, error) {
1270 var cerr *glib.Error
1271
1272 cret := xOutputStreamWritevAllFinish(x.GoPointer(), ResultVar.GoPointer(), BytesWrittenVar, &cerr)
1273 if cerr == nil {
1274 return cret, nil
1275 }
1276 return cret, cerr
1277
1278}
1279
1280var xOutputStreamWritevAsync func(uintptr, []OutputVector, uint, int, uintptr, uintptr, uintptr)
1281
1282// Request an asynchronous write of the bytes contained in @n_vectors @vectors into
1283// the stream. When the operation is finished @callback will be called.
1284// You can then call g_output_stream_writev_finish() to get the result of the
1285// operation.
1286//
1287// During an async request no other sync and async calls are allowed,
1288// and will result in %G_IO_ERROR_PENDING errors.
1289//
1290// On success, the number of bytes written will be passed to the
1291// @callback. It is not an error if this is not the same as the
1292// requested size, as it can happen e.g. on a partial I/O error,
1293// but generally we try to write as many bytes as requested.
1294//
1295// You are guaranteed that this method will never fail with
1296// %G_IO_ERROR_WOULD_BLOCK — if @stream can't accept more data, the
1297// method will just wait until this changes.
1298//
1299// Any outstanding I/O request with higher priority (lower numerical
1300// value) will be executed before an outstanding request with lower
1301// priority. Default priority is %G_PRIORITY_DEFAULT.
1302//
1303// The asynchronous methods have a default fallback that uses threads
1304// to implement asynchronicity, so they are optional for inheriting
1305// classes. However, if you override one you must override all.
1306//
1307// For the synchronous, blocking version of this function, see
1308// g_output_stream_writev().
1309//
1310// Note that no copy of @vectors will be made, so it must stay valid
1311// until @callback is called.
1312func (x *OutputStream) WritevAsync(VectorsVar []OutputVector, NVectorsVar uint, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) {
1313
1314 var CallbackVarRef uintptr
1315 if CallbackVar != nil {
1316 CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar))
1317 if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok {
1318 CallbackVarRef = cbRefPtr
1319 } else {
1320 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
1321 cbFn := *CallbackVar
1322 cbFn(arg0, arg1, arg2)
1323 }
1324 CallbackVarRef = purego.NewCallback(fcb)
1325 glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar)
1326 }
1327 }
1328
1329 xOutputStreamWritevAsync(x.GoPointer(), VectorsVar, NVectorsVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar)
1330
1331}
1332
1333var xOutputStreamWritevFinish func(uintptr, uintptr, *uint, **glib.Error) bool
1334
1335// Finishes a stream writev operation.
1336func (x *OutputStream) WritevFinish(ResultVar AsyncResult, BytesWrittenVar *uint) (bool, error) {
1337 var cerr *glib.Error
1338
1339 cret := xOutputStreamWritevFinish(x.GoPointer(), ResultVar.GoPointer(), BytesWrittenVar, &cerr)
1340 if cerr == nil {
1341 return cret, nil
1342 }
1343 return cret, cerr
1344
1345}
1346
1347func (c *OutputStream) GoPointer() uintptr {
1348 if c == nil {
1349 return 0
1350 }
1351 return c.Ptr
1352}
1353
1354func (c *OutputStream) SetGoPointer(ptr uintptr) {
1355 c.Ptr = ptr
1356}
1357
1358func init() {
1359 core.SetPackageName("GIO", "gio-2.0")
1360 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
1361 var libs []uintptr
1362 for _, libPath := range core.GetPaths("GIO") {
1363 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1364 if err != nil {
1365 panic(err)
1366 }
1367 libs = append(libs, lib)
1368 }
1369
1370 core.PuregoSafeRegister(&xOutputStreamGLibType, libs, "g_output_stream_get_type")
1371
1372 core.PuregoSafeRegister(&xOutputStreamClearPending, libs, "g_output_stream_clear_pending")
1373 core.PuregoSafeRegister(&xOutputStreamClose, libs, "g_output_stream_close")
1374 core.PuregoSafeRegister(&xOutputStreamCloseAsync, libs, "g_output_stream_close_async")
1375 core.PuregoSafeRegister(&xOutputStreamCloseFinish, libs, "g_output_stream_close_finish")
1376 core.PuregoSafeRegister(&xOutputStreamFlush, libs, "g_output_stream_flush")
1377 core.PuregoSafeRegister(&xOutputStreamFlushAsync, libs, "g_output_stream_flush_async")
1378 core.PuregoSafeRegister(&xOutputStreamFlushFinish, libs, "g_output_stream_flush_finish")
1379 core.PuregoSafeRegister(&xOutputStreamHasPending, libs, "g_output_stream_has_pending")
1380 core.PuregoSafeRegister(&xOutputStreamIsClosed, libs, "g_output_stream_is_closed")
1381 core.PuregoSafeRegister(&xOutputStreamIsClosing, libs, "g_output_stream_is_closing")
1382 core.PuregoSafeRegister(&xOutputStreamPrintf, libs, "g_output_stream_printf")
1383 core.PuregoSafeRegister(&xOutputStreamSetPending, libs, "g_output_stream_set_pending")
1384 core.PuregoSafeRegister(&xOutputStreamSplice, libs, "g_output_stream_splice")
1385 core.PuregoSafeRegister(&xOutputStreamSpliceAsync, libs, "g_output_stream_splice_async")
1386 core.PuregoSafeRegister(&xOutputStreamSpliceFinish, libs, "g_output_stream_splice_finish")
1387 core.PuregoSafeRegister(&xOutputStreamVprintf, libs, "g_output_stream_vprintf")
1388 core.PuregoSafeRegister(&xOutputStreamWrite, libs, "g_output_stream_write")
1389 core.PuregoSafeRegister(&xOutputStreamWriteAll, libs, "g_output_stream_write_all")
1390 core.PuregoSafeRegister(&xOutputStreamWriteAllAsync, libs, "g_output_stream_write_all_async")
1391 core.PuregoSafeRegister(&xOutputStreamWriteAllFinish, libs, "g_output_stream_write_all_finish")
1392 core.PuregoSafeRegister(&xOutputStreamWriteAsync, libs, "g_output_stream_write_async")
1393 core.PuregoSafeRegister(&xOutputStreamWriteBytes, libs, "g_output_stream_write_bytes")
1394 core.PuregoSafeRegister(&xOutputStreamWriteBytesAsync, libs, "g_output_stream_write_bytes_async")
1395 core.PuregoSafeRegister(&xOutputStreamWriteBytesFinish, libs, "g_output_stream_write_bytes_finish")
1396 core.PuregoSafeRegister(&xOutputStreamWriteFinish, libs, "g_output_stream_write_finish")
1397 core.PuregoSafeRegister(&xOutputStreamWritev, libs, "g_output_stream_writev")
1398 core.PuregoSafeRegister(&xOutputStreamWritevAll, libs, "g_output_stream_writev_all")
1399 core.PuregoSafeRegister(&xOutputStreamWritevAllAsync, libs, "g_output_stream_writev_all_async")
1400 core.PuregoSafeRegister(&xOutputStreamWritevAllFinish, libs, "g_output_stream_writev_all_finish")
1401 core.PuregoSafeRegister(&xOutputStreamWritevAsync, libs, "g_output_stream_writev_async")
1402 core.PuregoSafeRegister(&xOutputStreamWritevFinish, libs, "g_output_stream_writev_finish")
1403
1404}