1// Package gobject was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gobject
3
4import (
5 "unsafe"
6
7 "github.com/ebitengine/purego"
8
9 "github.com/bnema/puregotk/pkg/core"
10 "github.com/bnema/puregotk/v4/glib"
11 "github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// This function is provided by the user and should produce a copy
15// of the passed in boxed structure.
16type BoxedCopyFunc func(uintptr) uintptr
17
18// This function is provided by the user and should free the boxed
19// structure passed.
20type BoxedFreeFunc func(uintptr)
21
22var xBoxedCopy func(types.GType, uintptr) uintptr
23
24// Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
25func BoxedCopy(BoxedTypeVar types.GType, SrcBoxedVar uintptr) uintptr {
26
27 cret := xBoxedCopy(BoxedTypeVar, SrcBoxedVar)
28 return cret
29}
30
31var xBoxedFree func(types.GType, uintptr)
32
33// Free the boxed structure @boxed which is of type @boxed_type.
34func BoxedFree(BoxedTypeVar types.GType, BoxedVar uintptr) {
35
36 xBoxedFree(BoxedTypeVar, BoxedVar)
37
38}
39
40var xBoxedTypeRegisterStatic func(string, uintptr, uintptr) types.GType
41
42// This function creates a new %G_TYPE_BOXED derived type id for a new
43// boxed type with name @name.
44//
45// Boxed type handling functions have to be provided to copy and free
46// opaque boxed structures of this type.
47//
48// For the general case, it is recommended to use G_DEFINE_BOXED_TYPE()
49// instead of calling g_boxed_type_register_static() directly. The macro
50// will create the appropriate `*_get_type()` function for the boxed type.
51func BoxedTypeRegisterStatic(NameVar string, BoxedCopyVar *BoxedCopyFunc, BoxedFreeVar *BoxedFreeFunc) types.GType {
52
53 var BoxedCopyVarRef uintptr
54 if BoxedCopyVar != nil {
55 BoxedCopyVarPtr := uintptr(unsafe.Pointer(BoxedCopyVar))
56 if cbRefPtr, ok := glib.GetCallback(BoxedCopyVarPtr); ok {
57 BoxedCopyVarRef = cbRefPtr
58 } else {
59 fcb := func(arg0 uintptr) uintptr {
60 cbFn := *BoxedCopyVar
61 return cbFn(arg0)
62 }
63 BoxedCopyVarRef = purego.NewCallback(fcb)
64 glib.SaveCallbackWithClosure(BoxedCopyVarPtr, BoxedCopyVarRef, BoxedCopyVar)
65 }
66 }
67
68 var BoxedFreeVarRef uintptr
69 if BoxedFreeVar != nil {
70 BoxedFreeVarPtr := uintptr(unsafe.Pointer(BoxedFreeVar))
71 if cbRefPtr, ok := glib.GetCallback(BoxedFreeVarPtr); ok {
72 BoxedFreeVarRef = cbRefPtr
73 } else {
74 fcb := func(arg0 uintptr) {
75 cbFn := *BoxedFreeVar
76 cbFn(arg0)
77 }
78 BoxedFreeVarRef = purego.NewCallback(fcb)
79 glib.SaveCallbackWithClosure(BoxedFreeVarPtr, BoxedFreeVarRef, BoxedFreeVar)
80 }
81 }
82
83 cret := xBoxedTypeRegisterStatic(NameVar, BoxedCopyVarRef, BoxedFreeVarRef)
84 return cret
85}
86
87func init() {
88 core.SetPackageName("GOBJECT", "gobject-2.0")
89 core.SetSharedLibraries("GOBJECT", []string{"libgobject-2.0.so.0"})
90 var libs []uintptr
91 for _, libPath := range core.GetPaths("GOBJECT") {
92 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
93 if err != nil {
94 panic(err)
95 }
96 libs = append(libs, lib)
97 }
98
99 core.PuregoSafeRegister(&xBoxedCopy, libs, "g_boxed_copy")
100 core.PuregoSafeRegister(&xBoxedFree, libs, "g_boxed_free")
101 core.PuregoSafeRegister(&xBoxedTypeRegisterStatic, libs, "g_boxed_type_register_static")
102
103}