v0.2.2 9100209

gcache.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// Specifies the type of the @value_destroy_func and @key_destroy_func
14// functions passed to g_cache_new(). The functions are passed a
15// pointer to the #GCache key or #GCache value and should free any
16// memory and other resources associated with it.
17type CacheDestroyFunc func(uintptr)
18
19// Specifies the type of the @key_dup_func function passed to
20// g_cache_new(). The function is passed a key
21// (__not__ a value as the prototype implies) and
22// should return a duplicate of the key.
23type CacheDupFunc func(uintptr) uintptr
24
25// Specifies the type of the @value_new_func function passed to
26// g_cache_new(). It is passed a #GCache key and should create the
27// value corresponding to the key.
28type CacheNewFunc func(uintptr) uintptr
29
30// A `GCache` allows sharing of complex data structures, in order to
31// save system resources.
32//
33// `GCache` uses keys and values. A `GCache` key describes the properties
34// of a particular resource. A `GCache` value is the actual resource.
35//
36// `GCache` has been marked as deprecated, since this API is rarely
37// used and not very actively maintained.
38type Cache struct {
39	_ structs.HostLayout
40}
41
42func (x *Cache) GoPointer() uintptr {
43	return uintptr(unsafe.Pointer(x))
44}
45
46var xCacheDestroy func(uintptr)
47
48// Frees the memory allocated for the #GCache.
49//
50// Note that it does not destroy the keys and values which were
51// contained in the #GCache.
52func (x *Cache) Destroy() {
53
54	xCacheDestroy(x.GoPointer())
55
56}
57
58var xCacheInsert func(uintptr, uintptr) uintptr
59
60// Gets the value corresponding to the given key, creating it if
61// necessary. It first checks if the value already exists in the
62// #GCache, by using the @key_equal_func function passed to
63// g_cache_new(). If it does already exist it is returned, and its
64// reference count is increased by one. If the value does not currently
65// exist, if is created by calling the @value_new_func. The key is
66// duplicated by calling @key_dup_func and the duplicated key and value
67// are inserted into the #GCache.
68func (x *Cache) Insert(KeyVar uintptr) uintptr {
69
70	cret := xCacheInsert(x.GoPointer(), KeyVar)
71	return cret
72}
73
74var xCacheKeyForeach func(uintptr, uintptr, uintptr)
75
76// Calls the given function for each of the keys in the #GCache.
77//
78// NOTE @func is passed three parameters, the value and key of a cache
79// entry and the @user_data. The order of value and key is different
80// from the order in which g_hash_table_foreach() passes key-value
81// pairs to its callback function !
82func (x *Cache) KeyForeach(FuncVar *HFunc, UserDataVar uintptr) {
83
84	var FuncVarRef uintptr
85	if FuncVar != nil {
86		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
87		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
88			FuncVarRef = cbRefPtr
89		} else {
90			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
91				cbFn := *FuncVar
92				cbFn(arg0, arg1, arg2)
93			}
94			FuncVarRef = purego.NewCallback(fcb)
95			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
96		}
97	}
98
99	xCacheKeyForeach(x.GoPointer(), FuncVarRef, UserDataVar)
100
101}
102
103var xCacheRemove func(uintptr, uintptr)
104
105// Decreases the reference count of the given value. If it drops to 0
106// then the value and its corresponding key are destroyed, using the
107// @value_destroy_func and @key_destroy_func passed to g_cache_new().
108func (x *Cache) Remove(ValueVar uintptr) {
109
110	xCacheRemove(x.GoPointer(), ValueVar)
111
112}
113
114var xCacheValueForeach func(uintptr, uintptr, uintptr)
115
116// Calls the given function for each of the values in the #GCache.
117func (x *Cache) ValueForeach(FuncVar *HFunc, UserDataVar uintptr) {
118
119	var FuncVarRef uintptr
120	if FuncVar != nil {
121		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
122		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
123			FuncVarRef = cbRefPtr
124		} else {
125			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) {
126				cbFn := *FuncVar
127				cbFn(arg0, arg1, arg2)
128			}
129			FuncVarRef = purego.NewCallback(fcb)
130			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
131		}
132	}
133
134	xCacheValueForeach(x.GoPointer(), FuncVarRef, UserDataVar)
135
136}
137
138func init() {
139	core.SetPackageName("GLIB", "glib-2.0")
140	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
141	var libs []uintptr
142	for _, libPath := range core.GetPaths("GLIB") {
143		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
144		if err != nil {
145			panic(err)
146		}
147		libs = append(libs, lib)
148	}
149
150	core.PuregoSafeRegister(&xCacheDestroy, libs, "g_cache_destroy")
151	core.PuregoSafeRegister(&xCacheInsert, libs, "g_cache_insert")
152	core.PuregoSafeRegister(&xCacheKeyForeach, libs, "g_cache_key_foreach")
153	core.PuregoSafeRegister(&xCacheRemove, libs, "g_cache_remove")
154	core.PuregoSafeRegister(&xCacheValueForeach, libs, "g_cache_value_foreach")
155
156}

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