1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10)
11
12var xAtomicRcBoxAcquire func(uintptr) uintptr
13
14// Atomically acquires a reference on the data pointed by @mem_block.
15func AtomicRcBoxAcquire(MemBlockVar uintptr) uintptr {
16
17 cret := xAtomicRcBoxAcquire(MemBlockVar)
18
19 return cret
20}
21
22var xAtomicRcBoxAlloc func(uint) uintptr
23
24// Allocates @block_size bytes of memory, and adds atomic
25// reference counting semantics to it.
26//
27// The data will be freed when its reference count drops to
28// zero.
29//
30// The allocated data is guaranteed to be suitably aligned for any
31// built-in type.
32func AtomicRcBoxAlloc(BlockSizeVar uint) uintptr {
33
34 cret := xAtomicRcBoxAlloc(BlockSizeVar)
35
36 return cret
37}
38
39var xAtomicRcBoxAlloc0 func(uint) uintptr
40
41// Allocates @block_size bytes of memory, and adds atomic
42// reference counting semantics to it.
43//
44// The contents of the returned data is set to zero.
45//
46// The data will be freed when its reference count drops to
47// zero.
48//
49// The allocated data is guaranteed to be suitably aligned for any
50// built-in type.
51func AtomicRcBoxAlloc0(BlockSizeVar uint) uintptr {
52
53 cret := xAtomicRcBoxAlloc0(BlockSizeVar)
54
55 return cret
56}
57
58var xAtomicRcBoxDup func(uint, uintptr) uintptr
59
60// Allocates a new block of data with atomic reference counting
61// semantics, and copies @block_size bytes of @mem_block
62// into it.
63func AtomicRcBoxDup(BlockSizeVar uint, MemBlockVar uintptr) uintptr {
64
65 cret := xAtomicRcBoxDup(BlockSizeVar, MemBlockVar)
66
67 return cret
68}
69
70var xAtomicRcBoxGetSize func(uintptr) uint
71
72// Retrieves the size of the reference counted data pointed by @mem_block.
73func AtomicRcBoxGetSize(MemBlockVar uintptr) uint {
74
75 cret := xAtomicRcBoxGetSize(MemBlockVar)
76
77 return cret
78}
79
80var xAtomicRcBoxRelease func(uintptr)
81
82// Atomically releases a reference on the data pointed by @mem_block.
83//
84// If the reference was the last one, it will free the
85// resources allocated for @mem_block.
86func AtomicRcBoxRelease(MemBlockVar uintptr) {
87
88 xAtomicRcBoxRelease(MemBlockVar)
89
90}
91
92var xAtomicRcBoxReleaseFull func(uintptr, uintptr)
93
94// Atomically releases a reference on the data pointed by @mem_block.
95//
96// If the reference was the last one, it will call @clear_func
97// to clear the contents of @mem_block, and then will free the
98// resources allocated for @mem_block.
99//
100// Note that implementing weak references via @clear_func is not thread-safe:
101// clearing a pointer to the memory from the callback can race with another
102// thread trying to access it as @mem_block already has a reference count of 0
103// when the callback is called and will be freed.
104func AtomicRcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar *DestroyNotify) {
105
106 var ClearFuncVarRef uintptr
107 if ClearFuncVar != nil {
108 ClearFuncVarPtr := uintptr(unsafe.Pointer(ClearFuncVar))
109 if cbRefPtr, ok := GetCallback(ClearFuncVarPtr); ok {
110 ClearFuncVarRef = cbRefPtr
111 } else {
112 fcb := func(arg0 uintptr) {
113 cbFn := *ClearFuncVar
114 cbFn(arg0)
115 }
116 ClearFuncVarRef = purego.NewCallback(fcb)
117 SaveCallbackWithClosure(ClearFuncVarPtr, ClearFuncVarRef, ClearFuncVar)
118 }
119 }
120
121 xAtomicRcBoxReleaseFull(MemBlockVar, ClearFuncVarRef)
122
123}
124
125var xRcBoxAcquire func(uintptr) uintptr
126
127// Acquires a reference on the data pointed by @mem_block.
128func RcBoxAcquire(MemBlockVar uintptr) uintptr {
129
130 cret := xRcBoxAcquire(MemBlockVar)
131
132 return cret
133}
134
135var xRcBoxAlloc func(uint) uintptr
136
137// Allocates @block_size bytes of memory, and adds reference
138// counting semantics to it.
139//
140// The data will be freed when its reference count drops to
141// zero.
142//
143// The allocated data is guaranteed to be suitably aligned for any
144// built-in type.
145func RcBoxAlloc(BlockSizeVar uint) uintptr {
146
147 cret := xRcBoxAlloc(BlockSizeVar)
148
149 return cret
150}
151
152var xRcBoxAlloc0 func(uint) uintptr
153
154// Allocates @block_size bytes of memory, and adds reference
155// counting semantics to it.
156//
157// The contents of the returned data is set to zero.
158//
159// The data will be freed when its reference count drops to
160// zero.
161//
162// The allocated data is guaranteed to be suitably aligned for any
163// built-in type.
164func RcBoxAlloc0(BlockSizeVar uint) uintptr {
165
166 cret := xRcBoxAlloc0(BlockSizeVar)
167
168 return cret
169}
170
171var xRcBoxDup func(uint, uintptr) uintptr
172
173// Allocates a new block of data with reference counting
174// semantics, and copies @block_size bytes of @mem_block
175// into it.
176func RcBoxDup(BlockSizeVar uint, MemBlockVar uintptr) uintptr {
177
178 cret := xRcBoxDup(BlockSizeVar, MemBlockVar)
179
180 return cret
181}
182
183var xRcBoxGetSize func(uintptr) uint
184
185// Retrieves the size of the reference counted data pointed by @mem_block.
186func RcBoxGetSize(MemBlockVar uintptr) uint {
187
188 cret := xRcBoxGetSize(MemBlockVar)
189
190 return cret
191}
192
193var xRcBoxRelease func(uintptr)
194
195// Releases a reference on the data pointed by @mem_block.
196//
197// If the reference was the last one, it will free the
198// resources allocated for @mem_block.
199func RcBoxRelease(MemBlockVar uintptr) {
200
201 xRcBoxRelease(MemBlockVar)
202
203}
204
205var xRcBoxReleaseFull func(uintptr, uintptr)
206
207// Releases a reference on the data pointed by @mem_block.
208//
209// If the reference was the last one, it will call @clear_func
210// to clear the contents of @mem_block, and then will free the
211// resources allocated for @mem_block.
212func RcBoxReleaseFull(MemBlockVar uintptr, ClearFuncVar *DestroyNotify) {
213
214 var ClearFuncVarRef uintptr
215 if ClearFuncVar != nil {
216 ClearFuncVarPtr := uintptr(unsafe.Pointer(ClearFuncVar))
217 if cbRefPtr, ok := GetCallback(ClearFuncVarPtr); ok {
218 ClearFuncVarRef = cbRefPtr
219 } else {
220 fcb := func(arg0 uintptr) {
221 cbFn := *ClearFuncVar
222 cbFn(arg0)
223 }
224 ClearFuncVarRef = purego.NewCallback(fcb)
225 SaveCallbackWithClosure(ClearFuncVarPtr, ClearFuncVarRef, ClearFuncVar)
226 }
227 }
228
229 xRcBoxReleaseFull(MemBlockVar, ClearFuncVarRef)
230
231}
232
233func init() {
234 core.SetPackageName("GLIB", "glib-2.0")
235 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
236 var libs []uintptr
237 for _, libPath := range core.GetPaths("GLIB") {
238 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
239 if err != nil {
240 panic(err)
241 }
242 libs = append(libs, lib)
243 }
244
245 core.PuregoSafeRegister(&xAtomicRcBoxAcquire, libs, "g_atomic_rc_box_acquire")
246 core.PuregoSafeRegister(&xAtomicRcBoxAlloc, libs, "g_atomic_rc_box_alloc")
247 core.PuregoSafeRegister(&xAtomicRcBoxAlloc0, libs, "g_atomic_rc_box_alloc0")
248 core.PuregoSafeRegister(&xAtomicRcBoxDup, libs, "g_atomic_rc_box_dup")
249 core.PuregoSafeRegister(&xAtomicRcBoxGetSize, libs, "g_atomic_rc_box_get_size")
250 core.PuregoSafeRegister(&xAtomicRcBoxRelease, libs, "g_atomic_rc_box_release")
251 core.PuregoSafeRegister(&xAtomicRcBoxReleaseFull, libs, "g_atomic_rc_box_release_full")
252 core.PuregoSafeRegister(&xRcBoxAcquire, libs, "g_rc_box_acquire")
253 core.PuregoSafeRegister(&xRcBoxAlloc, libs, "g_rc_box_alloc")
254 core.PuregoSafeRegister(&xRcBoxAlloc0, libs, "g_rc_box_alloc0")
255 core.PuregoSafeRegister(&xRcBoxDup, libs, "g_rc_box_dup")
256 core.PuregoSafeRegister(&xRcBoxGetSize, libs, "g_rc_box_get_size")
257 core.PuregoSafeRegister(&xRcBoxRelease, libs, "g_rc_box_release")
258 core.PuregoSafeRegister(&xRcBoxReleaseFull, libs, "g_rc_box_release_full")
259
260}