// Code generated by cmd/cgo; DO NOT EDIT. //line /home/josie/.cache/paru/clone/wiiudownloader/src/pkg/mod/github.com/gotk3/gotk3@v0.6.5-0.20240618185848-ff349ae13f56/glib/giostream.go:1:1 package glib // #cgo pkg-config: gio-2.0 glib-2.0 gobject-2.0 // #include // #include // #include "giostream.go.h" import _ "unsafe" import ( "bytes" "errors" "unsafe" ) func init() { tm := []TypeMarshaler{ {Type(( /*line :17:9*/_Cfunc_g_io_stream_get_type /*line :17:30*/)()), marshalIOStream}, {Type(( /*line :18:9*/_Cfunc_g_output_stream_get_type /*line :18:34*/)()), marshalOutputStream}, {Type(( /*line :19:9*/_Cfunc_g_input_stream_get_type /*line :19:33*/)()), marshalInputStream}, } RegisterGValueMarshalers(tm) } // OutputStreamSpliceFlags is a representation of GTK's GOutputStreamSpliceFlags. type OutputStreamSpliceFlags int const ( OUTPUT_STREAM_SPLICE_NONE OutputStreamSpliceFlags = ( /*line :29:62*/_Ciconst_G_OUTPUT_STREAM_SPLICE_NONE /*line :29:90*/) OUTPUT_STREAM_SPLICE_CLOSE_SOURCE = ( /*line :30:62*/_Ciconst_G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE /*line :30:98*/) OUTPUT_STREAM_SPLICE_CLOSE_TARGET = ( /*line :31:62*/_Ciconst_G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET /*line :31:98*/) ) /* * GIOStream */ // IOStream is a representation of GIO's GIOStream. // Base class for implementing read/write streams type IOStream struct { *Object } // native returns a pointer to the underlying GIOStream. func (v *IOStream) native() * /*line :45:30*/_Ctype_GIOStream /*line :45:41*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GIOStream{ _cgo0 := /*line :50:23*/p; _cgoCheckPointer(_cgo0, nil); return /*line :50:25*/_Cfunc_toGIOStream(_cgo0); }() } // NativePrivate: to be used inside Gotk3 only. func (v *IOStream) NativePrivate() * /*line :54:37*/_Ctype_GIOStream /*line :54:48*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GIOStream{ _cgo0 := /*line :59:23*/p; _cgoCheckPointer(_cgo0, nil); return /*line :59:25*/_Cfunc_toGIOStream(_cgo0); }() } // Native returns a pointer to the underlying GIOStream. func (v *IOStream) Native() uintptr { return uintptr(unsafe.Pointer(v.native())) } func marshalIOStream(p uintptr) (interface{}, error) { c := ( /*line :68:7*/_Cfunc_g_value_get_object /*line :68:26*/)((* /*line :68:30*/_Ctype_GValue /*line :68:38*/)(unsafe.Pointer(p))) obj := Take(unsafe.Pointer(c)) return wrapIOStream(obj), nil } func wrapIOStream(obj *Object) *IOStream { return &IOStream{obj} } /* GInputStream * g_io_stream_get_input_stream () GOutputStream * g_io_stream_get_output_stream () void g_io_stream_splice_async () gboolean g_io_stream_splice_finish () */ // Close is a wrapper around g_io_stream_close(). func (v *IOStream) Close(cancellable *Cancellable) (bool, error) { var gerr * /*line :86:12*/_Ctype_GError /*line :86:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :88:3*/v.native(); _cgo1 := /*line :89:3*/cancellable.native(); _cgoBase2 := /*line :90:3*/&gerr; _cgo2 := _cgoBase2; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :90:9*/_Cfunc_g_io_stream_close(_cgo0, _cgo1, _cgo2); }()) if !ok { defer func() func() { _cgo0 := /*line :92:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :92:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } /* void g_io_stream_close_async () gboolean g_io_stream_close_finish () gboolean g_io_stream_is_closed () gboolean g_io_stream_has_pending () gboolean g_io_stream_set_pending () void g_io_stream_clear_pending () */ /* * GInputStream */ // InputStream is a representation of GIO's GInputStream. // Base class for implementing streaming input type InputStream struct { *Object } // native returns a pointer to the underlying GInputStream. func (v *InputStream) native() * /*line :118:33*/_Ctype_GInputStream /*line :118:47*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GInputStream{ _cgo0 := /*line :123:26*/p; _cgoCheckPointer(_cgo0, nil); return /*line :123:28*/_Cfunc_toGInputStream(_cgo0); }() } // NativePrivate: to be used inside Gotk3 only. func (v *InputStream) NativePrivate() * /*line :127:40*/_Ctype_GInputStream /*line :127:54*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GInputStream{ _cgo0 := /*line :132:26*/p; _cgoCheckPointer(_cgo0, nil); return /*line :132:28*/_Cfunc_toGInputStream(_cgo0); }() } // Native returns a pointer to the underlying GInputStream. func (v *InputStream) Native() uintptr { return uintptr(unsafe.Pointer(v.native())) } func marshalInputStream(p uintptr) (interface{}, error) { c := ( /*line :141:7*/_Cfunc_g_value_get_object /*line :141:26*/)((* /*line :141:30*/_Ctype_GValue /*line :141:38*/)(unsafe.Pointer(p))) obj := Take(unsafe.Pointer(c)) return wrapInputStream(obj), nil } func wrapInputStream(obj *Object) *InputStream { return &InputStream{obj} } // Read is a wrapper around g_input_stream_read(). func (v *InputStream) Read(length uint, cancellable *Cancellable) (*bytes.Buffer, int, error) { var gerr * /*line :152:12*/_Ctype_GError /*line :152:20*/ var buffer = bytes.NewBuffer(make([]byte, length)) c := func() _Ctype_gssize{ _cgo0 := /*line :156:3*/v.native(); _cgoIndex1 := /*line :157:19*/buffer.Bytes(); _cgo1 := /*line :157:3*/unsafe.Pointer(&_cgoIndex1[0]); var _cgo2 _Ctype_gsize = _Ctype_gsize /*line :158:10*/(length); _cgo3 := /*line :159:3*/cancellable.native(); _cgoBase4 := /*line :160:3*/&gerr; _cgo4 := _cgoBase4; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, _cgoIndex1); _cgoCheckPointer(_cgo3, nil); _cgoCheckPointer(_cgoBase4, 0 == 0); return /*line :160:9*/_Cfunc_g_input_stream_read(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4); }() if c == -1 { defer func() func() { _cgo0 := /*line :162:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :162:29*/_Cfunc_g_error_free(_cgo0); }}()() return nil, -1, errors.New(goString(gerr.message)) } return buffer, int(c), nil } // TODO find a way to get size to be read without asking for ... /* gboolean g_input_stream_read_all (GInputStream *stream, void *buffer, gsize count, gsize *bytes_read, GCancellable *cancellable, GError **error); */ /* void g_input_stream_read_all_async () gboolean g_input_stream_read_all_finish () gssize g_input_stream_skip () */ // Close is a wrapper around g_input_stream_close(). func (v *InputStream) Close(cancellable *Cancellable) (bool, error) { var gerr * /*line :187:12*/_Ctype_GError /*line :187:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :189:3*/v.native(); _cgo1 := /*line :190:3*/cancellable.native(); _cgoBase2 := /*line :191:3*/&gerr; _cgo2 := _cgoBase2; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :191:9*/_Cfunc_g_input_stream_close(_cgo0, _cgo1, _cgo2); }()) if !ok { defer func() func() { _cgo0 := /*line :193:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :193:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } // TODO g_input_stream*** /* void g_input_stream_read_async () gssize g_input_stream_read_finish () void g_input_stream_skip_async () gssize g_input_stream_skip_finish () void g_input_stream_close_async () gboolean g_input_stream_close_finish () */ // IsClosed is a wrapper around g_input_stream_is_closed(). func (v *InputStream) IsClosed() bool { return gobool(func() _Ctype_gboolean{ _cgo0 := /*line :211:43*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :211:54*/_Cfunc_g_input_stream_is_closed(_cgo0); }()) } // HasPending is a wrapper around g_input_stream_has_pending(). func (v *InputStream) HasPending() bool { return gobool(func() _Ctype_gboolean{ _cgo0 := /*line :216:45*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :216:56*/_Cfunc_g_input_stream_has_pending(_cgo0); }()) } // SetPending is a wrapper around g_input_stream_set_pending(). func (v *InputStream) SetPending() (bool, error) { var gerr * /*line :221:12*/_Ctype_GError /*line :221:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :223:3*/v.native(); _cgoBase1 := /*line :224:3*/&gerr; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :224:9*/_Cfunc_g_input_stream_set_pending(_cgo0, _cgo1); }()) if !ok { defer func() func() { _cgo0 := /*line :226:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :226:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } // ClearPending is a wrapper around g_input_stream_clear_pending(). func (v *InputStream) ClearPending() { func() { _cgo0 := /*line :234:33*/v.native(); _cgoCheckPointer(_cgo0, nil); /*line :234:44*/_Cfunc_g_input_stream_clear_pending(_cgo0); }() } /* Useless functions due to Go language specification and actual implementation of (*InputStream).Read that do same thing. GBytes * g_input_stream_read_bytes () void g_input_stream_read_bytes_async () GBytes * g_input_stream_read_bytes_finish () */ /* * GOutputStream */ // OutputStream is a representation of GIO's GOutputStream. // Base class for implementing streaming output type OutputStream struct { *Object } // native returns a pointer to the underlying GOutputStream. func (v *OutputStream) native() * /*line :256:34*/_Ctype_GOutputStream /*line :256:49*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GOutputStream{ _cgo0 := /*line :261:27*/p; _cgoCheckPointer(_cgo0, nil); return /*line :261:29*/_Cfunc_toGOutputStream(_cgo0); }() } // NativePrivate: to be used inside Gotk3 only. func (v *OutputStream) NativePrivate() * /*line :265:41*/_Ctype_GOutputStream /*line :265:56*/ { if v == nil || v.GObject == nil { return nil } p := unsafe.Pointer(v.GObject) return func() *_Ctype_struct__GOutputStream{ _cgo0 := /*line :270:27*/p; _cgoCheckPointer(_cgo0, nil); return /*line :270:29*/_Cfunc_toGOutputStream(_cgo0); }() } // Native returns a pointer to the underlying GOutputStream. func (v *OutputStream) Native() uintptr { return uintptr(unsafe.Pointer(v.native())) } func marshalOutputStream(p uintptr) (interface{}, error) { c := ( /*line :279:7*/_Cfunc_g_value_get_object /*line :279:26*/)((* /*line :279:30*/_Ctype_GValue /*line :279:38*/)(unsafe.Pointer(p))) obj := Take(unsafe.Pointer(c)) return wrapOutputStream(obj), nil } func wrapOutputStream(obj *Object) *OutputStream { return &OutputStream{obj} } /* gssize g_output_stream_write (GOutputStream *stream, const void *buffer, gsize count, GCancellable *cancellable, GError **error); */ // Write is a wrapper around g_output_stream_write(). // buffer := bytes.NewBuffer(make([]byte, length)) func (v *OutputStream) Write(buffer *bytes.Buffer, cancellable *Cancellable) (int, error) { var gerr * /*line :300:12*/_Ctype_GError /*line :300:20*/ length := buffer.Len() c := func() _Ctype_gssize{ _cgo0 := /*line :304:3*/v.native(); _cgoIndex1 := /*line :305:19*/buffer.Bytes(); _cgo1 := /*line :305:3*/unsafe.Pointer(&_cgoIndex1[0]); var _cgo2 _Ctype_gsize = _Ctype_gsize /*line :306:10*/(length); _cgo3 := /*line :307:3*/cancellable.native(); _cgoBase4 := /*line :308:3*/&gerr; _cgo4 := _cgoBase4; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, _cgoIndex1); _cgoCheckPointer(_cgo3, nil); _cgoCheckPointer(_cgoBase4, 0 == 0); return /*line :308:9*/_Cfunc_g_output_stream_write(_cgo0, _cgo1, _cgo2, _cgo3, _cgo4); }() if c == -1 { defer func() func() { _cgo0 := /*line :310:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :310:29*/_Cfunc_g_error_free(_cgo0); }}()() return -1, errors.New(goString(gerr.message)) } return int(c), nil } // Write is a wrapper around g_output_stream_write(). // func (v *OutputStream) Write(buffer *[]byte, cancellable *Cancellable) (int, error) { // // cdata := C.CString(data) // // defer C.free(unsafe.Pointer(cdata)) // var gerr *C.GError // c := C.g_output_stream_write( // v.native(), // unsafe.Pointer(buffer), // C.gsize(len(*buffer)), // cancellable.native(), // &gerr) // if c == -1 { // defer C.g_error_free(gerr) // return 0, errors.New(goString(gerr.message)) // } // return int(c), nil // } /* gboolean g_output_stream_write_all () */ // TODO outputStream asynch functions /* void g_output_stream_write_all_async () gboolean g_output_stream_write_all_finish () gboolean g_output_stream_writev () gboolean g_output_stream_writev_all () void g_output_stream_writev_async () gboolean g_output_stream_writev_finish () void g_output_stream_writev_all_async () gboolean g_output_stream_writev_all_finish () */ /* gssize g_output_stream_splice (GOutputStream *stream, GInputStream *source, GOutputStreamSpliceFlags flags, GCancellable *cancellable, GError **error); */ // Flush is a wrapper around g_output_stream_flush(). func (v *OutputStream) Flush(cancellable *Cancellable) (bool, error) { var gerr * /*line :360:12*/_Ctype_GError /*line :360:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :362:3*/v.native(); _cgo1 := /*line :363:3*/cancellable.native(); _cgoBase2 := /*line :364:3*/&gerr; _cgo2 := _cgoBase2; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :364:9*/_Cfunc_g_output_stream_flush(_cgo0, _cgo1, _cgo2); }()) if !ok { defer func() func() { _cgo0 := /*line :366:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :366:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } // Close is a wrapper around g_output_stream_close(). func (v *OutputStream) Close(cancellable *Cancellable) (bool, error) { var gerr * /*line :374:12*/_Ctype_GError /*line :374:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :376:3*/v.native(); _cgo1 := /*line :377:3*/cancellable.native(); _cgoBase2 := /*line :378:3*/&gerr; _cgo2 := _cgoBase2; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); _cgoCheckPointer(_cgoBase2, 0 == 0); return /*line :378:9*/_Cfunc_g_output_stream_close(_cgo0, _cgo1, _cgo2); }()) if !ok { defer func() func() { _cgo0 := /*line :380:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :380:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } // TODO outputStream asynch functions /* void g_output_stream_write_async () gssize g_output_stream_write_finish () void g_output_stream_splice_async () gssize g_output_stream_splice_finish () void g_output_stream_flush_async () gboolean g_output_stream_flush_finish () void g_output_stream_close_async () gboolean g_output_stream_close_finish () */ // IsClosing is a wrapper around g_output_stream_is_closing(). func (v *OutputStream) IsClosing() bool { return gobool(func() _Ctype_gboolean{ _cgo0 := /*line :400:45*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :400:56*/_Cfunc_g_output_stream_is_closing(_cgo0); }()) } // IsClosed is a wrapper around g_output_stream_is_closed(). func (v *OutputStream) IsClosed() bool { return gobool(func() _Ctype_gboolean{ _cgo0 := /*line :405:44*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :405:55*/_Cfunc_g_output_stream_is_closed(_cgo0); }()) } // HasPending is a wrapper around g_output_stream_has_pending(). func (v *OutputStream) HasPending() bool { return gobool(func() _Ctype_gboolean{ _cgo0 := /*line :410:46*/v.native(); _cgoCheckPointer(_cgo0, nil); return /*line :410:57*/_Cfunc_g_output_stream_has_pending(_cgo0); }()) } // SetPending is a wrapper around g_output_stream_set_pending(). func (v *OutputStream) SetPending() (bool, error) { var gerr * /*line :415:12*/_Ctype_GError /*line :415:20*/ ok := gobool(func() _Ctype_gboolean{ _cgo0 := /*line :417:3*/v.native(); _cgoBase1 := /*line :418:3*/&gerr; _cgo1 := _cgoBase1; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgoBase1, 0 == 0); return /*line :418:9*/_Cfunc_g_output_stream_set_pending(_cgo0, _cgo1); }()) if !ok { defer func() func() { _cgo0 := /*line :420:24*/gerr; return func() { _cgoCheckPointer(_cgo0, nil); /*line :420:29*/_Cfunc_g_error_free(_cgo0); }}()() return false, errors.New(goString(gerr.message)) } return ok, nil } // ClearPending is a wrapper around g_output_stream_clear_pending(). func (v *OutputStream) ClearPending() { func() { _cgo0 := /*line :428:34*/v.native(); _cgoCheckPointer(_cgo0, nil); /*line :428:45*/_Cfunc_g_output_stream_clear_pending(_cgo0); }() } /* gssize g_output_stream_write_bytes () void g_output_stream_write_bytes_async () gssize g_output_stream_write_bytes_finish () gboolean g_output_stream_printf () gboolean g_output_stream_vprintf () */