gtrashstack.go RawHistoryFolder
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 `GTrashStack` is an efficient way to keep a stack of unused allocated
14// memory chunks. Each memory chunk is required to be large enough to hold
15// a `gpointer`. This allows the stack to be maintained without any space
16// overhead, since the stack pointers can be stored inside the memory chunks.
17//
18// There is no function to create a `GTrashStack`. A `NULL` `GTrashStack*`
19// is a perfectly valid empty stack.
20//
21// Each piece of memory that is pushed onto the stack is cast to a
22// `GTrashStack*`.
23//
24// There is no longer any good reason to use `GTrashStack`. If you have
25// extra pieces of memory, `free()` them and allocate them again later.
26type TrashStack struct {
27 _ structs.HostLayout
28
29 Next *TrashStack
30}
31
32func (x *TrashStack) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36var xTrashStackHeight func(**TrashStack) uint
37
38// Returns the height of a #GTrashStack.
39//
40// Note that execution of this function is of O(N) complexity
41// where N denotes the number of items on the stack.
42func TrashStackHeight(StackPVar **TrashStack) uint {
43
44 cret := xTrashStackHeight(StackPVar)
45
46 return cret
47}
48
49var xTrashStackPeek func(**TrashStack) uintptr
50
51// Returns the element at the top of a #GTrashStack
52// which may be %NULL.
53func TrashStackPeek(StackPVar **TrashStack) uintptr {
54
55 cret := xTrashStackPeek(StackPVar)
56
57 return cret
58}
59
60var xTrashStackPop func(**TrashStack) uintptr
61
62// Pops a piece of memory off a #GTrashStack.
63func TrashStackPop(StackPVar **TrashStack) uintptr {
64
65 cret := xTrashStackPop(StackPVar)
66
67 return cret
68}
69
70var xTrashStackPush func(**TrashStack, uintptr)
71
72// Pushes a piece of memory onto a #GTrashStack.
73func TrashStackPush(StackPVar **TrashStack, DataPVar uintptr) {
74
75 xTrashStackPush(StackPVar, DataPVar)
76
77}
78
79func init() {
80 core.SetPackageName("GLIB", "glib-2.0")
81 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
82 var libs []uintptr
83 for _, libPath := range core.GetPaths("GLIB") {
84 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
85 if err != nil {
86 panic(err)
87 }
88 libs = append(libs, lib)
89 }
90
91 core.PuregoSafeRegister(&xTrashStackHeight, libs, "g_trash_stack_height")
92 core.PuregoSafeRegister(&xTrashStackPeek, libs, "g_trash_stack_peek")
93 core.PuregoSafeRegister(&xTrashStackPop, libs, "g_trash_stack_pop")
94 core.PuregoSafeRegister(&xTrashStackPush, libs, "g_trash_stack_push")
95
96}