v0.2.1 c0399be

gpollableinputstream.go RawHistoryFolder

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/types"
13)
14
15// The interface for pollable input streams.
16//
17// The default implementation of @can_poll always returns %TRUE.
18//
19// The default implementation of @read_nonblocking calls
20// g_pollable_input_stream_is_readable(), and then calls
21// g_input_stream_read() if it returns %TRUE. This means you only need
22// to override it if it is possible that your @is_readable
23// implementation may return %TRUE when the stream is not actually
24// readable.
25type PollableInputStreamInterface struct {
26	_ structs.HostLayout
27
28	GIface uintptr
29
30	xCanPoll uintptr
31
32	xIsReadable uintptr
33
34	xCreateSource uintptr
35
36	xReadNonblocking uintptr
37}
38
39func (x *PollableInputStreamInterface) GoPointer() uintptr {
40	return uintptr(unsafe.Pointer(x))
41}
42
43// OverrideCanPoll sets the "can_poll" callback function.
44// Checks if the #GPollableInputStream instance is actually pollable
45func (x *PollableInputStreamInterface) OverrideCanPoll(cb func(PollableInputStream) bool) {
46	if cb == nil {
47		x.xCanPoll = 0
48	} else {
49		x.xCanPoll = purego.NewCallback(func(StreamVarp uintptr) bool {
50			return cb(&PollableInputStreamBase{Ptr: StreamVarp})
51		})
52	}
53}
54
55// GetCanPoll gets the "can_poll" callback function.
56// Checks if the #GPollableInputStream instance is actually pollable
57func (x *PollableInputStreamInterface) GetCanPoll() func(PollableInputStream) bool {
58	if x.xCanPoll == 0 {
59		return nil
60	}
61	var rawCallback func(StreamVarp uintptr) bool
62	purego.RegisterFunc(&rawCallback, x.xCanPoll)
63	return func(StreamVar PollableInputStream) bool {
64		return rawCallback(StreamVar.GoPointer())
65	}
66}
67
68// OverrideIsReadable sets the "is_readable" callback function.
69// Checks if the stream is readable
70func (x *PollableInputStreamInterface) OverrideIsReadable(cb func(PollableInputStream) bool) {
71	if cb == nil {
72		x.xIsReadable = 0
73	} else {
74		x.xIsReadable = purego.NewCallback(func(StreamVarp uintptr) bool {
75			return cb(&PollableInputStreamBase{Ptr: StreamVarp})
76		})
77	}
78}
79
80// GetIsReadable gets the "is_readable" callback function.
81// Checks if the stream is readable
82func (x *PollableInputStreamInterface) GetIsReadable() func(PollableInputStream) bool {
83	if x.xIsReadable == 0 {
84		return nil
85	}
86	var rawCallback func(StreamVarp uintptr) bool
87	purego.RegisterFunc(&rawCallback, x.xIsReadable)
88	return func(StreamVar PollableInputStream) bool {
89		return rawCallback(StreamVar.GoPointer())
90	}
91}
92
93// OverrideCreateSource sets the "create_source" callback function.
94// Creates a #GSource to poll the stream
95func (x *PollableInputStreamInterface) OverrideCreateSource(cb func(PollableInputStream, *Cancellable) *glib.Source) {
96	if cb == nil {
97		x.xCreateSource = 0
98	} else {
99		x.xCreateSource = purego.NewCallback(func(StreamVarp uintptr, CancellableVarp uintptr) *glib.Source {
100			return cb(&PollableInputStreamBase{Ptr: StreamVarp}, CancellableNewFromInternalPtr(CancellableVarp))
101		})
102	}
103}
104
105// GetCreateSource gets the "create_source" callback function.
106// Creates a #GSource to poll the stream
107func (x *PollableInputStreamInterface) GetCreateSource() func(PollableInputStream, *Cancellable) *glib.Source {
108	if x.xCreateSource == 0 {
109		return nil
110	}
111	var rawCallback func(StreamVarp uintptr, CancellableVarp uintptr) *glib.Source
112	purego.RegisterFunc(&rawCallback, x.xCreateSource)
113	return func(StreamVar PollableInputStream, CancellableVar *Cancellable) *glib.Source {
114		return rawCallback(StreamVar.GoPointer(), CancellableVar.GoPointer())
115	}
116}
117
118// OverrideReadNonblocking sets the "read_nonblocking" callback function.
119// Does a non-blocking read or returns
120//
121//	%G_IO_ERROR_WOULD_BLOCK
122func (x *PollableInputStreamInterface) OverrideReadNonblocking(cb func(PollableInputStream, *[]byte, uint) int) {
123	if cb == nil {
124		x.xReadNonblocking = 0
125	} else {
126		x.xReadNonblocking = purego.NewCallback(func(StreamVarp uintptr, BufferVarp *[]byte, CountVarp uint) int {
127			return cb(&PollableInputStreamBase{Ptr: StreamVarp}, BufferVarp, CountVarp)
128		})
129	}
130}
131
132// GetReadNonblocking gets the "read_nonblocking" callback function.
133// Does a non-blocking read or returns
134//
135//	%G_IO_ERROR_WOULD_BLOCK
136func (x *PollableInputStreamInterface) GetReadNonblocking() func(PollableInputStream, *[]byte, uint) int {
137	if x.xReadNonblocking == 0 {
138		return nil
139	}
140	var rawCallback func(StreamVarp uintptr, BufferVarp *[]byte, CountVarp uint) int
141	purego.RegisterFunc(&rawCallback, x.xReadNonblocking)
142	return func(StreamVar PollableInputStream, BufferVar *[]byte, CountVar uint) int {
143		return rawCallback(StreamVar.GoPointer(), BufferVar, CountVar)
144	}
145}
146
147// `GPollableInputStream` is implemented by [class@Gio.InputStream]s that
148// can be polled for readiness to read. This can be used when
149// interfacing with a non-GIO API that expects
150// UNIX-file-descriptor-style asynchronous I/O rather than GIO-style.
151//
152// Some classes may implement `GPollableInputStream` but have only certain
153// instances of that class be pollable. If [method@Gio.PollableInputStream.can_poll]
154// returns false, then the behavior of other `GPollableInputStream` methods is
155// undefined.
156type PollableInputStream interface {
157	GoPointer() uintptr
158	SetGoPointer(uintptr)
159	CanPoll() bool
160	CreateSource(CancellableVar *Cancellable) *glib.Source
161	IsReadable() bool
162	ReadNonblocking(BufferVar *[]byte, CountVar uint, CancellableVar *Cancellable) (int, error)
163}
164
165var xPollableInputStreamGLibType func() types.GType
166
167func PollableInputStreamGLibType() types.GType {
168	return xPollableInputStreamGLibType()
169}
170
171type PollableInputStreamBase struct {
172	Ptr uintptr
173}
174
175func (x *PollableInputStreamBase) GoPointer() uintptr {
176	if x == nil {
177		return 0
178	}
179	return x.Ptr
180}
181
182func (x *PollableInputStreamBase) SetGoPointer(ptr uintptr) {
183	x.Ptr = ptr
184}
185
186// Checks if @stream is actually pollable. Some classes may implement
187// #GPollableInputStream but have only certain instances of that class
188// be pollable. If this method returns %FALSE, then the behavior of
189// other #GPollableInputStream methods is undefined.
190//
191// For any given stream, the value returned by this method is constant;
192// a stream cannot switch from pollable to non-pollable or vice versa.
193func (x *PollableInputStreamBase) CanPoll() bool {
194
195	cret := XGPollableInputStreamCanPoll(x.GoPointer())
196	return cret
197}
198
199// Creates a #GSource that triggers when @stream can be read, or
200// @cancellable is triggered or an error occurs. The callback on the
201// source is of the #GPollableSourceFunc type.
202//
203// As with g_pollable_input_stream_is_readable(), it is possible that
204// the stream may not actually be readable even after the source
205// triggers, so you should use g_pollable_input_stream_read_nonblocking()
206// rather than g_input_stream_read() from the callback.
207//
208// The behaviour of this method is undefined if
209// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
210func (x *PollableInputStreamBase) CreateSource(CancellableVar *Cancellable) *glib.Source {
211
212	cret := XGPollableInputStreamCreateSource(x.GoPointer(), CancellableVar.GoPointer())
213	return cret
214}
215
216// Checks if @stream can be read.
217//
218// Note that some stream types may not be able to implement this 100%
219// reliably, and it is possible that a call to g_input_stream_read()
220// after this returns %TRUE would still block. To guarantee
221// non-blocking behavior, you should always use
222// g_pollable_input_stream_read_nonblocking(), which will return a
223// %G_IO_ERROR_WOULD_BLOCK error rather than blocking.
224//
225// The behaviour of this method is undefined if
226// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
227func (x *PollableInputStreamBase) IsReadable() bool {
228
229	cret := XGPollableInputStreamIsReadable(x.GoPointer())
230	return cret
231}
232
233// Attempts to read up to @count bytes from @stream into @buffer, as
234// with g_input_stream_read(). If @stream is not currently readable,
235// this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can
236// use g_pollable_input_stream_create_source() to create a #GSource
237// that will be triggered when @stream is readable.
238//
239// Note that since this method never blocks, you cannot actually
240// use @cancellable to cancel it. However, it will return an error
241// if @cancellable has already been cancelled when you call, which
242// may happen if you call this method after a source triggers due
243// to having been cancelled.
244//
245// The behaviour of this method is undefined if
246// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
247func (x *PollableInputStreamBase) ReadNonblocking(BufferVar *[]byte, CountVar uint, CancellableVar *Cancellable) (int, error) {
248	var cerr *glib.Error
249
250	cret := XGPollableInputStreamReadNonblocking(x.GoPointer(), BufferVar, CountVar, CancellableVar.GoPointer(), &cerr)
251	if cerr == nil {
252		return cret, nil
253	}
254	return cret, cerr
255
256}
257
258var XGPollableInputStreamCanPoll func(uintptr) bool
259var XGPollableInputStreamCreateSource func(uintptr, uintptr) *glib.Source
260var XGPollableInputStreamIsReadable func(uintptr) bool
261var XGPollableInputStreamReadNonblocking func(uintptr, *[]byte, uint, uintptr, **glib.Error) int
262
263func init() {
264	core.SetPackageName("GIO", "gio-2.0")
265	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
266	var libs []uintptr
267	for _, libPath := range core.GetPaths("GIO") {
268		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
269		if err != nil {
270			panic(err)
271		}
272		libs = append(libs, lib)
273	}
274
275	core.PuregoSafeRegister(&xPollableInputStreamGLibType, libs, "g_pollable_input_stream_get_type")
276
277	core.PuregoSafeRegister(&XGPollableInputStreamCanPoll, libs, "g_pollable_input_stream_can_poll")
278	core.PuregoSafeRegister(&XGPollableInputStreamCreateSource, libs, "g_pollable_input_stream_create_source")
279	core.PuregoSafeRegister(&XGPollableInputStreamIsReadable, libs, "g_pollable_input_stream_is_readable")
280	core.PuregoSafeRegister(&XGPollableInputStreamReadNonblocking, libs, "g_pollable_input_stream_read_nonblocking")
281
282}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close