v0.2.2 9100209

gmemoryinputstream.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
15type MemoryInputStreamClass struct {
16	_ structs.HostLayout
17
18	ParentClass InputStreamClass
19
20	xGReserved1 uintptr
21
22	xGReserved2 uintptr
23
24	xGReserved3 uintptr
25
26	xGReserved4 uintptr
27
28	xGReserved5 uintptr
29}
30
31func (x *MemoryInputStreamClass) GoPointer() uintptr {
32	return uintptr(unsafe.Pointer(x))
33}
34
35// OverrideGReserved1 sets the "_g_reserved1" callback function.
36func (x *MemoryInputStreamClass) OverrideGReserved1(cb func()) {
37	if cb == nil {
38		x.xGReserved1 = 0
39	} else {
40		x.xGReserved1 = purego.NewCallback(func() {
41			cb()
42		})
43	}
44}
45
46// GetGReserved1 gets the "_g_reserved1" callback function.
47func (x *MemoryInputStreamClass) GetGReserved1() func() {
48	if x.xGReserved1 == 0 {
49		return nil
50	}
51	var rawCallback func()
52	purego.RegisterFunc(&rawCallback, x.xGReserved1)
53	return func() {
54		rawCallback()
55	}
56}
57
58// OverrideGReserved2 sets the "_g_reserved2" callback function.
59func (x *MemoryInputStreamClass) OverrideGReserved2(cb func()) {
60	if cb == nil {
61		x.xGReserved2 = 0
62	} else {
63		x.xGReserved2 = purego.NewCallback(func() {
64			cb()
65		})
66	}
67}
68
69// GetGReserved2 gets the "_g_reserved2" callback function.
70func (x *MemoryInputStreamClass) GetGReserved2() func() {
71	if x.xGReserved2 == 0 {
72		return nil
73	}
74	var rawCallback func()
75	purego.RegisterFunc(&rawCallback, x.xGReserved2)
76	return func() {
77		rawCallback()
78	}
79}
80
81// OverrideGReserved3 sets the "_g_reserved3" callback function.
82func (x *MemoryInputStreamClass) OverrideGReserved3(cb func()) {
83	if cb == nil {
84		x.xGReserved3 = 0
85	} else {
86		x.xGReserved3 = purego.NewCallback(func() {
87			cb()
88		})
89	}
90}
91
92// GetGReserved3 gets the "_g_reserved3" callback function.
93func (x *MemoryInputStreamClass) GetGReserved3() func() {
94	if x.xGReserved3 == 0 {
95		return nil
96	}
97	var rawCallback func()
98	purego.RegisterFunc(&rawCallback, x.xGReserved3)
99	return func() {
100		rawCallback()
101	}
102}
103
104// OverrideGReserved4 sets the "_g_reserved4" callback function.
105func (x *MemoryInputStreamClass) OverrideGReserved4(cb func()) {
106	if cb == nil {
107		x.xGReserved4 = 0
108	} else {
109		x.xGReserved4 = purego.NewCallback(func() {
110			cb()
111		})
112	}
113}
114
115// GetGReserved4 gets the "_g_reserved4" callback function.
116func (x *MemoryInputStreamClass) GetGReserved4() func() {
117	if x.xGReserved4 == 0 {
118		return nil
119	}
120	var rawCallback func()
121	purego.RegisterFunc(&rawCallback, x.xGReserved4)
122	return func() {
123		rawCallback()
124	}
125}
126
127// OverrideGReserved5 sets the "_g_reserved5" callback function.
128func (x *MemoryInputStreamClass) OverrideGReserved5(cb func()) {
129	if cb == nil {
130		x.xGReserved5 = 0
131	} else {
132		x.xGReserved5 = purego.NewCallback(func() {
133			cb()
134		})
135	}
136}
137
138// GetGReserved5 gets the "_g_reserved5" callback function.
139func (x *MemoryInputStreamClass) GetGReserved5() func() {
140	if x.xGReserved5 == 0 {
141		return nil
142	}
143	var rawCallback func()
144	purego.RegisterFunc(&rawCallback, x.xGReserved5)
145	return func() {
146		rawCallback()
147	}
148}
149
150type MemoryInputStreamPrivate struct {
151	_ structs.HostLayout
152}
153
154func (x *MemoryInputStreamPrivate) GoPointer() uintptr {
155	return uintptr(unsafe.Pointer(x))
156}
157
158// `GMemoryInputStream` is a class for using arbitrary
159// memory chunks as input for GIO streaming input operations.
160//
161// As of GLib 2.34, `GMemoryInputStream` implements
162// [iface@Gio.PollableInputStream].
163type MemoryInputStream struct {
164	InputStream
165}
166
167var xMemoryInputStreamGLibType func() types.GType
168
169func MemoryInputStreamGLibType() types.GType {
170	return xMemoryInputStreamGLibType()
171}
172
173func MemoryInputStreamNewFromInternalPtr(ptr uintptr) *MemoryInputStream {
174	cls := &MemoryInputStream{}
175	cls.Ptr = ptr
176	return cls
177}
178
179var xNewMemoryInputStream func() uintptr
180
181// Creates a new empty #GMemoryInputStream.
182func NewMemoryInputStream() *MemoryInputStream {
183	var cls *MemoryInputStream
184
185	cret := xNewMemoryInputStream()
186
187	if cret == 0 {
188		return nil
189	}
190	cls = &MemoryInputStream{}
191	cls.Ptr = cret
192	return cls
193}
194
195var xNewMemoryInputStreamFromBytes func(*glib.Bytes) uintptr
196
197// Creates a new #GMemoryInputStream with data from the given @bytes.
198func NewMemoryInputStreamFromBytes(BytesVar *glib.Bytes) *MemoryInputStream {
199	var cls *MemoryInputStream
200
201	cret := xNewMemoryInputStreamFromBytes(BytesVar)
202
203	if cret == 0 {
204		return nil
205	}
206	cls = &MemoryInputStream{}
207	cls.Ptr = cret
208	return cls
209}
210
211var xNewMemoryInputStreamFromData func([]byte, int, uintptr) uintptr
212
213// Creates a new #GMemoryInputStream with data in memory of a given size.
214func NewMemoryInputStreamFromData(DataVar []byte, LenVar int, DestroyVar *glib.DestroyNotify) *MemoryInputStream {
215	var cls *MemoryInputStream
216
217	var DestroyVarRef uintptr
218	if DestroyVar != nil {
219		DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar))
220		if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok {
221			DestroyVarRef = cbRefPtr
222		} else {
223			fcb := func(arg0 uintptr) {
224				cbFn := *DestroyVar
225				cbFn(arg0)
226			}
227			DestroyVarRef = purego.NewCallback(fcb)
228			glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar)
229		}
230	}
231
232	cret := xNewMemoryInputStreamFromData(DataVar, LenVar, DestroyVarRef)
233
234	if cret == 0 {
235		return nil
236	}
237	cls = &MemoryInputStream{}
238	cls.Ptr = cret
239	return cls
240}
241
242var xMemoryInputStreamAddBytes func(uintptr, *glib.Bytes)
243
244// Appends @bytes to data that can be read from the input stream.
245func (x *MemoryInputStream) AddBytes(BytesVar *glib.Bytes) {
246
247	xMemoryInputStreamAddBytes(x.GoPointer(), BytesVar)
248
249}
250
251var xMemoryInputStreamAddData func(uintptr, []byte, int, uintptr)
252
253// Appends @data to data that can be read from the input stream
254func (x *MemoryInputStream) AddData(DataVar []byte, LenVar int, DestroyVar *glib.DestroyNotify) {
255
256	var DestroyVarRef uintptr
257	if DestroyVar != nil {
258		DestroyVarPtr := uintptr(unsafe.Pointer(DestroyVar))
259		if cbRefPtr, ok := glib.GetCallback(DestroyVarPtr); ok {
260			DestroyVarRef = cbRefPtr
261		} else {
262			fcb := func(arg0 uintptr) {
263				cbFn := *DestroyVar
264				cbFn(arg0)
265			}
266			DestroyVarRef = purego.NewCallback(fcb)
267			glib.SaveCallbackWithClosure(DestroyVarPtr, DestroyVarRef, DestroyVar)
268		}
269	}
270
271	xMemoryInputStreamAddData(x.GoPointer(), DataVar, LenVar, DestroyVarRef)
272
273}
274
275func (c *MemoryInputStream) GoPointer() uintptr {
276	if c == nil {
277		return 0
278	}
279	return c.Ptr
280}
281
282func (c *MemoryInputStream) SetGoPointer(ptr uintptr) {
283	c.Ptr = ptr
284}
285
286// Checks if @stream is actually pollable. Some classes may implement
287// #GPollableInputStream but have only certain instances of that class
288// be pollable. If this method returns %FALSE, then the behavior of
289// other #GPollableInputStream methods is undefined.
290//
291// For any given stream, the value returned by this method is constant;
292// a stream cannot switch from pollable to non-pollable or vice versa.
293func (x *MemoryInputStream) CanPoll() bool {
294
295	cret := XGPollableInputStreamCanPoll(x.GoPointer())
296	return cret
297}
298
299// Creates a #GSource that triggers when @stream can be read, or
300// @cancellable is triggered or an error occurs. The callback on the
301// source is of the #GPollableSourceFunc type.
302//
303// As with g_pollable_input_stream_is_readable(), it is possible that
304// the stream may not actually be readable even after the source
305// triggers, so you should use g_pollable_input_stream_read_nonblocking()
306// rather than g_input_stream_read() from the callback.
307//
308// The behaviour of this method is undefined if
309// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
310func (x *MemoryInputStream) CreateSource(CancellableVar *Cancellable) *glib.Source {
311
312	cret := XGPollableInputStreamCreateSource(x.GoPointer(), CancellableVar.GoPointer())
313	return cret
314}
315
316// Checks if @stream can be read.
317//
318// Note that some stream types may not be able to implement this 100%
319// reliably, and it is possible that a call to g_input_stream_read()
320// after this returns %TRUE would still block. To guarantee
321// non-blocking behavior, you should always use
322// g_pollable_input_stream_read_nonblocking(), which will return a
323// %G_IO_ERROR_WOULD_BLOCK error rather than blocking.
324//
325// The behaviour of this method is undefined if
326// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
327func (x *MemoryInputStream) IsReadable() bool {
328
329	cret := XGPollableInputStreamIsReadable(x.GoPointer())
330	return cret
331}
332
333// Attempts to read up to @count bytes from @stream into @buffer, as
334// with g_input_stream_read(). If @stream is not currently readable,
335// this will immediately return %G_IO_ERROR_WOULD_BLOCK, and you can
336// use g_pollable_input_stream_create_source() to create a #GSource
337// that will be triggered when @stream is readable.
338//
339// Note that since this method never blocks, you cannot actually
340// use @cancellable to cancel it. However, it will return an error
341// if @cancellable has already been cancelled when you call, which
342// may happen if you call this method after a source triggers due
343// to having been cancelled.
344//
345// The behaviour of this method is undefined if
346// g_pollable_input_stream_can_poll() returns %FALSE for @stream.
347func (x *MemoryInputStream) ReadNonblocking(BufferVar *[]byte, CountVar uint, CancellableVar *Cancellable) (int, error) {
348	var cerr *glib.Error
349
350	cret := XGPollableInputStreamReadNonblocking(x.GoPointer(), BufferVar, CountVar, CancellableVar.GoPointer(), &cerr)
351	if cerr == nil {
352		return cret, nil
353	}
354	return cret, cerr
355
356}
357
358// Tests if the stream supports the #GSeekableIface.
359func (x *MemoryInputStream) CanSeek() bool {
360
361	cret := XGSeekableCanSeek(x.GoPointer())
362	return cret
363}
364
365// Tests if the length of the stream can be adjusted with
366// g_seekable_truncate().
367func (x *MemoryInputStream) CanTruncate() bool {
368
369	cret := XGSeekableCanTruncate(x.GoPointer())
370	return cret
371}
372
373// Seeks in the stream by the given @offset, modified by @type.
374//
375// Attempting to seek past the end of the stream will have different
376// results depending on if the stream is fixed-sized or resizable.  If
377// the stream is resizable then seeking past the end and then writing
378// will result in zeros filling the empty space.  Seeking past the end
379// of a resizable stream and reading will result in EOF.  Seeking past
380// the end of a fixed-sized stream will fail.
381//
382// Any operation that would result in a negative offset will fail.
383//
384// If @cancellable is not %NULL, then the operation can be cancelled by
385// triggering the cancellable object from another thread. If the operation
386// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
387func (x *MemoryInputStream) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) {
388	var cerr *glib.Error
389
390	cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr)
391	if cerr == nil {
392		return cret, nil
393	}
394	return cret, cerr
395
396}
397
398// Tells the current position within the stream.
399func (x *MemoryInputStream) Tell() int64 {
400
401	cret := XGSeekableTell(x.GoPointer())
402	return cret
403}
404
405// Sets the length of the stream to @offset. If the stream was previously
406// larger than @offset, the extra data is discarded. If the stream was
407// previously shorter than @offset, it is extended with NUL ('\0') bytes.
408//
409// If @cancellable is not %NULL, then the operation can be cancelled by
410// triggering the cancellable object from another thread. If the operation
411// was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an
412// operation was partially finished when the operation was cancelled the
413// partial result will be returned, without an error.
414func (x *MemoryInputStream) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) {
415	var cerr *glib.Error
416
417	cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr)
418	if cerr == nil {
419		return cret, nil
420	}
421	return cret, cerr
422
423}
424
425func init() {
426	core.SetPackageName("GIO", "gio-2.0")
427	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
428	var libs []uintptr
429	for _, libPath := range core.GetPaths("GIO") {
430		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
431		if err != nil {
432			panic(err)
433		}
434		libs = append(libs, lib)
435	}
436
437	core.PuregoSafeRegister(&xMemoryInputStreamGLibType, libs, "g_memory_input_stream_get_type")
438
439	core.PuregoSafeRegister(&xNewMemoryInputStream, libs, "g_memory_input_stream_new")
440	core.PuregoSafeRegister(&xNewMemoryInputStreamFromBytes, libs, "g_memory_input_stream_new_from_bytes")
441	core.PuregoSafeRegister(&xNewMemoryInputStreamFromData, libs, "g_memory_input_stream_new_from_data")
442
443	core.PuregoSafeRegister(&xMemoryInputStreamAddBytes, libs, "g_memory_input_stream_add_bytes")
444	core.PuregoSafeRegister(&xMemoryInputStreamAddData, libs, "g_memory_input_stream_add_data")
445
446}

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