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 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// Specifies the type of the function passed to
15// [func@GLib.HashTable.find], [func@GLib.HashTable.foreach_remove], and
16// [func@GLib.HashTable.foreach_steal].
17//
18// The function is called with each key/value pair, together with
19// the @user_data parameter passed to the calling function.
20//
21// The function should return true if the key/value pair should be
22// selected, meaning it has been found or it should be removed from the
23// [struct@GLib.HashTable], depending on the calling function.
24type HRFunc func(uintptr, uintptr, uintptr) bool
25
26// The #GHashTable struct is an opaque data structure to represent a
27// [Hash Table](data-structures.html#hash-tables). It should only be accessed via the
28// following functions.
29type HashTable struct {
30 _ structs.HostLayout
31}
32
33var xHashTableGLibType func() types.GType
34
35func HashTableGLibType() types.GType {
36 return xHashTableGLibType()
37}
38
39func (x *HashTable) GoPointer() uintptr {
40 return uintptr(unsafe.Pointer(x))
41}
42
43// A GHashTableIter structure represents an iterator that can be used
44// to iterate over the elements of a #GHashTable. GHashTableIter
45// structures are typically allocated on the stack and then initialized
46// with g_hash_table_iter_init().
47//
48// The iteration order of a #GHashTableIter over the keys/values in a hash
49// table is not defined.
50type HashTableIter struct {
51 _ structs.HostLayout
52
53 Dummy1 uintptr
54
55 Dummy2 uintptr
56
57 Dummy3 uintptr
58
59 Dummy4 int
60
61 Dummy5 bool
62
63 Dummy6 uintptr
64}
65
66func (x *HashTableIter) GoPointer() uintptr {
67 return uintptr(unsafe.Pointer(x))
68}
69
70var xHashTableIterGetHashTable func(uintptr) *HashTable
71
72// Returns the #GHashTable associated with @iter.
73func (x *HashTableIter) GetHashTable() *HashTable {
74
75 cret := xHashTableIterGetHashTable(x.GoPointer())
76 return cret
77}
78
79var xHashTableIterInit func(uintptr, *HashTable)
80
81// Initializes a key/value pair iterator and associates it with
82// @hash_table. Modifying the hash table after calling this function
83// invalidates the returned iterator.
84//
85// The iteration order of a #GHashTableIter over the keys/values in a hash
86// table is not defined.
87//
88// |[<!-- language="C" -->
89// GHashTableIter iter;
90// gpointer key, value;
91//
92// g_hash_table_iter_init (&iter, hash_table);
93// while (g_hash_table_iter_next (&iter, &key, &value))
94//
95// {
96// // do something with key and value
97// }
98//
99// ]|
100func (x *HashTableIter) Init(HashTableVar *HashTable) {
101
102 xHashTableIterInit(x.GoPointer(), HashTableVar)
103
104}
105
106var xHashTableIterNext func(uintptr, *uintptr, *uintptr) bool
107
108// Advances @iter and retrieves the key and/or value that are now
109// pointed to as a result of this advancement. If %FALSE is returned,
110// @key and @value are not set, and the iterator becomes invalid.
111func (x *HashTableIter) Next(KeyVar *uintptr, ValueVar *uintptr) bool {
112
113 cret := xHashTableIterNext(x.GoPointer(), KeyVar, ValueVar)
114 return cret
115}
116
117var xHashTableIterRemove func(uintptr)
118
119// Removes the key/value pair currently pointed to by the iterator
120// from its associated #GHashTable. Can only be called after
121// g_hash_table_iter_next() returned %TRUE, and cannot be called
122// more than once for the same key/value pair.
123//
124// If the #GHashTable was created using g_hash_table_new_full(),
125// the key and value are freed using the supplied destroy functions,
126// otherwise you have to make sure that any dynamically allocated
127// values are freed yourself.
128//
129// It is safe to continue iterating the #GHashTable afterward:
130// |[<!-- language="C" -->
131// while (g_hash_table_iter_next (&iter, &key, &value))
132//
133// {
134// if (condition)
135// g_hash_table_iter_remove (&iter);
136// }
137//
138// ]|
139func (x *HashTableIter) Remove() {
140
141 xHashTableIterRemove(x.GoPointer())
142
143}
144
145var xHashTableIterReplace func(uintptr, uintptr)
146
147// Replaces the value currently pointed to by the iterator
148// from its associated #GHashTable. Can only be called after
149// g_hash_table_iter_next() returned %TRUE.
150//
151// If you supplied a @value_destroy_func when creating the
152// #GHashTable, the old value is freed using that function.
153func (x *HashTableIter) Replace(ValueVar uintptr) {
154
155 xHashTableIterReplace(x.GoPointer(), ValueVar)
156
157}
158
159var xHashTableIterSteal func(uintptr)
160
161// Removes the key/value pair currently pointed to by the
162// iterator from its associated #GHashTable, without calling
163// the key and value destroy functions. Can only be called
164// after g_hash_table_iter_next() returned %TRUE, and cannot
165// be called more than once for the same key/value pair.
166func (x *HashTableIter) Steal() {
167
168 xHashTableIterSteal(x.GoPointer())
169
170}
171
172var xDirectEqual func(uintptr, uintptr) bool
173
174// Compares two #gpointer arguments and returns %TRUE if they are equal.
175// It can be passed to g_hash_table_new() as the @key_equal_func
176// parameter, when using opaque pointers compared by pointer value as
177// keys in a #GHashTable.
178//
179// This equality function is also appropriate for keys that are integers
180// stored in pointers, such as `GINT_TO_POINTER (n)`.
181func DirectEqual(V1Var uintptr, V2Var uintptr) bool {
182
183 cret := xDirectEqual(V1Var, V2Var)
184
185 return cret
186}
187
188var xDirectHash func(uintptr) uint
189
190// Converts a gpointer to a hash value.
191// It can be passed to g_hash_table_new() as the @hash_func parameter,
192// when using opaque pointers compared by pointer value as keys in a
193// #GHashTable.
194//
195// This hash function is also appropriate for keys that are integers
196// stored in pointers, such as `GINT_TO_POINTER (n)`.
197func DirectHash(VVar uintptr) uint {
198
199 cret := xDirectHash(VVar)
200
201 return cret
202}
203
204var xDoubleEqual func(uintptr, uintptr) bool
205
206// Compares the two #gdouble values being pointed to and returns
207// %TRUE if they are equal.
208// It can be passed to g_hash_table_new() as the @key_equal_func
209// parameter, when using non-%NULL pointers to doubles as keys in a
210// #GHashTable.
211func DoubleEqual(V1Var uintptr, V2Var uintptr) bool {
212
213 cret := xDoubleEqual(V1Var, V2Var)
214
215 return cret
216}
217
218var xDoubleHash func(uintptr) uint
219
220// Converts a pointer to a #gdouble to a hash value.
221// It can be passed to g_hash_table_new() as the @hash_func parameter,
222// It can be passed to g_hash_table_new() as the @hash_func parameter,
223// when using non-%NULL pointers to doubles as keys in a #GHashTable.
224func DoubleHash(VVar uintptr) uint {
225
226 cret := xDoubleHash(VVar)
227
228 return cret
229}
230
231var xHashTableAdd func(*HashTable, uintptr) bool
232
233// This is a convenience function for using a #GHashTable as a set. It
234// is equivalent to calling g_hash_table_replace() with @key as both the
235// key and the value.
236//
237// In particular, this means that if @key already exists in the hash table, then
238// the old copy of @key in the hash table is freed and @key replaces it in the
239// table.
240//
241// When a hash table only ever contains keys that have themselves as the
242// corresponding value it is able to be stored more efficiently. See
243// the discussion in the section description.
244//
245// Starting from GLib 2.40, this function returns a boolean value to
246// indicate whether the newly added value was already in the hash table
247// or not.
248func HashTableAdd(HashTableVar *HashTable, KeyVar uintptr) bool {
249
250 cret := xHashTableAdd(HashTableVar, KeyVar)
251
252 return cret
253}
254
255var xHashTableContains func(*HashTable, uintptr) bool
256
257// Checks if @key is in @hash_table.
258func HashTableContains(HashTableVar *HashTable, KeyVar uintptr) bool {
259
260 cret := xHashTableContains(HashTableVar, KeyVar)
261
262 return cret
263}
264
265var xHashTableDestroy func(*HashTable)
266
267// Destroys all keys and values in the #GHashTable and decrements its
268// reference count by 1. If keys and/or values are dynamically allocated,
269// you should either free them first or create the #GHashTable with destroy
270// notifiers using g_hash_table_new_full(). In the latter case the destroy
271// functions you supplied will be called on all keys and values during the
272// destruction phase.
273func HashTableDestroy(HashTableVar *HashTable) {
274
275 xHashTableDestroy(HashTableVar)
276
277}
278
279var xHashTableFind func(*HashTable, uintptr, uintptr) uintptr
280
281// Calls the given function for key/value pairs in the #GHashTable
282// until @predicate returns %TRUE. The function is passed the key
283// and value of each pair, and the given @user_data parameter. The
284// hash table may not be modified while iterating over it (you can't
285// add/remove items).
286//
287// Note, that hash tables are really only optimized for forward
288// lookups, i.e. g_hash_table_lookup(). So code that frequently issues
289// g_hash_table_find() or g_hash_table_foreach() (e.g. in the order of
290// once per every entry in a hash table) should probably be reworked
291// to use additional or different data structures for reverse lookups
292// (keep in mind that an O(n) find/foreach operation issued for all n
293// values in a hash table ends up needing O(n*n) operations).
294func HashTableFind(HashTableVar *HashTable, PredicateVar *HRFunc, UserDataVar uintptr) uintptr {
295
296 var PredicateVarRef uintptr
297 if PredicateVar != nil {
298 PredicateVarPtr := uintptr(unsafe.Pointer(PredicateVar))
299 if cbRefPtr, ok := GetCallback(PredicateVarPtr); ok {
300 PredicateVarRef = cbRefPtr
301 } else {
302 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) bool {
303 cbFn := *PredicateVar
304 return cbFn(arg0, arg1, arg2)
305 }
306 PredicateVarRef = purego.NewCallback(fcb)
307 SaveCallbackWithClosure(PredicateVarPtr, PredicateVarRef, PredicateVar)
308 }
309 }
310
311 cret := xHashTableFind(HashTableVar, PredicateVarRef, UserDataVar)
312
313 return cret
314}
315
316var xHashTableForeach func(*HashTable, uintptr, uintptr)
317
318// Calls the given function for each of the key/value pairs in the
319// #GHashTable. The function is passed the key and value of each
320// pair, and the given @user_data parameter. The hash table may not
321// be modified while iterating over it (you can't add/remove
322// items). To remove all items matching a predicate, use
323// g_hash_table_foreach_remove().
324//
325// The order in which g_hash_table_foreach() iterates over the keys/values in
326// the hash table is not defined.
327//
328// See g_hash_table_find() for performance caveats for linear
329// order searches in contrast to g_hash_table_lookup().
330func HashTableForeach(HashTableVar *HashTable, FuncVar *HFunc, UserDataVar uintptr) {
331
332 var FuncVarRef uintptr
333 if FuncVar != nil {
334 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
335 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
336 FuncVarRef = cbRefPtr
337 } else {
338 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
339 cbFn := *FuncVar
340 cbFn(arg0, arg1, arg2)
341 }
342 FuncVarRef = purego.NewCallback(fcb)
343 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
344 }
345 }
346
347 xHashTableForeach(HashTableVar, FuncVarRef, UserDataVar)
348
349}
350
351var xHashTableForeachRemove func(*HashTable, uintptr, uintptr) uint
352
353// Calls the given function for each key/value pair in the
354// #GHashTable. If the function returns %TRUE, then the key/value
355// pair is removed from the #GHashTable. If you supplied key or
356// value destroy functions when creating the #GHashTable, they are
357// used to free the memory allocated for the removed keys and values.
358//
359// See #GHashTableIter for an alternative way to loop over the
360// key/value pairs in the hash table.
361func HashTableForeachRemove(HashTableVar *HashTable, FuncVar *HRFunc, UserDataVar uintptr) uint {
362
363 var FuncVarRef uintptr
364 if FuncVar != nil {
365 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
366 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
367 FuncVarRef = cbRefPtr
368 } else {
369 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) bool {
370 cbFn := *FuncVar
371 return cbFn(arg0, arg1, arg2)
372 }
373 FuncVarRef = purego.NewCallback(fcb)
374 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
375 }
376 }
377
378 cret := xHashTableForeachRemove(HashTableVar, FuncVarRef, UserDataVar)
379
380 return cret
381}
382
383var xHashTableForeachSteal func(*HashTable, uintptr, uintptr) uint
384
385// Calls the given function for each key/value pair in the
386// #GHashTable. If the function returns %TRUE, then the key/value
387// pair is removed from the #GHashTable, but no key or value
388// destroy functions are called.
389//
390// See #GHashTableIter for an alternative way to loop over the
391// key/value pairs in the hash table.
392func HashTableForeachSteal(HashTableVar *HashTable, FuncVar *HRFunc, UserDataVar uintptr) uint {
393
394 var FuncVarRef uintptr
395 if FuncVar != nil {
396 FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
397 if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
398 FuncVarRef = cbRefPtr
399 } else {
400 fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) bool {
401 cbFn := *FuncVar
402 return cbFn(arg0, arg1, arg2)
403 }
404 FuncVarRef = purego.NewCallback(fcb)
405 SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
406 }
407 }
408
409 cret := xHashTableForeachSteal(HashTableVar, FuncVarRef, UserDataVar)
410
411 return cret
412}
413
414var xHashTableGetKeysAsPtrArray func(*HashTable) uintptr
415
416// Retrieves every key inside @hash_table, as a #GPtrArray.
417// The returned data is valid until changes to the hash release those keys.
418//
419// This iterates over every entry in the hash table to build its return value.
420// To iterate over the entries in a #GHashTable more efficiently, use a
421// #GHashTableIter.
422//
423// You should always unref the returned array with g_ptr_array_unref().
424func HashTableGetKeysAsPtrArray(HashTableVar *HashTable) uintptr {
425
426 cret := xHashTableGetKeysAsPtrArray(HashTableVar)
427
428 return cret
429}
430
431var xHashTableGetValuesAsPtrArray func(*HashTable) uintptr
432
433// Retrieves every value inside @hash_table, as a #GPtrArray.
434// The returned data is valid until changes to the hash release those values.
435//
436// This iterates over every entry in the hash table to build its return value.
437// To iterate over the entries in a #GHashTable more efficiently, use a
438// #GHashTableIter.
439//
440// You should always unref the returned array with g_ptr_array_unref().
441func HashTableGetValuesAsPtrArray(HashTableVar *HashTable) uintptr {
442
443 cret := xHashTableGetValuesAsPtrArray(HashTableVar)
444
445 return cret
446}
447
448var xHashTableInsert func(*HashTable, uintptr, uintptr) bool
449
450// Inserts a new key and value into a #GHashTable.
451//
452// If the key already exists in the #GHashTable its current
453// value is replaced with the new value. If you supplied a
454// @value_destroy_func when creating the #GHashTable, the old
455// value is freed using that function. If you supplied a
456// @key_destroy_func when creating the #GHashTable, the passed
457// key is freed using that function.
458//
459// Starting from GLib 2.40, this function returns a boolean value to
460// indicate whether the newly added value was already in the hash table
461// or not.
462func HashTableInsert(HashTableVar *HashTable, KeyVar uintptr, ValueVar uintptr) bool {
463
464 cret := xHashTableInsert(HashTableVar, KeyVar, ValueVar)
465
466 return cret
467}
468
469var xHashTableLookup func(*HashTable, uintptr) uintptr
470
471// Looks up a key in a #GHashTable. Note that this function cannot
472// distinguish between a key that is not present and one which is present
473// and has the value %NULL. If you need this distinction, use
474// g_hash_table_lookup_extended().
475func HashTableLookup(HashTableVar *HashTable, KeyVar uintptr) uintptr {
476
477 cret := xHashTableLookup(HashTableVar, KeyVar)
478
479 return cret
480}
481
482var xHashTableLookupExtended func(*HashTable, uintptr, *uintptr, *uintptr) bool
483
484// Looks up a key in the #GHashTable, returning the original key and the
485// associated value and a #gboolean which is %TRUE if the key was found. This
486// is useful if you need to free the memory allocated for the original key,
487// for example before calling g_hash_table_remove().
488//
489// You can actually pass %NULL for @lookup_key to test
490// whether the %NULL key exists, provided the hash and equal functions
491// of @hash_table are %NULL-safe.
492func HashTableLookupExtended(HashTableVar *HashTable, LookupKeyVar uintptr, OrigKeyVar *uintptr, ValueVar *uintptr) bool {
493
494 cret := xHashTableLookupExtended(HashTableVar, LookupKeyVar, OrigKeyVar, ValueVar)
495
496 return cret
497}
498
499var xHashTableNewSimilar func(*HashTable) *HashTable
500
501// Creates a new #GHashTable like g_hash_table_new_full() with a reference
502// count of 1.
503//
504// It inherits the hash function, the key equal function, the key destroy function,
505// as well as the value destroy function, from @other_hash_table.
506//
507// The returned hash table will be empty; it will not contain the keys
508// or values from @other_hash_table.
509func HashTableNewSimilar(OtherHashTableVar *HashTable) *HashTable {
510
511 cret := xHashTableNewSimilar(OtherHashTableVar)
512
513 return cret
514}
515
516var xHashTableRef func(*HashTable) *HashTable
517
518// Atomically increments the reference count of @hash_table by one.
519// This function is MT-safe and may be called from any thread.
520func HashTableRef(HashTableVar *HashTable) *HashTable {
521
522 cret := xHashTableRef(HashTableVar)
523
524 return cret
525}
526
527var xHashTableRemove func(*HashTable, uintptr) bool
528
529// Removes a key and its associated value from a #GHashTable.
530//
531// If the #GHashTable was created using g_hash_table_new_full(), the
532// key and value are freed using the supplied destroy functions, otherwise
533// you have to make sure that any dynamically allocated values are freed
534// yourself.
535func HashTableRemove(HashTableVar *HashTable, KeyVar uintptr) bool {
536
537 cret := xHashTableRemove(HashTableVar, KeyVar)
538
539 return cret
540}
541
542var xHashTableRemoveAll func(*HashTable)
543
544// Removes all keys and their associated values from a #GHashTable.
545//
546// If the #GHashTable was created using g_hash_table_new_full(),
547// the keys and values are freed using the supplied destroy functions,
548// otherwise you have to make sure that any dynamically allocated
549// values are freed yourself.
550func HashTableRemoveAll(HashTableVar *HashTable) {
551
552 xHashTableRemoveAll(HashTableVar)
553
554}
555
556var xHashTableReplace func(*HashTable, uintptr, uintptr) bool
557
558// Inserts a new key and value into a #GHashTable similar to
559// g_hash_table_insert(). The difference is that if the key
560// already exists in the #GHashTable, it gets replaced by the
561// new key. If you supplied a @value_destroy_func when creating
562// the #GHashTable, the old value is freed using that function.
563// If you supplied a @key_destroy_func when creating the
564// #GHashTable, the old key is freed using that function.
565//
566// Starting from GLib 2.40, this function returns a boolean value to
567// indicate whether the newly added value was already in the hash table
568// or not.
569func HashTableReplace(HashTableVar *HashTable, KeyVar uintptr, ValueVar uintptr) bool {
570
571 cret := xHashTableReplace(HashTableVar, KeyVar, ValueVar)
572
573 return cret
574}
575
576var xHashTableSize func(*HashTable) uint
577
578// Returns the number of elements contained in the #GHashTable.
579func HashTableSize(HashTableVar *HashTable) uint {
580
581 cret := xHashTableSize(HashTableVar)
582
583 return cret
584}
585
586var xHashTableSteal func(*HashTable, uintptr) bool
587
588// Removes a key and its associated value from a #GHashTable without
589// calling the key and value destroy functions.
590func HashTableSteal(HashTableVar *HashTable, KeyVar uintptr) bool {
591
592 cret := xHashTableSteal(HashTableVar, KeyVar)
593
594 return cret
595}
596
597var xHashTableStealAll func(*HashTable)
598
599// Removes all keys and their associated values from a #GHashTable
600// without calling the key and value destroy functions.
601func HashTableStealAll(HashTableVar *HashTable) {
602
603 xHashTableStealAll(HashTableVar)
604
605}
606
607var xHashTableStealAllKeys func(*HashTable) uintptr
608
609// Removes all keys and their associated values from a #GHashTable
610// without calling the key destroy functions, returning the keys
611// as a #GPtrArray with the free func set to the @hash_table key
612// destroy function.
613func HashTableStealAllKeys(HashTableVar *HashTable) uintptr {
614
615 cret := xHashTableStealAllKeys(HashTableVar)
616
617 return cret
618}
619
620var xHashTableStealAllValues func(*HashTable) uintptr
621
622// Removes all keys and their associated values from a #GHashTable
623// without calling the value destroy functions, returning the values
624// as a #GPtrArray with the free func set to the @hash_table value
625// destroy function.
626func HashTableStealAllValues(HashTableVar *HashTable) uintptr {
627
628 cret := xHashTableStealAllValues(HashTableVar)
629
630 return cret
631}
632
633var xHashTableStealExtended func(*HashTable, uintptr, *uintptr, *uintptr) bool
634
635// Looks up a key in the #GHashTable, stealing the original key and the
636// associated value and returning %TRUE if the key was found. If the key was
637// not found, %FALSE is returned.
638//
639// If found, the stolen key and value are removed from the hash table without
640// calling the key and value destroy functions, and ownership is transferred to
641// the caller of this method, as with g_hash_table_steal(). That is the case
642// regardless whether @stolen_key or @stolen_value output parameters are
643// requested.
644//
645// You can pass %NULL for @lookup_key, provided the hash and equal functions
646// of @hash_table are %NULL-safe.
647//
648// The dictionary implementation optimizes for having all values identical to
649// their keys, for example by using g_hash_table_add(). Before 2.82, when
650// stealing both the key and the value from such a dictionary, the value was
651// %NULL. Since 2.82, the returned value and key will be the same.
652func HashTableStealExtended(HashTableVar *HashTable, LookupKeyVar uintptr, StolenKeyVar *uintptr, StolenValueVar *uintptr) bool {
653
654 cret := xHashTableStealExtended(HashTableVar, LookupKeyVar, StolenKeyVar, StolenValueVar)
655
656 return cret
657}
658
659var xHashTableUnref func(*HashTable)
660
661// Atomically decrements the reference count of @hash_table by one.
662// If the reference count drops to 0, all keys and values will be
663// destroyed, and all memory allocated by the hash table is released.
664// This function is MT-safe and may be called from any thread.
665func HashTableUnref(HashTableVar *HashTable) {
666
667 xHashTableUnref(HashTableVar)
668
669}
670
671var xInt64Equal func(uintptr, uintptr) bool
672
673// Compares the two #gint64 values being pointed to and returns
674// %TRUE if they are equal.
675// It can be passed to g_hash_table_new() as the @key_equal_func
676// parameter, when using non-%NULL pointers to 64-bit integers as keys in a
677// #GHashTable.
678func Int64Equal(V1Var uintptr, V2Var uintptr) bool {
679
680 cret := xInt64Equal(V1Var, V2Var)
681
682 return cret
683}
684
685var xInt64Hash func(uintptr) uint
686
687// Converts a pointer to a #gint64 to a hash value.
688//
689// It can be passed to g_hash_table_new() as the @hash_func parameter,
690// when using non-%NULL pointers to 64-bit integer values as keys in a
691// #GHashTable.
692func Int64Hash(VVar uintptr) uint {
693
694 cret := xInt64Hash(VVar)
695
696 return cret
697}
698
699var xIntEqual func(uintptr, uintptr) bool
700
701// Compares the two #gint values being pointed to and returns
702// %TRUE if they are equal.
703// It can be passed to g_hash_table_new() as the @key_equal_func
704// parameter, when using non-%NULL pointers to integers as keys in a
705// #GHashTable.
706//
707// Note that this function acts on pointers to #gint, not on #gint
708// directly: if your hash table's keys are of the form
709// `GINT_TO_POINTER (n)`, use g_direct_equal() instead.
710func IntEqual(V1Var uintptr, V2Var uintptr) bool {
711
712 cret := xIntEqual(V1Var, V2Var)
713
714 return cret
715}
716
717var xIntHash func(uintptr) uint
718
719// Converts a pointer to a #gint to a hash value.
720// It can be passed to g_hash_table_new() as the @hash_func parameter,
721// when using non-%NULL pointers to integer values as keys in a #GHashTable.
722//
723// Note that this function acts on pointers to #gint, not on #gint
724// directly: if your hash table's keys are of the form
725// `GINT_TO_POINTER (n)`, use g_direct_hash() instead.
726func IntHash(VVar uintptr) uint {
727
728 cret := xIntHash(VVar)
729
730 return cret
731}
732
733var xStrEqual func(uintptr, uintptr) bool
734
735// Compares two strings for byte-by-byte equality and returns %TRUE
736// if they are equal. It can be passed to g_hash_table_new() as the
737// @key_equal_func parameter, when using non-%NULL strings as keys in a
738// #GHashTable.
739//
740// This function is typically used for hash table comparisons, but can be used
741// for general purpose comparisons of non-%NULL strings. For a %NULL-safe string
742// comparison function, see g_strcmp0().
743func StrEqual(V1Var uintptr, V2Var uintptr) bool {
744
745 cret := xStrEqual(V1Var, V2Var)
746
747 return cret
748}
749
750var xStrHash func(uintptr) uint
751
752// Converts a string to a hash value.
753//
754// This function implements the widely used "djb" hash apparently
755// posted by Daniel Bernstein to comp.lang.c some time ago. The 32
756// bit unsigned hash value starts at 5381 and for each byte 'c' in
757// the string, is updated: `hash = hash * 33 + c`. This function
758// uses the signed value of each byte.
759//
760// It can be passed to g_hash_table_new() as the @hash_func parameter,
761// when using non-%NULL strings as keys in a #GHashTable.
762//
763// Note that this function may not be a perfect fit for all use cases.
764// For example, it produces some hash collisions with strings as short
765// as 2.
766func StrHash(VVar uintptr) uint {
767
768 cret := xStrHash(VVar)
769
770 return cret
771}
772
773func init() {
774 core.SetPackageName("GLIB", "glib-2.0")
775 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
776 var libs []uintptr
777 for _, libPath := range core.GetPaths("GLIB") {
778 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
779 if err != nil {
780 panic(err)
781 }
782 libs = append(libs, lib)
783 }
784
785 core.PuregoSafeRegister(&xDirectEqual, libs, "g_direct_equal")
786 core.PuregoSafeRegister(&xDirectHash, libs, "g_direct_hash")
787 core.PuregoSafeRegister(&xDoubleEqual, libs, "g_double_equal")
788 core.PuregoSafeRegister(&xDoubleHash, libs, "g_double_hash")
789 core.PuregoSafeRegister(&xHashTableAdd, libs, "g_hash_table_add")
790 core.PuregoSafeRegister(&xHashTableContains, libs, "g_hash_table_contains")
791 core.PuregoSafeRegister(&xHashTableDestroy, libs, "g_hash_table_destroy")
792 core.PuregoSafeRegister(&xHashTableFind, libs, "g_hash_table_find")
793 core.PuregoSafeRegister(&xHashTableForeach, libs, "g_hash_table_foreach")
794 core.PuregoSafeRegister(&xHashTableForeachRemove, libs, "g_hash_table_foreach_remove")
795 core.PuregoSafeRegister(&xHashTableForeachSteal, libs, "g_hash_table_foreach_steal")
796 core.PuregoSafeRegister(&xHashTableGetKeysAsPtrArray, libs, "g_hash_table_get_keys_as_ptr_array")
797 core.PuregoSafeRegister(&xHashTableGetValuesAsPtrArray, libs, "g_hash_table_get_values_as_ptr_array")
798 core.PuregoSafeRegister(&xHashTableInsert, libs, "g_hash_table_insert")
799 core.PuregoSafeRegister(&xHashTableLookup, libs, "g_hash_table_lookup")
800 core.PuregoSafeRegister(&xHashTableLookupExtended, libs, "g_hash_table_lookup_extended")
801 core.PuregoSafeRegister(&xHashTableNewSimilar, libs, "g_hash_table_new_similar")
802 core.PuregoSafeRegister(&xHashTableRef, libs, "g_hash_table_ref")
803 core.PuregoSafeRegister(&xHashTableRemove, libs, "g_hash_table_remove")
804 core.PuregoSafeRegister(&xHashTableRemoveAll, libs, "g_hash_table_remove_all")
805 core.PuregoSafeRegister(&xHashTableReplace, libs, "g_hash_table_replace")
806 core.PuregoSafeRegister(&xHashTableSize, libs, "g_hash_table_size")
807 core.PuregoSafeRegister(&xHashTableSteal, libs, "g_hash_table_steal")
808 core.PuregoSafeRegister(&xHashTableStealAll, libs, "g_hash_table_steal_all")
809 core.PuregoSafeRegister(&xHashTableStealAllKeys, libs, "g_hash_table_steal_all_keys")
810 core.PuregoSafeRegister(&xHashTableStealAllValues, libs, "g_hash_table_steal_all_values")
811 core.PuregoSafeRegister(&xHashTableStealExtended, libs, "g_hash_table_steal_extended")
812 core.PuregoSafeRegister(&xHashTableUnref, libs, "g_hash_table_unref")
813 core.PuregoSafeRegister(&xInt64Equal, libs, "g_int64_equal")
814 core.PuregoSafeRegister(&xInt64Hash, libs, "g_int64_hash")
815 core.PuregoSafeRegister(&xIntEqual, libs, "g_int_equal")
816 core.PuregoSafeRegister(&xIntHash, libs, "g_int_hash")
817 core.PuregoSafeRegister(&xStrEqual, libs, "g_str_equal")
818 core.PuregoSafeRegister(&xStrHash, libs, "g_str_hash")
819
820 core.PuregoSafeRegister(&xHashTableGLibType, libs, "g_hash_table_get_type")
821
822 core.PuregoSafeRegister(&xHashTableIterGetHashTable, libs, "g_hash_table_iter_get_hash_table")
823 core.PuregoSafeRegister(&xHashTableIterInit, libs, "g_hash_table_iter_init")
824 core.PuregoSafeRegister(&xHashTableIterNext, libs, "g_hash_table_iter_next")
825 core.PuregoSafeRegister(&xHashTableIterRemove, libs, "g_hash_table_iter_remove")
826 core.PuregoSafeRegister(&xHashTableIterReplace, libs, "g_hash_table_iter_replace")
827 core.PuregoSafeRegister(&xHashTableIterSteal, libs, "g_hash_table_iter_steal")
828
829}