1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11)
12
13// A #GSequenceIterCompareFunc is a function used to compare iterators.
14// It must return zero if the iterators compare equal, a negative value
15// if @a comes before @b, and a positive value if @b comes before @a.
16type SequenceIterCompareFunc func(*SequenceIter, *SequenceIter, uintptr) int
17
18// The #GSequence struct is an opaque data type representing a
19// [sequence](data-structures.html#scalable-lists) data type.
20type Sequence struct {
21 _ structs.HostLayout
22}
23
24func (x *Sequence) GoPointer() uintptr {
25 return uintptr(unsafe.Pointer(x))
26}
27
28var xSequenceAppend func(uintptr, uintptr) *SequenceIter
29
30// Adds a new item to the end of @seq.
31func (x *Sequence) Append(DataVar uintptr) *SequenceIter {
32
33 cret := xSequenceAppend(x.GoPointer(), DataVar)
34 return cret
35}
36
37var xSequenceForeach func(uintptr, uintptr, uintptr)
38
39// Calls @func for each item in the sequence passing @user_data
40// to the function. @func must not modify the sequence itself.
41func (x *Sequence) Foreach(FuncVar *Func, UserDataVar uintptr) {
42
43 var FuncVarRef uintptr
44 if FuncVar != nil {
45 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
46 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
47 FuncVarRef = cbRefPtr
48 } else {
49 fcb := func(arg0 uintptr, arg1 uintptr) {
50 cbFn := *FuncVar
51 cbFn(arg0, arg1)
52 }
53 FuncVarRef = purego.NewCallback(fcb)
54 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
55 }
56 }
57
58 xSequenceForeach(x.GoPointer(), FuncVarRef, UserDataVar)
59
60}
61
62var xSequenceFree func(uintptr)
63
64// Frees the memory allocated for @seq. If @seq has a data destroy
65// function associated with it, that function is called on all items
66// in @seq.
67func (x *Sequence) Free() {
68
69 xSequenceFree(x.GoPointer())
70
71}
72
73var xSequenceGetBeginIter func(uintptr) *SequenceIter
74
75// Returns the begin iterator for @seq.
76func (x *Sequence) GetBeginIter() *SequenceIter {
77
78 cret := xSequenceGetBeginIter(x.GoPointer())
79 return cret
80}
81
82var xSequenceGetEndIter func(uintptr) *SequenceIter
83
84// Returns the end iterator for @seg
85func (x *Sequence) GetEndIter() *SequenceIter {
86
87 cret := xSequenceGetEndIter(x.GoPointer())
88 return cret
89}
90
91var xSequenceGetIterAtPos func(uintptr, int) *SequenceIter
92
93// Returns the iterator at position @pos. If @pos is negative or larger
94// than the number of items in @seq, the end iterator is returned.
95func (x *Sequence) GetIterAtPos(PosVar int) *SequenceIter {
96
97 cret := xSequenceGetIterAtPos(x.GoPointer(), PosVar)
98 return cret
99}
100
101var xSequenceGetLength func(uintptr) int
102
103// Returns the positive length (>= 0) of @seq. Note that this method is
104// O(h) where `h' is the height of the tree. It is thus more efficient
105// to use g_sequence_is_empty() when comparing the length to zero.
106func (x *Sequence) GetLength() int {
107
108 cret := xSequenceGetLength(x.GoPointer())
109 return cret
110}
111
112var xSequenceInsertSorted func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
113
114// Inserts @data into @seq using @cmp_func to determine the new
115// position. The sequence must already be sorted according to @cmp_func;
116// otherwise the new position of @data is undefined.
117//
118// @cmp_func is called with two items of the @seq, and @cmp_data.
119// It should return 0 if the items are equal, a negative value
120// if the first item comes before the second, and a positive value
121// if the second item comes before the first.
122//
123// Note that when adding a large amount of data to a #GSequence,
124// it is more efficient to do unsorted insertions and then call
125// g_sequence_sort() or g_sequence_sort_iter().
126func (x *Sequence) InsertSorted(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter {
127
128 var CmpFuncVarRef uintptr
129 if CmpFuncVar != nil {
130 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
131 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
132 CmpFuncVarRef = cbRefPtr
133 } else {
134 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
135 cbFn := *CmpFuncVar
136 return cbFn(arg0, arg1, arg2)
137 }
138 CmpFuncVarRef = purego.NewCallback(fcb)
139 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
140 }
141 }
142
143 cret := xSequenceInsertSorted(x.GoPointer(), DataVar, CmpFuncVarRef, CmpDataVar)
144 return cret
145}
146
147var xSequenceInsertSortedIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
148
149// Like g_sequence_insert_sorted(), but uses
150// a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
151// the compare function.
152//
153// @iter_cmp is called with two iterators pointing into @seq.
154// It should return 0 if the iterators are equal, a negative
155// value if the first iterator comes before the second, and a
156// positive value if the second iterator comes before the first.
157//
158// Note that when adding a large amount of data to a #GSequence,
159// it is more efficient to do unsorted insertions and then call
160// g_sequence_sort() or g_sequence_sort_iter().
161func (x *Sequence) InsertSortedIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter {
162
163 var IterCmpVarRef uintptr
164 if IterCmpVar != nil {
165 IterCmpVarPtr := uintptr(unsafe.Pointer(IterCmpVar))
166 if cbRefPtr, ok := GetCallback(IterCmpVarPtr); ok {
167 IterCmpVarRef = cbRefPtr
168 } else {
169 fcb := func(arg0 *SequenceIter, arg1 *SequenceIter, arg2 uintptr) int {
170 cbFn := *IterCmpVar
171 return cbFn(arg0, arg1, arg2)
172 }
173 IterCmpVarRef = purego.NewCallback(fcb)
174 SaveCallbackWithClosure(IterCmpVarPtr, IterCmpVarRef, IterCmpVar)
175 }
176 }
177
178 cret := xSequenceInsertSortedIter(x.GoPointer(), DataVar, IterCmpVarRef, CmpDataVar)
179 return cret
180}
181
182var xSequenceIsEmpty func(uintptr) bool
183
184// Returns %TRUE if the sequence contains zero items.
185//
186// This function is functionally identical to checking the result of
187// g_sequence_get_length() being equal to zero. However this function is
188// implemented in O(1) running time.
189func (x *Sequence) IsEmpty() bool {
190
191 cret := xSequenceIsEmpty(x.GoPointer())
192 return cret
193}
194
195var xSequenceLookup func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
196
197// Returns an iterator pointing to the position of the first item found
198// equal to @data according to @cmp_func and @cmp_data. If more than one
199// item is equal, it is not guaranteed that it is the first which is
200// returned. In that case, you can use g_sequence_iter_next() and
201// g_sequence_iter_prev() to get others.
202//
203// @cmp_func is called with two items of the @seq, and @cmp_data.
204// It should return 0 if the items are equal, a negative value if
205// the first item comes before the second, and a positive value if
206// the second item comes before the first.
207//
208// This function will fail if the data contained in the sequence is
209// unsorted.
210func (x *Sequence) Lookup(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter {
211
212 var CmpFuncVarRef uintptr
213 if CmpFuncVar != nil {
214 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
215 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
216 CmpFuncVarRef = cbRefPtr
217 } else {
218 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
219 cbFn := *CmpFuncVar
220 return cbFn(arg0, arg1, arg2)
221 }
222 CmpFuncVarRef = purego.NewCallback(fcb)
223 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
224 }
225 }
226
227 cret := xSequenceLookup(x.GoPointer(), DataVar, CmpFuncVarRef, CmpDataVar)
228 return cret
229}
230
231var xSequenceLookupIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
232
233// Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
234// instead of a #GCompareDataFunc as the compare function.
235//
236// @iter_cmp is called with two iterators pointing into @seq.
237// It should return 0 if the iterators are equal, a negative value
238// if the first iterator comes before the second, and a positive
239// value if the second iterator comes before the first.
240//
241// This function will fail if the data contained in the sequence is
242// unsorted.
243func (x *Sequence) LookupIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter {
244
245 var IterCmpVarRef uintptr
246 if IterCmpVar != nil {
247 IterCmpVarPtr := uintptr(unsafe.Pointer(IterCmpVar))
248 if cbRefPtr, ok := GetCallback(IterCmpVarPtr); ok {
249 IterCmpVarRef = cbRefPtr
250 } else {
251 fcb := func(arg0 *SequenceIter, arg1 *SequenceIter, arg2 uintptr) int {
252 cbFn := *IterCmpVar
253 return cbFn(arg0, arg1, arg2)
254 }
255 IterCmpVarRef = purego.NewCallback(fcb)
256 SaveCallbackWithClosure(IterCmpVarPtr, IterCmpVarRef, IterCmpVar)
257 }
258 }
259
260 cret := xSequenceLookupIter(x.GoPointer(), DataVar, IterCmpVarRef, CmpDataVar)
261 return cret
262}
263
264var xSequencePrepend func(uintptr, uintptr) *SequenceIter
265
266// Adds a new item to the front of @seq
267func (x *Sequence) Prepend(DataVar uintptr) *SequenceIter {
268
269 cret := xSequencePrepend(x.GoPointer(), DataVar)
270 return cret
271}
272
273var xSequenceSearch func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
274
275// Returns an iterator pointing to the position where @data would
276// be inserted according to @cmp_func and @cmp_data.
277//
278// @cmp_func is called with two items of the @seq, and @cmp_data.
279// It should return 0 if the items are equal, a negative value if
280// the first item comes before the second, and a positive value if
281// the second item comes before the first.
282//
283// If you are simply searching for an existing element of the sequence,
284// consider using g_sequence_lookup().
285//
286// This function will fail if the data contained in the sequence is
287// unsorted.
288func (x *Sequence) Search(DataVar uintptr, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) *SequenceIter {
289
290 var CmpFuncVarRef uintptr
291 if CmpFuncVar != nil {
292 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
293 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
294 CmpFuncVarRef = cbRefPtr
295 } else {
296 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
297 cbFn := *CmpFuncVar
298 return cbFn(arg0, arg1, arg2)
299 }
300 CmpFuncVarRef = purego.NewCallback(fcb)
301 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
302 }
303 }
304
305 cret := xSequenceSearch(x.GoPointer(), DataVar, CmpFuncVarRef, CmpDataVar)
306 return cret
307}
308
309var xSequenceSearchIter func(uintptr, uintptr, uintptr, uintptr) *SequenceIter
310
311// Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
312// instead of a #GCompareDataFunc as the compare function.
313//
314// @iter_cmp is called with two iterators pointing into @seq.
315// It should return 0 if the iterators are equal, a negative value
316// if the first iterator comes before the second, and a positive
317// value if the second iterator comes before the first.
318//
319// If you are simply searching for an existing element of the sequence,
320// consider using g_sequence_lookup_iter().
321//
322// This function will fail if the data contained in the sequence is
323// unsorted.
324func (x *Sequence) SearchIter(DataVar uintptr, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) *SequenceIter {
325
326 var IterCmpVarRef uintptr
327 if IterCmpVar != nil {
328 IterCmpVarPtr := uintptr(unsafe.Pointer(IterCmpVar))
329 if cbRefPtr, ok := GetCallback(IterCmpVarPtr); ok {
330 IterCmpVarRef = cbRefPtr
331 } else {
332 fcb := func(arg0 *SequenceIter, arg1 *SequenceIter, arg2 uintptr) int {
333 cbFn := *IterCmpVar
334 return cbFn(arg0, arg1, arg2)
335 }
336 IterCmpVarRef = purego.NewCallback(fcb)
337 SaveCallbackWithClosure(IterCmpVarPtr, IterCmpVarRef, IterCmpVar)
338 }
339 }
340
341 cret := xSequenceSearchIter(x.GoPointer(), DataVar, IterCmpVarRef, CmpDataVar)
342 return cret
343}
344
345var xSequenceSort func(uintptr, uintptr, uintptr)
346
347// Sorts @seq using @cmp_func.
348//
349// @cmp_func is passed two items of @seq and should
350// return 0 if they are equal, a negative value if the
351// first comes before the second, and a positive value
352// if the second comes before the first.
353func (x *Sequence) Sort(CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) {
354
355 var CmpFuncVarRef uintptr
356 if CmpFuncVar != nil {
357 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
358 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
359 CmpFuncVarRef = cbRefPtr
360 } else {
361 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
362 cbFn := *CmpFuncVar
363 return cbFn(arg0, arg1, arg2)
364 }
365 CmpFuncVarRef = purego.NewCallback(fcb)
366 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
367 }
368 }
369
370 xSequenceSort(x.GoPointer(), CmpFuncVarRef, CmpDataVar)
371
372}
373
374var xSequenceSortIter func(uintptr, uintptr, uintptr)
375
376// Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
377// of a #GCompareDataFunc as the compare function
378//
379// @cmp_func is called with two iterators pointing into @seq. It should
380// return 0 if the iterators are equal, a negative value if the first
381// iterator comes before the second, and a positive value if the second
382// iterator comes before the first.
383func (x *Sequence) SortIter(CmpFuncVar *SequenceIterCompareFunc, CmpDataVar uintptr) {
384
385 var CmpFuncVarRef uintptr
386 if CmpFuncVar != nil {
387 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
388 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
389 CmpFuncVarRef = cbRefPtr
390 } else {
391 fcb := func(arg0 *SequenceIter, arg1 *SequenceIter, arg2 uintptr) int {
392 cbFn := *CmpFuncVar
393 return cbFn(arg0, arg1, arg2)
394 }
395 CmpFuncVarRef = purego.NewCallback(fcb)
396 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
397 }
398 }
399
400 xSequenceSortIter(x.GoPointer(), CmpFuncVarRef, CmpDataVar)
401
402}
403
404// The #GSequenceIter struct is an opaque data type representing an
405// iterator pointing into a #GSequence.
406type SequenceIter struct {
407 _ structs.HostLayout
408}
409
410func (x *SequenceIter) GoPointer() uintptr {
411 return uintptr(unsafe.Pointer(x))
412}
413
414var xSequenceIterCompare func(uintptr, *SequenceIter) int
415
416// Returns a negative number if @a comes before @b, 0 if they are equal,
417// and a positive number if @a comes after @b.
418//
419// The @a and @b iterators must point into the same sequence.
420func (x *SequenceIter) Compare(BVar *SequenceIter) int {
421
422 cret := xSequenceIterCompare(x.GoPointer(), BVar)
423 return cret
424}
425
426var xSequenceIterGetPosition func(uintptr) int
427
428// Returns the position of @iter
429func (x *SequenceIter) GetPosition() int {
430
431 cret := xSequenceIterGetPosition(x.GoPointer())
432 return cret
433}
434
435var xSequenceIterGetSequence func(uintptr) *Sequence
436
437// Returns the #GSequence that @iter points into.
438func (x *SequenceIter) GetSequence() *Sequence {
439
440 cret := xSequenceIterGetSequence(x.GoPointer())
441 return cret
442}
443
444var xSequenceIterIsBegin func(uintptr) bool
445
446// Returns whether @iter is the begin iterator
447func (x *SequenceIter) IsBegin() bool {
448
449 cret := xSequenceIterIsBegin(x.GoPointer())
450 return cret
451}
452
453var xSequenceIterIsEnd func(uintptr) bool
454
455// Returns whether @iter is the end iterator
456func (x *SequenceIter) IsEnd() bool {
457
458 cret := xSequenceIterIsEnd(x.GoPointer())
459 return cret
460}
461
462var xSequenceIterMove func(uintptr, int) *SequenceIter
463
464// Returns the #GSequenceIter which is @delta positions away from @iter.
465// If @iter is closer than -@delta positions to the beginning of the sequence,
466// the begin iterator is returned. If @iter is closer than @delta positions
467// to the end of the sequence, the end iterator is returned.
468func (x *SequenceIter) Move(DeltaVar int) *SequenceIter {
469
470 cret := xSequenceIterMove(x.GoPointer(), DeltaVar)
471 return cret
472}
473
474var xSequenceIterNext func(uintptr) *SequenceIter
475
476// Returns an iterator pointing to the next position after @iter.
477// If @iter is the end iterator, the end iterator is returned.
478func (x *SequenceIter) Next() *SequenceIter {
479
480 cret := xSequenceIterNext(x.GoPointer())
481 return cret
482}
483
484var xSequenceIterPrev func(uintptr) *SequenceIter
485
486// Returns an iterator pointing to the previous position before @iter.
487// If @iter is the begin iterator, the begin iterator is returned.
488func (x *SequenceIter) Prev() *SequenceIter {
489
490 cret := xSequenceIterPrev(x.GoPointer())
491 return cret
492}
493
494var xSequenceForeachRange func(*SequenceIter, *SequenceIter, uintptr, uintptr)
495
496// Calls @func for each item in the range (@begin, @end) passing
497// @user_data to the function. @func must not modify the sequence
498// itself.
499func SequenceForeachRange(BeginVar *SequenceIter, EndVar *SequenceIter, FuncVar *Func, UserDataVar uintptr) {
500
501 var FuncVarRef uintptr
502 if FuncVar != nil {
503 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
504 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
505 FuncVarRef = cbRefPtr
506 } else {
507 fcb := func(arg0 uintptr, arg1 uintptr) {
508 cbFn := *FuncVar
509 cbFn(arg0, arg1)
510 }
511 FuncVarRef = purego.NewCallback(fcb)
512 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
513 }
514 }
515
516 xSequenceForeachRange(BeginVar, EndVar, FuncVarRef, UserDataVar)
517
518}
519
520var xSequenceGet func(*SequenceIter) uintptr
521
522// Returns the data that @iter points to.
523func SequenceGet(IterVar *SequenceIter) uintptr {
524
525 cret := xSequenceGet(IterVar)
526
527 return cret
528}
529
530var xSequenceInsertBefore func(*SequenceIter, uintptr) *SequenceIter
531
532// Inserts a new item just before the item pointed to by @iter.
533func SequenceInsertBefore(IterVar *SequenceIter, DataVar uintptr) *SequenceIter {
534
535 cret := xSequenceInsertBefore(IterVar, DataVar)
536
537 return cret
538}
539
540var xSequenceMove func(*SequenceIter, *SequenceIter)
541
542// Moves the item pointed to by @src to the position indicated by @dest.
543// After calling this function @dest will point to the position immediately
544// after @src. It is allowed for @src and @dest to point into different
545// sequences.
546func SequenceMove(SrcVar *SequenceIter, DestVar *SequenceIter) {
547
548 xSequenceMove(SrcVar, DestVar)
549
550}
551
552var xSequenceMoveRange func(*SequenceIter, *SequenceIter, *SequenceIter)
553
554// Inserts the (@begin, @end) range at the destination pointed to by @dest.
555// The @begin and @end iters must point into the same sequence. It is
556// allowed for @dest to point to a different sequence than the one pointed
557// into by @begin and @end.
558//
559// If @dest is %NULL, the range indicated by @begin and @end is
560// removed from the sequence. If @dest points to a place within
561// the (@begin, @end) range, the range does not move.
562func SequenceMoveRange(DestVar *SequenceIter, BeginVar *SequenceIter, EndVar *SequenceIter) {
563
564 xSequenceMoveRange(DestVar, BeginVar, EndVar)
565
566}
567
568var xSequenceRangeGetMidpoint func(*SequenceIter, *SequenceIter) *SequenceIter
569
570// Finds an iterator somewhere in the range (@begin, @end). This
571// iterator will be close to the middle of the range, but is not
572// guaranteed to be exactly in the middle.
573//
574// The @begin and @end iterators must both point to the same sequence
575// and @begin must come before or be equal to @end in the sequence.
576func SequenceRangeGetMidpoint(BeginVar *SequenceIter, EndVar *SequenceIter) *SequenceIter {
577
578 cret := xSequenceRangeGetMidpoint(BeginVar, EndVar)
579
580 return cret
581}
582
583var xSequenceRemove func(*SequenceIter)
584
585// Removes the item pointed to by @iter. It is an error to pass the
586// end iterator to this function.
587//
588// If the sequence has a data destroy function associated with it, this
589// function is called on the data for the removed item.
590func SequenceRemove(IterVar *SequenceIter) {
591
592 xSequenceRemove(IterVar)
593
594}
595
596var xSequenceRemoveRange func(*SequenceIter, *SequenceIter)
597
598// Removes all items in the (@begin, @end) range.
599//
600// If the sequence has a data destroy function associated with it, this
601// function is called on the data for the removed items.
602func SequenceRemoveRange(BeginVar *SequenceIter, EndVar *SequenceIter) {
603
604 xSequenceRemoveRange(BeginVar, EndVar)
605
606}
607
608var xSequenceSet func(*SequenceIter, uintptr)
609
610// Changes the data for the item pointed to by @iter to be @data. If
611// the sequence has a data destroy function associated with it, that
612// function is called on the existing data that @iter pointed to.
613func SequenceSet(IterVar *SequenceIter, DataVar uintptr) {
614
615 xSequenceSet(IterVar, DataVar)
616
617}
618
619var xSequenceSortChanged func(*SequenceIter, uintptr, uintptr)
620
621// Moves the data pointed to by @iter to a new position as indicated by
622// @cmp_func. This
623// function should be called for items in a sequence already sorted according
624// to @cmp_func whenever some aspect of an item changes so that @cmp_func
625// may return different values for that item.
626//
627// @cmp_func is called with two items of the @seq, and @cmp_data.
628// It should return 0 if the items are equal, a negative value if
629// the first item comes before the second, and a positive value if
630// the second item comes before the first.
631func SequenceSortChanged(IterVar *SequenceIter, CmpFuncVar *CompareDataFunc, CmpDataVar uintptr) {
632
633 var CmpFuncVarRef uintptr
634 if CmpFuncVar != nil {
635 CmpFuncVarPtr := uintptr(unsafe.Pointer(CmpFuncVar))
636 if cbRefPtr, ok := GetCallback(CmpFuncVarPtr); ok {
637 CmpFuncVarRef = cbRefPtr
638 } else {
639 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
640 cbFn := *CmpFuncVar
641 return cbFn(arg0, arg1, arg2)
642 }
643 CmpFuncVarRef = purego.NewCallback(fcb)
644 SaveCallbackWithClosure(CmpFuncVarPtr, CmpFuncVarRef, CmpFuncVar)
645 }
646 }
647
648 xSequenceSortChanged(IterVar, CmpFuncVarRef, CmpDataVar)
649
650}
651
652var xSequenceSortChangedIter func(*SequenceIter, uintptr, uintptr)
653
654// Like g_sequence_sort_changed(), but uses
655// a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
656// the compare function.
657//
658// @iter_cmp is called with two iterators pointing into the #GSequence that
659// @iter points into. It should
660// return 0 if the iterators are equal, a negative value if the first
661// iterator comes before the second, and a positive value if the second
662// iterator comes before the first.
663func SequenceSortChangedIter(IterVar *SequenceIter, IterCmpVar *SequenceIterCompareFunc, CmpDataVar uintptr) {
664
665 var IterCmpVarRef uintptr
666 if IterCmpVar != nil {
667 IterCmpVarPtr := uintptr(unsafe.Pointer(IterCmpVar))
668 if cbRefPtr, ok := GetCallback(IterCmpVarPtr); ok {
669 IterCmpVarRef = cbRefPtr
670 } else {
671 fcb := func(arg0 *SequenceIter, arg1 *SequenceIter, arg2 uintptr) int {
672 cbFn := *IterCmpVar
673 return cbFn(arg0, arg1, arg2)
674 }
675 IterCmpVarRef = purego.NewCallback(fcb)
676 SaveCallbackWithClosure(IterCmpVarPtr, IterCmpVarRef, IterCmpVar)
677 }
678 }
679
680 xSequenceSortChangedIter(IterVar, IterCmpVarRef, CmpDataVar)
681
682}
683
684var xSequenceSwap func(*SequenceIter, *SequenceIter)
685
686// Swaps the items pointed to by @a and @b. It is allowed for @a and @b
687// to point into difference sequences.
688func SequenceSwap(AVar *SequenceIter, BVar *SequenceIter) {
689
690 xSequenceSwap(AVar, BVar)
691
692}
693
694func init() {
695 core.SetPackageName("GLIB", "glib-2.0")
696 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
697 var libs []uintptr
698 for _, libPath := range core.GetPaths("GLIB") {
699 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
700 if err != nil {
701 panic(err)
702 }
703 libs = append(libs, lib)
704 }
705
706 core.PuregoSafeRegister(&xSequenceForeachRange, libs, "g_sequence_foreach_range")
707 core.PuregoSafeRegister(&xSequenceGet, libs, "g_sequence_get")
708 core.PuregoSafeRegister(&xSequenceInsertBefore, libs, "g_sequence_insert_before")
709 core.PuregoSafeRegister(&xSequenceMove, libs, "g_sequence_move")
710 core.PuregoSafeRegister(&xSequenceMoveRange, libs, "g_sequence_move_range")
711 core.PuregoSafeRegister(&xSequenceRangeGetMidpoint, libs, "g_sequence_range_get_midpoint")
712 core.PuregoSafeRegister(&xSequenceRemove, libs, "g_sequence_remove")
713 core.PuregoSafeRegister(&xSequenceRemoveRange, libs, "g_sequence_remove_range")
714 core.PuregoSafeRegister(&xSequenceSet, libs, "g_sequence_set")
715 core.PuregoSafeRegister(&xSequenceSortChanged, libs, "g_sequence_sort_changed")
716 core.PuregoSafeRegister(&xSequenceSortChangedIter, libs, "g_sequence_sort_changed_iter")
717 core.PuregoSafeRegister(&xSequenceSwap, libs, "g_sequence_swap")
718
719 core.PuregoSafeRegister(&xSequenceAppend, libs, "g_sequence_append")
720 core.PuregoSafeRegister(&xSequenceForeach, libs, "g_sequence_foreach")
721 core.PuregoSafeRegister(&xSequenceFree, libs, "g_sequence_free")
722 core.PuregoSafeRegister(&xSequenceGetBeginIter, libs, "g_sequence_get_begin_iter")
723 core.PuregoSafeRegister(&xSequenceGetEndIter, libs, "g_sequence_get_end_iter")
724 core.PuregoSafeRegister(&xSequenceGetIterAtPos, libs, "g_sequence_get_iter_at_pos")
725 core.PuregoSafeRegister(&xSequenceGetLength, libs, "g_sequence_get_length")
726 core.PuregoSafeRegister(&xSequenceInsertSorted, libs, "g_sequence_insert_sorted")
727 core.PuregoSafeRegister(&xSequenceInsertSortedIter, libs, "g_sequence_insert_sorted_iter")
728 core.PuregoSafeRegister(&xSequenceIsEmpty, libs, "g_sequence_is_empty")
729 core.PuregoSafeRegister(&xSequenceLookup, libs, "g_sequence_lookup")
730 core.PuregoSafeRegister(&xSequenceLookupIter, libs, "g_sequence_lookup_iter")
731 core.PuregoSafeRegister(&xSequencePrepend, libs, "g_sequence_prepend")
732 core.PuregoSafeRegister(&xSequenceSearch, libs, "g_sequence_search")
733 core.PuregoSafeRegister(&xSequenceSearchIter, libs, "g_sequence_search_iter")
734 core.PuregoSafeRegister(&xSequenceSort, libs, "g_sequence_sort")
735 core.PuregoSafeRegister(&xSequenceSortIter, libs, "g_sequence_sort_iter")
736
737 core.PuregoSafeRegister(&xSequenceIterCompare, libs, "g_sequence_iter_compare")
738 core.PuregoSafeRegister(&xSequenceIterGetPosition, libs, "g_sequence_iter_get_position")
739 core.PuregoSafeRegister(&xSequenceIterGetSequence, libs, "g_sequence_iter_get_sequence")
740 core.PuregoSafeRegister(&xSequenceIterIsBegin, libs, "g_sequence_iter_is_begin")
741 core.PuregoSafeRegister(&xSequenceIterIsEnd, libs, "g_sequence_iter_is_end")
742 core.PuregoSafeRegister(&xSequenceIterMove, libs, "g_sequence_iter_move")
743 core.PuregoSafeRegister(&xSequenceIterNext, libs, "g_sequence_iter_next")
744 core.PuregoSafeRegister(&xSequenceIterPrev, libs, "g_sequence_iter_prev")
745
746}