1// Package gobject was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gobject
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/glib"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15// The type used for callback functions in structure definitions and function
16// signatures.
17//
18// This doesn't mean that all callback functions must take no parameters and
19// return void. The required signature of a callback function is determined by
20// the context in which is used (e.g. the signal to which it is connected).
21//
22// Use G_CALLBACK() to cast the callback function to a #GCallback.
23type Callback func()
24
25// The type used for marshaller functions.
26type ClosureMarshal func(*Closure, *Value, uint, []Value, uintptr, uintptr)
27
28// The type used for the various notification callbacks which can be registered
29// on closures.
30type ClosureNotify func(uintptr, *Closure)
31
32// This is the signature of va_list marshaller functions, an optional
33// marshaller that can be used in some situations to avoid
34// marshalling the signal argument into GValues.
35type VaClosureMarshal func(*Closure, *Value, *TypeInstance, []interface{}, uintptr, int, []types.GType)
36
37// A #GCClosure is a specialization of #GClosure for C function callbacks.
38type CClosure struct {
39 _ structs.HostLayout
40
41 Closure uintptr
42
43 Callback uintptr
44}
45
46func (x *CClosure) GoPointer() uintptr {
47 return uintptr(unsafe.Pointer(x))
48}
49
50// A `GClosure` represents a callback supplied by the programmer.
51//
52// It will generally comprise a function of some kind and a marshaller
53// used to call it. It is the responsibility of the marshaller to
54// convert the arguments for the invocation from #GValues into
55// a suitable form, perform the callback on the converted arguments,
56// and transform the return value back into a #GValue.
57//
58// In the case of C programs, a closure usually just holds a pointer
59// to a function and maybe a data argument, and the marshaller
60// converts between #GValue and native C types. The GObject
61// library provides the #GCClosure type for this purpose. Bindings for
62// other languages need marshallers which convert between #GValues
63// and suitable representations in the runtime of the language in
64// order to use functions written in that language as callbacks. Use
65// g_closure_set_marshal() to set the marshaller on such a custom
66// closure implementation.
67//
68// Within GObject, closures play an important role in the
69// implementation of signals. When a signal is registered, the
70// @c_marshaller argument to g_signal_new() specifies the default C
71// marshaller for any closure which is connected to this
72// signal. GObject provides a number of C marshallers for this
73// purpose, see the g_cclosure_marshal_*() functions. Additional C
74// marshallers can be generated with the [glib-genmarshal][glib-genmarshal]
75// utility. Closures can be explicitly connected to signals with
76// g_signal_connect_closure(), but it usually more convenient to let
77// GObject create a closure automatically by using one of the
78// g_signal_connect_*() functions which take a callback function/user
79// data pair.
80//
81// Using closures has a number of important advantages over a simple
82// callback function/data pointer combination:
83//
84// - Closures allow the callee to get the types of the callback parameters,
85// which means that language bindings don't have to write individual glue
86// for each callback type.
87//
88// - The reference counting of #GClosure makes it easy to handle reentrancy
89// right; if a callback is removed while it is being invoked, the closure
90// and its parameters won't be freed until the invocation finishes.
91//
92// - g_closure_invalidate() and invalidation notifiers allow callbacks to be
93// automatically removed when the objects they point to go away.
94type Closure struct {
95 _ structs.HostLayout
96
97 RefCount uint
98
99 MetaMarshalNouse uint
100
101 NGuards uint
102
103 NFnotifiers uint
104
105 NInotifiers uint
106
107 InInotify uint
108
109 Floating uint
110
111 DerivativeFlag uint
112
113 InMarshal uint
114
115 IsInvalid uint
116
117 xMarshal uintptr
118
119 Data uintptr
120
121 Notifiers *ClosureNotifyData
122}
123
124var xClosureGLibType func() types.GType
125
126func ClosureGLibType() types.GType {
127 return xClosureGLibType()
128}
129
130func (x *Closure) GoPointer() uintptr {
131 return uintptr(unsafe.Pointer(x))
132}
133
134var xNewClosureObject func(uint, uintptr) *Closure
135
136// A variant of g_closure_new_simple() which stores @object in the
137// @data field of the closure and calls g_object_watch_closure() on
138// @object and the created closure. This function is mainly useful
139// when implementing new types of closures.
140func NewClosureObject(SizeofClosureVar uint, ObjectVar *Object) *Closure {
141
142 cret := xNewClosureObject(SizeofClosureVar, ObjectVar.GoPointer())
143 return cret
144}
145
146var xNewClosureSimple func(uint, uintptr) *Closure
147
148// Allocates a struct of the given size and initializes the initial
149// part as a #GClosure.
150//
151// This function is mainly useful when implementing new types of closures:
152//
153// |[<!-- language="C" -->
154// typedef struct _MyClosure MyClosure;
155// struct _MyClosure
156//
157// {
158// GClosure closure;
159// // extra data goes here
160// };
161//
162// static void
163// my_closure_finalize (gpointer notify_data,
164//
165// GClosure *closure)
166//
167// {
168// MyClosure *my_closure = (MyClosure *)closure;
169//
170// // free extra data here
171// }
172//
173// MyClosure *my_closure_new (gpointer data)
174//
175// {
176// GClosure *closure;
177// MyClosure *my_closure;
178//
179// closure = g_closure_new_simple (sizeof (MyClosure), data);
180// my_closure = (MyClosure *) closure;
181//
182// // initialize extra data here
183//
184// g_closure_add_finalize_notifier (closure, notify_data,
185// my_closure_finalize);
186// return my_closure;
187// }
188//
189// ]|
190func NewClosureSimple(SizeofClosureVar uint, DataVar uintptr) *Closure {
191
192 cret := xNewClosureSimple(SizeofClosureVar, DataVar)
193 return cret
194}
195
196var xClosureAddFinalizeNotifier func(uintptr, uintptr, uintptr)
197
198// Registers a finalization notifier which will be called when the
199// reference count of @closure goes down to 0.
200//
201// Multiple finalization notifiers on a single closure are invoked in
202// unspecified order. If a single call to g_closure_unref() results in
203// the closure being both invalidated and finalized, then the invalidate
204// notifiers will be run before the finalize notifiers.
205func (x *Closure) AddFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) {
206
207 var NotifyFuncVarRef uintptr
208 if NotifyFuncVar != nil {
209 NotifyFuncVarPtr := uintptr(unsafe.Pointer(NotifyFuncVar))
210 if cbRefPtr, ok := glib.GetCallback(NotifyFuncVarPtr); ok {
211 NotifyFuncVarRef = cbRefPtr
212 } else {
213 fcb := func(arg0 uintptr, arg1 *Closure) {
214 cbFn := *NotifyFuncVar
215 cbFn(arg0, arg1)
216 }
217 NotifyFuncVarRef = purego.NewCallback(fcb)
218 glib.SaveCallbackWithClosure(NotifyFuncVarPtr, NotifyFuncVarRef, NotifyFuncVar)
219 }
220 }
221
222 xClosureAddFinalizeNotifier(x.GoPointer(), NotifyDataVar, NotifyFuncVarRef)
223
224}
225
226var xClosureAddInvalidateNotifier func(uintptr, uintptr, uintptr)
227
228// Registers an invalidation notifier which will be called when the
229// @closure is invalidated with g_closure_invalidate().
230//
231// Invalidation notifiers are invoked before finalization notifiers,
232// in an unspecified order.
233func (x *Closure) AddInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) {
234
235 var NotifyFuncVarRef uintptr
236 if NotifyFuncVar != nil {
237 NotifyFuncVarPtr := uintptr(unsafe.Pointer(NotifyFuncVar))
238 if cbRefPtr, ok := glib.GetCallback(NotifyFuncVarPtr); ok {
239 NotifyFuncVarRef = cbRefPtr
240 } else {
241 fcb := func(arg0 uintptr, arg1 *Closure) {
242 cbFn := *NotifyFuncVar
243 cbFn(arg0, arg1)
244 }
245 NotifyFuncVarRef = purego.NewCallback(fcb)
246 glib.SaveCallbackWithClosure(NotifyFuncVarPtr, NotifyFuncVarRef, NotifyFuncVar)
247 }
248 }
249
250 xClosureAddInvalidateNotifier(x.GoPointer(), NotifyDataVar, NotifyFuncVarRef)
251
252}
253
254var xClosureAddMarshalGuards func(uintptr, uintptr, uintptr, uintptr, uintptr)
255
256// Adds a pair of notifiers which get invoked before and after the
257// closure callback, respectively.
258//
259// This is typically used to protect the extra arguments for the
260// duration of the callback. See g_object_watch_closure() for an
261// example of marshal guards.
262func (x *Closure) AddMarshalGuards(PreMarshalDataVar uintptr, PreMarshalNotifyVar *ClosureNotify, PostMarshalDataVar uintptr, PostMarshalNotifyVar *ClosureNotify) {
263
264 var PreMarshalNotifyVarRef uintptr
265 if PreMarshalNotifyVar != nil {
266 PreMarshalNotifyVarPtr := uintptr(unsafe.Pointer(PreMarshalNotifyVar))
267 if cbRefPtr, ok := glib.GetCallback(PreMarshalNotifyVarPtr); ok {
268 PreMarshalNotifyVarRef = cbRefPtr
269 } else {
270 fcb := func(arg0 uintptr, arg1 *Closure) {
271 cbFn := *PreMarshalNotifyVar
272 cbFn(arg0, arg1)
273 }
274 PreMarshalNotifyVarRef = purego.NewCallback(fcb)
275 glib.SaveCallbackWithClosure(PreMarshalNotifyVarPtr, PreMarshalNotifyVarRef, PreMarshalNotifyVar)
276 }
277 }
278
279 var PostMarshalNotifyVarRef uintptr
280 if PostMarshalNotifyVar != nil {
281 PostMarshalNotifyVarPtr := uintptr(unsafe.Pointer(PostMarshalNotifyVar))
282 if cbRefPtr, ok := glib.GetCallback(PostMarshalNotifyVarPtr); ok {
283 PostMarshalNotifyVarRef = cbRefPtr
284 } else {
285 fcb := func(arg0 uintptr, arg1 *Closure) {
286 cbFn := *PostMarshalNotifyVar
287 cbFn(arg0, arg1)
288 }
289 PostMarshalNotifyVarRef = purego.NewCallback(fcb)
290 glib.SaveCallbackWithClosure(PostMarshalNotifyVarPtr, PostMarshalNotifyVarRef, PostMarshalNotifyVar)
291 }
292 }
293
294 xClosureAddMarshalGuards(x.GoPointer(), PreMarshalDataVar, PreMarshalNotifyVarRef, PostMarshalDataVar, PostMarshalNotifyVarRef)
295
296}
297
298var xClosureInvalidate func(uintptr)
299
300// Sets a flag on the closure to indicate that its calling
301// environment has become invalid, and thus causes any future
302// invocations of g_closure_invoke() on this @closure to be
303// ignored.
304//
305// Also, invalidation notifiers installed on the closure will
306// be called at this point. Note that unless you are holding a
307// reference to the closure yourself, the invalidation notifiers may
308// unref the closure and cause it to be destroyed, so if you need to
309// access the closure after calling g_closure_invalidate(), make sure
310// that you've previously called g_closure_ref().
311//
312// Note that g_closure_invalidate() will also be called when the
313// reference count of a closure drops to zero (unless it has already
314// been invalidated before).
315func (x *Closure) Invalidate() {
316
317 xClosureInvalidate(x.GoPointer())
318
319}
320
321var xClosureInvoke func(uintptr, *Value, uint, []Value, uintptr)
322
323// Invokes the closure, i.e. executes the callback represented by the @closure.
324func (x *Closure) Invoke(ReturnValueVar *Value, NParamValuesVar uint, ParamValuesVar []Value, InvocationHintVar uintptr) {
325
326 xClosureInvoke(x.GoPointer(), ReturnValueVar, NParamValuesVar, ParamValuesVar, InvocationHintVar)
327
328}
329
330var xClosureRef func(uintptr) *Closure
331
332// Increments the reference count on a closure to force it staying
333// alive while the caller holds a pointer to it.
334func (x *Closure) Ref() *Closure {
335
336 cret := xClosureRef(x.GoPointer())
337 return cret
338}
339
340var xClosureRemoveFinalizeNotifier func(uintptr, uintptr, uintptr)
341
342// Removes a finalization notifier.
343//
344// Notice that notifiers are automatically removed after they are run.
345func (x *Closure) RemoveFinalizeNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) {
346
347 var NotifyFuncVarRef uintptr
348 if NotifyFuncVar != nil {
349 NotifyFuncVarPtr := uintptr(unsafe.Pointer(NotifyFuncVar))
350 if cbRefPtr, ok := glib.GetCallback(NotifyFuncVarPtr); ok {
351 NotifyFuncVarRef = cbRefPtr
352 } else {
353 fcb := func(arg0 uintptr, arg1 *Closure) {
354 cbFn := *NotifyFuncVar
355 cbFn(arg0, arg1)
356 }
357 NotifyFuncVarRef = purego.NewCallback(fcb)
358 glib.SaveCallbackWithClosure(NotifyFuncVarPtr, NotifyFuncVarRef, NotifyFuncVar)
359 }
360 }
361
362 xClosureRemoveFinalizeNotifier(x.GoPointer(), NotifyDataVar, NotifyFuncVarRef)
363
364}
365
366var xClosureRemoveInvalidateNotifier func(uintptr, uintptr, uintptr)
367
368// Removes an invalidation notifier.
369//
370// Notice that notifiers are automatically removed after they are run.
371func (x *Closure) RemoveInvalidateNotifier(NotifyDataVar uintptr, NotifyFuncVar *ClosureNotify) {
372
373 var NotifyFuncVarRef uintptr
374 if NotifyFuncVar != nil {
375 NotifyFuncVarPtr := uintptr(unsafe.Pointer(NotifyFuncVar))
376 if cbRefPtr, ok := glib.GetCallback(NotifyFuncVarPtr); ok {
377 NotifyFuncVarRef = cbRefPtr
378 } else {
379 fcb := func(arg0 uintptr, arg1 *Closure) {
380 cbFn := *NotifyFuncVar
381 cbFn(arg0, arg1)
382 }
383 NotifyFuncVarRef = purego.NewCallback(fcb)
384 glib.SaveCallbackWithClosure(NotifyFuncVarPtr, NotifyFuncVarRef, NotifyFuncVar)
385 }
386 }
387
388 xClosureRemoveInvalidateNotifier(x.GoPointer(), NotifyDataVar, NotifyFuncVarRef)
389
390}
391
392var xClosureSetMarshal func(uintptr, uintptr)
393
394// Sets the marshaller of @closure.
395//
396// The `marshal_data` of @marshal provides a way for a meta marshaller to
397// provide additional information to the marshaller.
398//
399// For GObject's C predefined marshallers (the `g_cclosure_marshal_*()`
400// functions), what it provides is a callback function to use instead of
401// @closure->callback.
402//
403// See also: g_closure_set_meta_marshal()
404func (x *Closure) SetMarshal(MarshalVar *ClosureMarshal) {
405
406 var MarshalVarRef uintptr
407 if MarshalVar != nil {
408 MarshalVarPtr := uintptr(unsafe.Pointer(MarshalVar))
409 if cbRefPtr, ok := glib.GetCallback(MarshalVarPtr); ok {
410 MarshalVarRef = cbRefPtr
411 } else {
412 fcb := func(arg0 *Closure, arg1 *Value, arg2 uint, arg3 []Value, arg4 uintptr, arg5 uintptr) {
413 cbFn := *MarshalVar
414 cbFn(arg0, arg1, arg2, arg3, arg4, arg5)
415 }
416 MarshalVarRef = purego.NewCallback(fcb)
417 glib.SaveCallbackWithClosure(MarshalVarPtr, MarshalVarRef, MarshalVar)
418 }
419 }
420
421 xClosureSetMarshal(x.GoPointer(), MarshalVarRef)
422
423}
424
425var xClosureSetMetaMarshal func(uintptr, uintptr, uintptr)
426
427// Sets the meta marshaller of @closure.
428//
429// A meta marshaller wraps the @closure's marshal and modifies the way
430// it is called in some fashion. The most common use of this facility
431// is for C callbacks.
432//
433// The same marshallers (generated by [glib-genmarshal][glib-genmarshal]),
434// are used everywhere, but the way that we get the callback function
435// differs. In most cases we want to use the @closure's callback, but in
436// other cases we want to use some different technique to retrieve the
437// callback function.
438//
439// For example, class closures for signals (see
440// g_signal_type_cclosure_new()) retrieve the callback function from a
441// fixed offset in the class structure. The meta marshaller retrieves
442// the right callback and passes it to the marshaller as the
443// @marshal_data argument.
444func (x *Closure) SetMetaMarshal(MarshalDataVar uintptr, MetaMarshalVar *ClosureMarshal) {
445
446 var MetaMarshalVarRef uintptr
447 if MetaMarshalVar != nil {
448 MetaMarshalVarPtr := uintptr(unsafe.Pointer(MetaMarshalVar))
449 if cbRefPtr, ok := glib.GetCallback(MetaMarshalVarPtr); ok {
450 MetaMarshalVarRef = cbRefPtr
451 } else {
452 fcb := func(arg0 *Closure, arg1 *Value, arg2 uint, arg3 []Value, arg4 uintptr, arg5 uintptr) {
453 cbFn := *MetaMarshalVar
454 cbFn(arg0, arg1, arg2, arg3, arg4, arg5)
455 }
456 MetaMarshalVarRef = purego.NewCallback(fcb)
457 glib.SaveCallbackWithClosure(MetaMarshalVarPtr, MetaMarshalVarRef, MetaMarshalVar)
458 }
459 }
460
461 xClosureSetMetaMarshal(x.GoPointer(), MarshalDataVar, MetaMarshalVarRef)
462
463}
464
465var xClosureSink func(uintptr)
466
467// Takes over the initial ownership of a closure.
468//
469// Each closure is initially created in a "floating" state, which means
470// that the initial reference count is not owned by any caller.
471//
472// This function checks to see if the object is still floating, and if so,
473// unsets the floating state and decreases the reference count. If the
474// closure is not floating, g_closure_sink() does nothing.
475//
476// The reason for the existence of the floating state is to prevent
477// cumbersome code sequences like:
478//
479// |[<!-- language="C" -->
480// closure = g_cclosure_new (cb_func, cb_data);
481// g_source_set_closure (source, closure);
482// g_closure_unref (closure); // GObject doesn't really need this
483// ]|
484//
485// Because g_source_set_closure() (and similar functions) take ownership of the
486// initial reference count, if it is unowned, we instead can write:
487//
488// |[<!-- language="C" -->
489// g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
490// ]|
491//
492// Generally, this function is used together with g_closure_ref(). An example
493// of storing a closure for later notification looks like:
494//
495// |[<!-- language="C" -->
496// static GClosure *notify_closure = NULL;
497// void
498// foo_notify_set_closure (GClosure *closure)
499//
500// {
501// if (notify_closure)
502// g_closure_unref (notify_closure);
503// notify_closure = closure;
504// if (notify_closure)
505// {
506// g_closure_ref (notify_closure);
507// g_closure_sink (notify_closure);
508// }
509// }
510//
511// ]|
512//
513// Because g_closure_sink() may decrement the reference count of a closure
514// (if it hasn't been called on @closure yet) just like g_closure_unref(),
515// g_closure_ref() should be called prior to this function.
516func (x *Closure) Sink() {
517
518 xClosureSink(x.GoPointer())
519
520}
521
522var xClosureUnref func(uintptr)
523
524// Decrements the reference count of a closure after it was previously
525// incremented by the same caller.
526//
527// If no other callers are using the closure, then the closure will be
528// destroyed and freed.
529func (x *Closure) Unref() {
530
531 xClosureUnref(x.GoPointer())
532
533}
534
535// OverrideMarshal sets the "marshal" callback function.
536func (x *Closure) OverrideMarshal(cb func(*Closure, *Value, uint, *Value, uintptr, uintptr)) {
537 if cb == nil {
538 x.xMarshal = 0
539 } else {
540 x.xMarshal = purego.NewCallback(func(ClosureVarp *Closure, ReturnValueVarp *Value, NParamValuesVarp uint, ParamValuesVarp *Value, InvocationHintVarp uintptr, MarshalDataVarp uintptr) {
541 cb(ClosureVarp, ReturnValueVarp, NParamValuesVarp, ParamValuesVarp, InvocationHintVarp, MarshalDataVarp)
542 })
543 }
544}
545
546// GetMarshal gets the "marshal" callback function.
547func (x *Closure) GetMarshal() func(*Closure, *Value, uint, *Value, uintptr, uintptr) {
548 if x.xMarshal == 0 {
549 return nil
550 }
551 var rawCallback func(ClosureVarp *Closure, ReturnValueVarp *Value, NParamValuesVarp uint, ParamValuesVarp *Value, InvocationHintVarp uintptr, MarshalDataVarp uintptr)
552 purego.RegisterFunc(&rawCallback, x.xMarshal)
553 return func(ClosureVar *Closure, ReturnValueVar *Value, NParamValuesVar uint, ParamValuesVar *Value, InvocationHintVar uintptr, MarshalDataVar uintptr) {
554 rawCallback(ClosureVar, ReturnValueVar, NParamValuesVar, ParamValuesVar, InvocationHintVar, MarshalDataVar)
555 }
556}
557
558type ClosureNotifyData struct {
559 _ structs.HostLayout
560
561 Data uintptr
562
563 Notify ClosureNotify
564}
565
566func (x *ClosureNotifyData) GoPointer() uintptr {
567 return uintptr(unsafe.Pointer(x))
568}
569
570var xCclosureMarshalGeneric func(*Closure, *Value, uint, *Value, uintptr, uintptr)
571
572// A generic marshaller function implemented via
573// [libffi](http://sourceware.org/libffi/).
574//
575// Normally this function is not passed explicitly to g_signal_new(),
576// but used automatically by GLib when specifying a %NULL marshaller.
577func CclosureMarshalGeneric(ClosureVar *Closure, ReturnGvalueVar *Value, NParamValuesVar uint, ParamValuesVar *Value, InvocationHintVar uintptr, MarshalDataVar uintptr) {
578
579 xCclosureMarshalGeneric(ClosureVar, ReturnGvalueVar, NParamValuesVar, ParamValuesVar, InvocationHintVar, MarshalDataVar)
580
581}
582
583var xCclosureNew func(uintptr, uintptr, uintptr) *Closure
584
585// Creates a new closure which invokes @callback_func with @user_data as
586// the last parameter.
587//
588// @destroy_data will be called as a finalize notifier on the #GClosure.
589func CclosureNew(CallbackFuncVar *Callback, UserDataVar uintptr, DestroyDataVar *ClosureNotify) *Closure {
590
591 var CallbackFuncVarRef uintptr
592 if CallbackFuncVar != nil {
593 CallbackFuncVarPtr := uintptr(unsafe.Pointer(CallbackFuncVar))
594 if cbRefPtr, ok := glib.GetCallback(CallbackFuncVarPtr); ok {
595 CallbackFuncVarRef = cbRefPtr
596 } else {
597 fcb := func() {
598 cbFn := *CallbackFuncVar
599 cbFn()
600 }
601 CallbackFuncVarRef = purego.NewCallback(fcb)
602 glib.SaveCallbackWithClosure(CallbackFuncVarPtr, CallbackFuncVarRef, CallbackFuncVar)
603 }
604 }
605
606 var DestroyDataVarRef uintptr
607 if DestroyDataVar != nil {
608 DestroyDataVarPtr := uintptr(unsafe.Pointer(DestroyDataVar))
609 if cbRefPtr, ok := glib.GetCallback(DestroyDataVarPtr); ok {
610 DestroyDataVarRef = cbRefPtr
611 } else {
612 fcb := func(arg0 uintptr, arg1 *Closure) {
613 cbFn := *DestroyDataVar
614 cbFn(arg0, arg1)
615 }
616 DestroyDataVarRef = purego.NewCallback(fcb)
617 glib.SaveCallbackWithClosure(DestroyDataVarPtr, DestroyDataVarRef, DestroyDataVar)
618 }
619 }
620
621 cret := xCclosureNew(CallbackFuncVarRef, UserDataVar, DestroyDataVarRef)
622 return cret
623}
624
625var xCclosureNewSwap func(uintptr, uintptr, uintptr) *Closure
626
627// Creates a new closure which invokes @callback_func with @user_data as
628// the first parameter.
629//
630// @destroy_data will be called as a finalize notifier on the #GClosure.
631func CclosureNewSwap(CallbackFuncVar *Callback, UserDataVar uintptr, DestroyDataVar *ClosureNotify) *Closure {
632
633 var CallbackFuncVarRef uintptr
634 if CallbackFuncVar != nil {
635 CallbackFuncVarPtr := uintptr(unsafe.Pointer(CallbackFuncVar))
636 if cbRefPtr, ok := glib.GetCallback(CallbackFuncVarPtr); ok {
637 CallbackFuncVarRef = cbRefPtr
638 } else {
639 fcb := func() {
640 cbFn := *CallbackFuncVar
641 cbFn()
642 }
643 CallbackFuncVarRef = purego.NewCallback(fcb)
644 glib.SaveCallbackWithClosure(CallbackFuncVarPtr, CallbackFuncVarRef, CallbackFuncVar)
645 }
646 }
647
648 var DestroyDataVarRef uintptr
649 if DestroyDataVar != nil {
650 DestroyDataVarPtr := uintptr(unsafe.Pointer(DestroyDataVar))
651 if cbRefPtr, ok := glib.GetCallback(DestroyDataVarPtr); ok {
652 DestroyDataVarRef = cbRefPtr
653 } else {
654 fcb := func(arg0 uintptr, arg1 *Closure) {
655 cbFn := *DestroyDataVar
656 cbFn(arg0, arg1)
657 }
658 DestroyDataVarRef = purego.NewCallback(fcb)
659 glib.SaveCallbackWithClosure(DestroyDataVarPtr, DestroyDataVarRef, DestroyDataVar)
660 }
661 }
662
663 cret := xCclosureNewSwap(CallbackFuncVarRef, UserDataVar, DestroyDataVarRef)
664 return cret
665}
666
667var xSignalTypeCclosureNew func(types.GType, uint) *Closure
668
669// Creates a new closure which invokes the function found at the offset
670// @struct_offset in the class structure of the interface or classed type
671// identified by @itype.
672func SignalTypeCclosureNew(ItypeVar types.GType, StructOffsetVar uint) *Closure {
673
674 cret := xSignalTypeCclosureNew(ItypeVar, StructOffsetVar)
675 return cret
676}
677
678func init() {
679 core.SetPackageName("GOBJECT", "gobject-2.0")
680 core.SetSharedLibraries("GOBJECT", []string{"libgobject-2.0.so.0"})
681 var libs []uintptr
682 for _, libPath := range core.GetPaths("GOBJECT") {
683 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
684 if err != nil {
685 panic(err)
686 }
687 libs = append(libs, lib)
688 }
689
690 core.PuregoSafeRegister(&xCclosureMarshalGeneric, libs, "g_cclosure_marshal_generic")
691 core.PuregoSafeRegister(&xCclosureNew, libs, "g_cclosure_new")
692 core.PuregoSafeRegister(&xCclosureNewSwap, libs, "g_cclosure_new_swap")
693 core.PuregoSafeRegister(&xSignalTypeCclosureNew, libs, "g_signal_type_cclosure_new")
694
695 core.PuregoSafeRegister(&xClosureGLibType, libs, "g_closure_get_type")
696
697 core.PuregoSafeRegister(&xNewClosureObject, libs, "g_closure_new_object")
698 core.PuregoSafeRegister(&xNewClosureSimple, libs, "g_closure_new_simple")
699
700 core.PuregoSafeRegister(&xClosureAddFinalizeNotifier, libs, "g_closure_add_finalize_notifier")
701 core.PuregoSafeRegister(&xClosureAddInvalidateNotifier, libs, "g_closure_add_invalidate_notifier")
702 core.PuregoSafeRegister(&xClosureAddMarshalGuards, libs, "g_closure_add_marshal_guards")
703 core.PuregoSafeRegister(&xClosureInvalidate, libs, "g_closure_invalidate")
704 core.PuregoSafeRegister(&xClosureInvoke, libs, "g_closure_invoke")
705 core.PuregoSafeRegister(&xClosureRef, libs, "g_closure_ref")
706 core.PuregoSafeRegister(&xClosureRemoveFinalizeNotifier, libs, "g_closure_remove_finalize_notifier")
707 core.PuregoSafeRegister(&xClosureRemoveInvalidateNotifier, libs, "g_closure_remove_invalidate_notifier")
708 core.PuregoSafeRegister(&xClosureSetMarshal, libs, "g_closure_set_marshal")
709 core.PuregoSafeRegister(&xClosureSetMetaMarshal, libs, "g_closure_set_meta_marshal")
710 core.PuregoSafeRegister(&xClosureSink, libs, "g_closure_sink")
711 core.PuregoSafeRegister(&xClosureUnref, libs, "g_closure_unref")
712
713}