// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type BufferedInputStreamClass struct { _ structs.HostLayout ParentClass FilterInputStreamClass xFill uintptr xFillAsync uintptr xFillFinish uintptr xGReserved1 uintptr xGReserved2 uintptr xGReserved3 uintptr xGReserved4 uintptr xGReserved5 uintptr } func (x *BufferedInputStreamClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideFill sets the "fill" callback function. func (x *BufferedInputStreamClass) OverrideFill(cb func(*BufferedInputStream, int, *Cancellable) int) { if cb == nil { x.xFill = 0 } else { x.xFill = purego.NewCallback(func(StreamVarp uintptr, CountVarp int, CancellableVarp uintptr) int { return cb(BufferedInputStreamNewFromInternalPtr(StreamVarp), CountVarp, CancellableNewFromInternalPtr(CancellableVarp)) }) } } // GetFill gets the "fill" callback function. func (x *BufferedInputStreamClass) GetFill() func(*BufferedInputStream, int, *Cancellable) int { if x.xFill == 0 { return nil } var rawCallback func(StreamVarp uintptr, CountVarp int, CancellableVarp uintptr) int purego.RegisterFunc(&rawCallback, x.xFill) return func(StreamVar *BufferedInputStream, CountVar int, CancellableVar *Cancellable) int { return rawCallback(StreamVar.GoPointer(), CountVar, CancellableVar.GoPointer()) } } // OverrideFillAsync sets the "fill_async" callback function. func (x *BufferedInputStreamClass) OverrideFillAsync(cb func(*BufferedInputStream, int, int, *Cancellable, *AsyncReadyCallback, uintptr)) { if cb == nil { x.xFillAsync = 0 } else { x.xFillAsync = purego.NewCallback(func(StreamVarp uintptr, CountVarp int, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) { cb(BufferedInputStreamNewFromInternalPtr(StreamVarp), CountVarp, IoPriorityVarp, CancellableNewFromInternalPtr(CancellableVarp), (*AsyncReadyCallback)(unsafe.Pointer(CallbackVarp)), UserDataVarp) }) } } // GetFillAsync gets the "fill_async" callback function. func (x *BufferedInputStreamClass) GetFillAsync() func(*BufferedInputStream, int, int, *Cancellable, *AsyncReadyCallback, uintptr) { if x.xFillAsync == 0 { return nil } var rawCallback func(StreamVarp uintptr, CountVarp int, IoPriorityVarp int, CancellableVarp uintptr, CallbackVarp uintptr, UserDataVarp uintptr) purego.RegisterFunc(&rawCallback, x.xFillAsync) return func(StreamVar *BufferedInputStream, CountVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { rawCallback(StreamVar.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), glib.NewCallbackNullable(CallbackVar), UserDataVar) } } // OverrideFillFinish sets the "fill_finish" callback function. func (x *BufferedInputStreamClass) OverrideFillFinish(cb func(*BufferedInputStream, AsyncResult) int) { if cb == nil { x.xFillFinish = 0 } else { x.xFillFinish = purego.NewCallback(func(StreamVarp uintptr, ResultVarp uintptr) int { return cb(BufferedInputStreamNewFromInternalPtr(StreamVarp), &AsyncResultBase{Ptr: ResultVarp}) }) } } // GetFillFinish gets the "fill_finish" callback function. func (x *BufferedInputStreamClass) GetFillFinish() func(*BufferedInputStream, AsyncResult) int { if x.xFillFinish == 0 { return nil } var rawCallback func(StreamVarp uintptr, ResultVarp uintptr) int purego.RegisterFunc(&rawCallback, x.xFillFinish) return func(StreamVar *BufferedInputStream, ResultVar AsyncResult) int { return rawCallback(StreamVar.GoPointer(), ResultVar.GoPointer()) } } // OverrideGReserved1 sets the "_g_reserved1" callback function. func (x *BufferedInputStreamClass) OverrideGReserved1(cb func()) { if cb == nil { x.xGReserved1 = 0 } else { x.xGReserved1 = purego.NewCallback(func() { cb() }) } } // GetGReserved1 gets the "_g_reserved1" callback function. func (x *BufferedInputStreamClass) GetGReserved1() func() { if x.xGReserved1 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved1) return func() { rawCallback() } } // OverrideGReserved2 sets the "_g_reserved2" callback function. func (x *BufferedInputStreamClass) OverrideGReserved2(cb func()) { if cb == nil { x.xGReserved2 = 0 } else { x.xGReserved2 = purego.NewCallback(func() { cb() }) } } // GetGReserved2 gets the "_g_reserved2" callback function. func (x *BufferedInputStreamClass) GetGReserved2() func() { if x.xGReserved2 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved2) return func() { rawCallback() } } // OverrideGReserved3 sets the "_g_reserved3" callback function. func (x *BufferedInputStreamClass) OverrideGReserved3(cb func()) { if cb == nil { x.xGReserved3 = 0 } else { x.xGReserved3 = purego.NewCallback(func() { cb() }) } } // GetGReserved3 gets the "_g_reserved3" callback function. func (x *BufferedInputStreamClass) GetGReserved3() func() { if x.xGReserved3 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved3) return func() { rawCallback() } } // OverrideGReserved4 sets the "_g_reserved4" callback function. func (x *BufferedInputStreamClass) OverrideGReserved4(cb func()) { if cb == nil { x.xGReserved4 = 0 } else { x.xGReserved4 = purego.NewCallback(func() { cb() }) } } // GetGReserved4 gets the "_g_reserved4" callback function. func (x *BufferedInputStreamClass) GetGReserved4() func() { if x.xGReserved4 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved4) return func() { rawCallback() } } // OverrideGReserved5 sets the "_g_reserved5" callback function. func (x *BufferedInputStreamClass) OverrideGReserved5(cb func()) { if cb == nil { x.xGReserved5 = 0 } else { x.xGReserved5 = purego.NewCallback(func() { cb() }) } } // GetGReserved5 gets the "_g_reserved5" callback function. func (x *BufferedInputStreamClass) GetGReserved5() func() { if x.xGReserved5 == 0 { return nil } var rawCallback func() purego.RegisterFunc(&rawCallback, x.xGReserved5) return func() { rawCallback() } } type BufferedInputStreamPrivate struct { _ structs.HostLayout } func (x *BufferedInputStreamPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Buffered input stream implements [class@Gio.FilterInputStream] and provides // for buffered reads. // // By default, `GBufferedInputStream`'s buffer size is set at 4 kilobytes. // // To create a buffered input stream, use [ctor@Gio.BufferedInputStream.new], // or [ctor@Gio.BufferedInputStream.new_sized] to specify the buffer's size at // construction. // // To get the size of a buffer within a buffered input stream, use // [method@Gio.BufferedInputStream.get_buffer_size]. To change the size of a // buffered input stream's buffer, use [method@Gio.BufferedInputStream.set_buffer_size]. // Note that the buffer's size cannot be reduced below the size of the data within the buffer. type BufferedInputStream struct { FilterInputStream } var xBufferedInputStreamGLibType func() types.GType func BufferedInputStreamGLibType() types.GType { return xBufferedInputStreamGLibType() } func BufferedInputStreamNewFromInternalPtr(ptr uintptr) *BufferedInputStream { cls := &BufferedInputStream{} cls.Ptr = ptr return cls } var xNewBufferedInputStream func(uintptr) uintptr // Creates a new [class@Gio.InputStream] from the given @base_stream, with // a buffer set to the default size (4 kilobytes). func NewBufferedInputStream(BaseStreamVar *InputStream) *BufferedInputStream { var cls *BufferedInputStream cret := xNewBufferedInputStream(BaseStreamVar.GoPointer()) if cret == 0 { return nil } cls = &BufferedInputStream{} cls.Ptr = cret return cls } var xNewBufferedInputStreamSized func(uintptr, uint) uintptr // Creates a new [class@Gio.BufferedInputStream] from the given @base_stream, // with a buffer set to @size. func NewBufferedInputStreamSized(BaseStreamVar *InputStream, SizeVar uint) *BufferedInputStream { var cls *BufferedInputStream cret := xNewBufferedInputStreamSized(BaseStreamVar.GoPointer(), SizeVar) if cret == 0 { return nil } cls = &BufferedInputStream{} cls.Ptr = cret return cls } var xBufferedInputStreamFill func(uintptr, int, uintptr, **glib.Error) int // Tries to read @count bytes from the stream into the buffer. // Will block during this read. // // If @count is zero, returns zero and does nothing. A value of @count // larger than `G_MAXSSIZE` will cause a // [error@Gio.IOErrorEnum.INVALID_ARGUMENT] error. // // On success, the number of bytes read into the buffer is returned. // It is not an error if this is not the same as the requested size, as it // can happen e.g. near the end of a file. Zero is returned on end of file // (or if @count is zero), but never otherwise. // // If @count is -1 then the attempted read size is equal to the number of // bytes that are required to fill the buffer. // // If @cancellable is not `NULL`, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error [error@Gio.IOErrorEnum.CANCELLED] will be returned. // If an operation was partially finished when the operation was cancelled the // partial result will be returned, without an error. // // On error `-1` is returned and @error is set accordingly. // // For the asynchronous, non-blocking, version of this function, see // [method@Gio.BufferedInputStream.fill_async]. func (x *BufferedInputStream) Fill(CountVar int, CancellableVar *Cancellable) (int, error) { var cerr *glib.Error cret := xBufferedInputStreamFill(x.GoPointer(), CountVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xBufferedInputStreamFillAsync func(uintptr, int, int, uintptr, uintptr, uintptr) // Reads data into @stream's buffer asynchronously, up to @count size. // @io_priority can be used to prioritize reads. For the synchronous // version of this function, see [method@Gio.BufferedInputStream.fill]. // // If @count is `-1` then the attempted read size is equal to the number // of bytes that are required to fill the buffer. func (x *BufferedInputStream) FillAsync(CountVar int, IoPriorityVar int, CancellableVar *Cancellable, CallbackVar *AsyncReadyCallback, UserDataVar uintptr) { var CallbackVarRef uintptr if CallbackVar != nil { CallbackVarPtr := uintptr(unsafe.Pointer(CallbackVar)) if cbRefPtr, ok := glib.GetCallback(CallbackVarPtr); ok { CallbackVarRef = cbRefPtr } else { fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) { cbFn := *CallbackVar cbFn(arg0, arg1, arg2) } CallbackVarRef = purego.NewCallback(fcb) glib.SaveCallbackWithClosure(CallbackVarPtr, CallbackVarRef, CallbackVar) } } xBufferedInputStreamFillAsync(x.GoPointer(), CountVar, IoPriorityVar, CancellableVar.GoPointer(), CallbackVarRef, UserDataVar) } var xBufferedInputStreamFillFinish func(uintptr, uintptr, **glib.Error) int // Finishes an asynchronous read. func (x *BufferedInputStream) FillFinish(ResultVar AsyncResult) (int, error) { var cerr *glib.Error cret := xBufferedInputStreamFillFinish(x.GoPointer(), ResultVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xBufferedInputStreamGetAvailable func(uintptr) uint // Gets the size of the available data within the stream. func (x *BufferedInputStream) GetAvailable() uint { cret := xBufferedInputStreamGetAvailable(x.GoPointer()) return cret } var xBufferedInputStreamGetBufferSize func(uintptr) uint // Gets the size of the input buffer. func (x *BufferedInputStream) GetBufferSize() uint { cret := xBufferedInputStreamGetBufferSize(x.GoPointer()) return cret } var xBufferedInputStreamPeek func(uintptr, []byte, uint, uint) uint // Peeks in the buffer, copying data of size @count into @buffer, // offset @offset bytes. func (x *BufferedInputStream) Peek(BufferVar []byte, OffsetVar uint, CountVar uint) uint { cret := xBufferedInputStreamPeek(x.GoPointer(), BufferVar, OffsetVar, CountVar) return cret } var xBufferedInputStreamPeekBuffer func(uintptr, *uint) uintptr // Returns the buffer with the currently available bytes. The returned // buffer must not be modified and will become invalid when reading from // the stream or filling the buffer. func (x *BufferedInputStream) PeekBuffer(CountVar *uint) uintptr { cret := xBufferedInputStreamPeekBuffer(x.GoPointer(), CountVar) return cret } var xBufferedInputStreamReadByte func(uintptr, uintptr, **glib.Error) int // Tries to read a single byte from the stream or the buffer. Will block // during this read. // // On success, the byte read from the stream is returned. On end of stream // `-1` is returned but it's not an exceptional error and @error is not set. // // If @cancellable is not `NULL`, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error [error@Gio.IOErrorEnum.CANCELLED] will be returned. // If an operation was partially finished when the operation was cancelled the // partial result will be returned, without an error. // // On error `-1` is returned and @error is set accordingly. func (x *BufferedInputStream) ReadByte(CancellableVar *Cancellable) (int, error) { var cerr *glib.Error cret := xBufferedInputStreamReadByte(x.GoPointer(), CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } var xBufferedInputStreamSetBufferSize func(uintptr, uint) // Sets the size of the internal buffer of @stream to @size, or to the // size of the contents of the buffer. The buffer can never be resized // smaller than its current contents. func (x *BufferedInputStream) SetBufferSize(SizeVar uint) { xBufferedInputStreamSetBufferSize(x.GoPointer(), SizeVar) } func (c *BufferedInputStream) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *BufferedInputStream) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyBufferSize sets the "buffer-size" property. // The size of the backend buffer, in bytes. func (x *BufferedInputStream) SetPropertyBufferSize(value uint) { var v gobject.Value v.Init(gobject.TypeUintVal) v.SetUint(value) x.SetProperty("buffer-size", &v) } // GetPropertyBufferSize gets the "buffer-size" property. // The size of the backend buffer, in bytes. func (x *BufferedInputStream) GetPropertyBufferSize() uint { var v gobject.Value x.GetProperty("buffer-size", &v) return v.GetUint() } // Tests if the stream supports the #GSeekableIface. func (x *BufferedInputStream) CanSeek() bool { cret := XGSeekableCanSeek(x.GoPointer()) return cret } // Tests if the length of the stream can be adjusted with // g_seekable_truncate(). func (x *BufferedInputStream) CanTruncate() bool { cret := XGSeekableCanTruncate(x.GoPointer()) return cret } // Seeks in the stream by the given @offset, modified by @type. // // Attempting to seek past the end of the stream will have different // results depending on if the stream is fixed-sized or resizable. If // the stream is resizable then seeking past the end and then writing // will result in zeros filling the empty space. Seeking past the end // of a resizable stream and reading will result in EOF. Seeking past // the end of a fixed-sized stream will fail. // // Any operation that would result in a negative offset will fail. // // If @cancellable is not %NULL, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. func (x *BufferedInputStream) Seek(OffsetVar int64, TypeVar glib.SeekType, CancellableVar *Cancellable) (bool, error) { var cerr *glib.Error cret := XGSeekableSeek(x.GoPointer(), OffsetVar, TypeVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } // Tells the current position within the stream. func (x *BufferedInputStream) Tell() int64 { cret := XGSeekableTell(x.GoPointer()) return cret } // Sets the length of the stream to @offset. If the stream was previously // larger than @offset, the extra data is discarded. If the stream was // previously shorter than @offset, it is extended with NUL ('\0') bytes. // // If @cancellable is not %NULL, then the operation can be cancelled by // triggering the cancellable object from another thread. If the operation // was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. If an // operation was partially finished when the operation was cancelled the // partial result will be returned, without an error. func (x *BufferedInputStream) Truncate(OffsetVar int64, CancellableVar *Cancellable) (bool, error) { var cerr *glib.Error cret := XGSeekableTruncate(x.GoPointer(), OffsetVar, CancellableVar.GoPointer(), &cerr) if cerr == nil { return cret, nil } return cret, cerr } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xBufferedInputStreamGLibType, libs, "g_buffered_input_stream_get_type") core.PuregoSafeRegister(&xNewBufferedInputStream, libs, "g_buffered_input_stream_new") core.PuregoSafeRegister(&xNewBufferedInputStreamSized, libs, "g_buffered_input_stream_new_sized") core.PuregoSafeRegister(&xBufferedInputStreamFill, libs, "g_buffered_input_stream_fill") core.PuregoSafeRegister(&xBufferedInputStreamFillAsync, libs, "g_buffered_input_stream_fill_async") core.PuregoSafeRegister(&xBufferedInputStreamFillFinish, libs, "g_buffered_input_stream_fill_finish") core.PuregoSafeRegister(&xBufferedInputStreamGetAvailable, libs, "g_buffered_input_stream_get_available") core.PuregoSafeRegister(&xBufferedInputStreamGetBufferSize, libs, "g_buffered_input_stream_get_buffer_size") core.PuregoSafeRegister(&xBufferedInputStreamPeek, libs, "g_buffered_input_stream_peek") core.PuregoSafeRegister(&xBufferedInputStreamPeekBuffer, libs, "g_buffered_input_stream_peek_buffer") core.PuregoSafeRegister(&xBufferedInputStreamReadByte, libs, "g_buffered_input_stream_read_byte") core.PuregoSafeRegister(&xBufferedInputStreamSetBufferSize, libs, "g_buffered_input_stream_set_buffer_size") }