v0.2.1 c0399be

gconverter.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// Provides an interface for converting data from one type
16// to another type. The conversion can be stateful
17// and may fail at any place.
18type ConverterIface struct {
19	_ structs.HostLayout
20
21	GIface uintptr
22
23	xConvert uintptr
24
25	xReset uintptr
26}
27
28func (x *ConverterIface) GoPointer() uintptr {
29	return uintptr(unsafe.Pointer(x))
30}
31
32// OverrideConvert sets the "convert" callback function.
33// Converts data.
34func (x *ConverterIface) OverrideConvert(cb func(Converter, []byte, uint, []byte, uint, ConverterFlags, *uint, *uint) ConverterResult) {
35	if cb == nil {
36		x.xConvert = 0
37	} else {
38		x.xConvert = purego.NewCallback(func(ConverterVarp uintptr, InbufVarp []byte, InbufSizeVarp uint, OutbufVarp []byte, OutbufSizeVarp uint, FlagsVarp ConverterFlags, BytesReadVarp *uint, BytesWrittenVarp *uint) ConverterResult {
39			return cb(&ConverterBase{Ptr: ConverterVarp}, InbufVarp, InbufSizeVarp, OutbufVarp, OutbufSizeVarp, FlagsVarp, BytesReadVarp, BytesWrittenVarp)
40		})
41	}
42}
43
44// GetConvert gets the "convert" callback function.
45// Converts data.
46func (x *ConverterIface) GetConvert() func(Converter, []byte, uint, []byte, uint, ConverterFlags, *uint, *uint) ConverterResult {
47	if x.xConvert == 0 {
48		return nil
49	}
50	var rawCallback func(ConverterVarp uintptr, InbufVarp []byte, InbufSizeVarp uint, OutbufVarp []byte, OutbufSizeVarp uint, FlagsVarp ConverterFlags, BytesReadVarp *uint, BytesWrittenVarp *uint) ConverterResult
51	purego.RegisterFunc(&rawCallback, x.xConvert)
52	return func(ConverterVar Converter, InbufVar []byte, InbufSizeVar uint, OutbufVar []byte, OutbufSizeVar uint, FlagsVar ConverterFlags, BytesReadVar *uint, BytesWrittenVar *uint) ConverterResult {
53		return rawCallback(ConverterVar.GoPointer(), InbufVar, InbufSizeVar, OutbufVar, OutbufSizeVar, FlagsVar, BytesReadVar, BytesWrittenVar)
54	}
55}
56
57// OverrideReset sets the "reset" callback function.
58// Reverts the internal state of the converter to its initial state.
59func (x *ConverterIface) OverrideReset(cb func(Converter)) {
60	if cb == nil {
61		x.xReset = 0
62	} else {
63		x.xReset = purego.NewCallback(func(ConverterVarp uintptr) {
64			cb(&ConverterBase{Ptr: ConverterVarp})
65		})
66	}
67}
68
69// GetReset gets the "reset" callback function.
70// Reverts the internal state of the converter to its initial state.
71func (x *ConverterIface) GetReset() func(Converter) {
72	if x.xReset == 0 {
73		return nil
74	}
75	var rawCallback func(ConverterVarp uintptr)
76	purego.RegisterFunc(&rawCallback, x.xReset)
77	return func(ConverterVar Converter) {
78		rawCallback(ConverterVar.GoPointer())
79	}
80}
81
82// `GConverter` is an interface for streaming conversions.
83//
84// `GConverter` is implemented by objects that convert
85// binary data in various ways. The conversion can be
86// stateful and may fail at any place.
87//
88// Some example conversions are: character set conversion,
89// compression, decompression and regular expression
90// replace.
91type Converter interface {
92	GoPointer() uintptr
93	SetGoPointer(uintptr)
94	Convert(InbufVar []byte, InbufSizeVar uint, OutbufVar []byte, OutbufSizeVar uint, FlagsVar ConverterFlags, BytesReadVar *uint, BytesWrittenVar *uint) (ConverterResult, error)
95	ConvertBytes(BytesVar *glib.Bytes) (*glib.Bytes, error)
96	Reset()
97}
98
99var xConverterGLibType func() types.GType
100
101func ConverterGLibType() types.GType {
102	return xConverterGLibType()
103}
104
105type ConverterBase struct {
106	Ptr uintptr
107}
108
109func (x *ConverterBase) GoPointer() uintptr {
110	if x == nil {
111		return 0
112	}
113	return x.Ptr
114}
115
116func (x *ConverterBase) SetGoPointer(ptr uintptr) {
117	x.Ptr = ptr
118}
119
120// This is the main operation used when converting data. It is to be called
121// multiple times in a loop, and each time it will do some work, i.e.
122// producing some output (in @outbuf) or consuming some input (from @inbuf) or
123// both. If its not possible to do any work an error is returned.
124//
125// Note that a single call may not consume all input (or any input at all).
126// Also a call may produce output even if given no input, due to state stored
127// in the converter producing output.
128//
129// If any data was either produced or consumed, and then an error happens, then
130// only the successful conversion is reported and the error is returned on the
131// next call.
132//
133// A full conversion loop involves calling this method repeatedly, each time
134// giving it new input and space output space. When there is no more input
135// data after the data in @inbuf, the flag %G_CONVERTER_INPUT_AT_END must be set.
136// The loop will be (unless some error happens) returning %G_CONVERTER_CONVERTED
137// each time until all data is consumed and all output is produced, then
138// %G_CONVERTER_FINISHED is returned instead. Note, that %G_CONVERTER_FINISHED
139// may be returned even if %G_CONVERTER_INPUT_AT_END is not set, for instance
140// in a decompression converter where the end of data is detectable from the
141// data (and there might even be other data after the end of the compressed data).
142//
143// When some data has successfully been converted @bytes_read and is set to
144// the number of bytes read from @inbuf, and @bytes_written is set to indicate
145// how many bytes was written to @outbuf. If there are more data to output
146// or consume (i.e. unless the %G_CONVERTER_INPUT_AT_END is specified) then
147// %G_CONVERTER_CONVERTED is returned, and if no more data is to be output
148// then %G_CONVERTER_FINISHED is returned.
149//
150// On error %G_CONVERTER_ERROR is returned and @error is set accordingly.
151// Some errors need special handling:
152//
153// %G_IO_ERROR_NO_SPACE is returned if there is not enough space
154// to write the resulting converted data, the application should
155// call the function again with a larger @outbuf to continue.
156//
157// %G_IO_ERROR_PARTIAL_INPUT is returned if there is not enough
158// input to fully determine what the conversion should produce,
159// and the %G_CONVERTER_INPUT_AT_END flag is not set. This happens for
160// example with an incomplete multibyte sequence when converting text,
161// or when a regexp matches up to the end of the input (and may match
162// further input). It may also happen when @inbuf_size is zero and
163// there is no more data to produce.
164//
165// When this happens the application should read more input and then
166// call the function again. If further input shows that there is no
167// more data call the function again with the same data but with
168// the %G_CONVERTER_INPUT_AT_END flag set. This may cause the conversion
169// to finish as e.g. in the regexp match case (or, to fail again with
170// %G_IO_ERROR_PARTIAL_INPUT in e.g. a charset conversion where the
171// input is actually partial).
172//
173// After g_converter_convert() has returned %G_CONVERTER_FINISHED the
174// converter object is in an invalid state where its not allowed
175// to call g_converter_convert() anymore. At this time you can only
176// free the object or call g_converter_reset() to reset it to the
177// initial state.
178//
179// If the flag %G_CONVERTER_FLUSH is set then conversion is modified
180// to try to write out all internal state to the output. The application
181// has to call the function multiple times with the flag set, and when
182// the available input has been consumed and all internal state has
183// been produced then %G_CONVERTER_FLUSHED (or %G_CONVERTER_FINISHED if
184// really at the end) is returned instead of %G_CONVERTER_CONVERTED.
185// This is somewhat similar to what happens at the end of the input stream,
186// but done in the middle of the data.
187//
188// This has different meanings for different conversions. For instance
189// in a compression converter it would mean that we flush all the
190// compression state into output such that if you uncompress the
191// compressed data you get back all the input data. Doing this may
192// make the final file larger due to padding though. Another example
193// is a regexp conversion, where if you at the end of the flushed data
194// have a match, but there is also a potential longer match. In the
195// non-flushed case we would ask for more input, but when flushing we
196// treat this as the end of input and do the match.
197//
198// Flushing is not always possible (like if a charset converter flushes
199// at a partial multibyte sequence). Converters are supposed to try
200// to produce as much output as possible and then return an error
201// (typically %G_IO_ERROR_PARTIAL_INPUT).
202func (x *ConverterBase) Convert(InbufVar []byte, InbufSizeVar uint, OutbufVar []byte, OutbufSizeVar uint, FlagsVar ConverterFlags, BytesReadVar *uint, BytesWrittenVar *uint) (ConverterResult, error) {
203	var cerr *glib.Error
204
205	cret := XGConverterConvert(x.GoPointer(), InbufVar, InbufSizeVar, OutbufVar, OutbufSizeVar, FlagsVar, BytesReadVar, BytesWrittenVar, &cerr)
206	if cerr == nil {
207		return cret, nil
208	}
209	return cret, cerr
210
211}
212
213// Applies @converter to the data in @bytes.
214func (x *ConverterBase) ConvertBytes(BytesVar *glib.Bytes) (*glib.Bytes, error) {
215	var cerr *glib.Error
216
217	cret := XGConverterConvertBytes(x.GoPointer(), BytesVar, &cerr)
218	if cerr == nil {
219		return cret, nil
220	}
221	return cret, cerr
222
223}
224
225// Resets all internal state in the converter, making it behave
226// as if it was just created. If the converter has any internal
227// state that would produce output then that output is lost.
228func (x *ConverterBase) Reset() {
229
230	XGConverterReset(x.GoPointer())
231
232}
233
234var XGConverterConvert func(uintptr, []byte, uint, []byte, uint, ConverterFlags, *uint, *uint, **glib.Error) ConverterResult
235var XGConverterConvertBytes func(uintptr, *glib.Bytes, **glib.Error) *glib.Bytes
236var XGConverterReset func(uintptr)
237
238func init() {
239	core.SetPackageName("GIO", "gio-2.0")
240	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
241	var libs []uintptr
242	for _, libPath := range core.GetPaths("GIO") {
243		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
244		if err != nil {
245			panic(err)
246		}
247		libs = append(libs, lib)
248	}
249
250	core.PuregoSafeRegister(&xConverterGLibType, libs, "g_converter_get_type")
251
252	core.PuregoSafeRegister(&XGConverterConvert, libs, "g_converter_convert")
253	core.PuregoSafeRegister(&XGConverterConvertBytes, libs, "g_converter_convert_bytes")
254	core.PuregoSafeRegister(&XGConverterReset, libs, "g_converter_reset")
255
256}

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