1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8 "github.com/bnema/puregotk/v4/glib"
9 "github.com/bnema/puregotk/v4/gobject"
10)
11
12var xPollableSourceNew func(uintptr) *glib.Source
13
14// Utility method for #GPollableInputStream and #GPollableOutputStream
15// implementations. Creates a new #GSource that expects a callback of
16// type #GPollableSourceFunc. The new source does not actually do
17// anything on its own; use g_source_add_child_source() to add other
18// sources to it to cause it to trigger.
19func PollableSourceNew(PollableStreamVar *gobject.Object) *glib.Source {
20
21 cret := xPollableSourceNew(PollableStreamVar.GoPointer())
22 return cret
23}
24
25var xPollableSourceNewFull func(uintptr, *glib.Source, uintptr) *glib.Source
26
27// Utility method for #GPollableInputStream and #GPollableOutputStream
28// implementations. Creates a new #GSource, as with
29// g_pollable_source_new(), but also attaching @child_source (with a
30// dummy callback), and @cancellable, if they are non-%NULL.
31func PollableSourceNewFull(PollableStreamVar *gobject.Object, ChildSourceVar *glib.Source, CancellableVar *Cancellable) *glib.Source {
32
33 cret := xPollableSourceNewFull(PollableStreamVar.GoPointer(), ChildSourceVar, CancellableVar.GoPointer())
34 return cret
35}
36
37var xPollableStreamRead func(uintptr, []byte, uint, bool, uintptr, **glib.Error) int
38
39// Tries to read from @stream, as with g_input_stream_read() (if
40// @blocking is %TRUE) or g_pollable_input_stream_read_nonblocking()
41// (if @blocking is %FALSE). This can be used to more easily share
42// code between blocking and non-blocking implementations of a method.
43//
44// If @blocking is %FALSE, then @stream must be a
45// #GPollableInputStream for which g_pollable_input_stream_can_poll()
46// returns %TRUE, or else the behavior is undefined. If @blocking is
47// %TRUE, then @stream does not need to be a #GPollableInputStream.
48func PollableStreamRead(StreamVar *InputStream, BufferVar []byte, CountVar uint, BlockingVar bool, CancellableVar *Cancellable) (int, error) {
49 var cerr *glib.Error
50
51 cret := xPollableStreamRead(StreamVar.GoPointer(), BufferVar, CountVar, BlockingVar, CancellableVar.GoPointer(), &cerr)
52 if cerr == nil {
53 return cret, nil
54 }
55 return cret, cerr
56
57}
58
59var xPollableStreamWrite func(uintptr, []byte, uint, bool, uintptr, **glib.Error) int
60
61// Tries to write to @stream, as with g_output_stream_write() (if
62// @blocking is %TRUE) or g_pollable_output_stream_write_nonblocking()
63// (if @blocking is %FALSE). This can be used to more easily share
64// code between blocking and non-blocking implementations of a method.
65//
66// If @blocking is %FALSE, then @stream must be a
67// #GPollableOutputStream for which
68// g_pollable_output_stream_can_poll() returns %TRUE or else the
69// behavior is undefined. If @blocking is %TRUE, then @stream does not
70// need to be a #GPollableOutputStream.
71func PollableStreamWrite(StreamVar *OutputStream, BufferVar []byte, CountVar uint, BlockingVar bool, CancellableVar *Cancellable) (int, error) {
72 var cerr *glib.Error
73
74 cret := xPollableStreamWrite(StreamVar.GoPointer(), BufferVar, CountVar, BlockingVar, CancellableVar.GoPointer(), &cerr)
75 if cerr == nil {
76 return cret, nil
77 }
78 return cret, cerr
79
80}
81
82var xPollableStreamWriteAll func(uintptr, []byte, uint, bool, *uint, uintptr, **glib.Error) bool
83
84// Tries to write @count bytes to @stream, as with
85// g_output_stream_write_all(), but using g_pollable_stream_write()
86// rather than g_output_stream_write().
87//
88// On a successful write of @count bytes, %TRUE is returned, and
89// @bytes_written is set to @count.
90//
91// If there is an error during the operation (including
92// %G_IO_ERROR_WOULD_BLOCK in the non-blocking case), %FALSE is
93// returned and @error is set to indicate the error status,
94// @bytes_written is updated to contain the number of bytes written
95// into the stream before the error occurred.
96//
97// As with g_pollable_stream_write(), if @blocking is %FALSE, then
98// @stream must be a #GPollableOutputStream for which
99// g_pollable_output_stream_can_poll() returns %TRUE or else the
100// behavior is undefined. If @blocking is %TRUE, then @stream does not
101// need to be a #GPollableOutputStream.
102func PollableStreamWriteAll(StreamVar *OutputStream, BufferVar []byte, CountVar uint, BlockingVar bool, BytesWrittenVar *uint, CancellableVar *Cancellable) (bool, error) {
103 var cerr *glib.Error
104
105 cret := xPollableStreamWriteAll(StreamVar.GoPointer(), BufferVar, CountVar, BlockingVar, BytesWrittenVar, CancellableVar.GoPointer(), &cerr)
106 if cerr == nil {
107 return cret, nil
108 }
109 return cret, cerr
110
111}
112
113func init() {
114 core.SetPackageName("GIO", "gio-2.0")
115 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
116 var libs []uintptr
117 for _, libPath := range core.GetPaths("GIO") {
118 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
119 if err != nil {
120 panic(err)
121 }
122 libs = append(libs, lib)
123 }
124
125 core.PuregoSafeRegister(&xPollableSourceNew, libs, "g_pollable_source_new")
126 core.PuregoSafeRegister(&xPollableSourceNewFull, libs, "g_pollable_source_new_full")
127 core.PuregoSafeRegister(&xPollableStreamRead, libs, "g_pollable_stream_read")
128 core.PuregoSafeRegister(&xPollableStreamWrite, libs, "g_pollable_stream_write")
129 core.PuregoSafeRegister(&xPollableStreamWriteAll, libs, "g_pollable_stream_write_all")
130
131}