1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8)
9
10// A GQuark is a non-zero integer which uniquely identifies a
11// particular string.
12//
13// A GQuark value of zero is associated to `NULL`.
14//
15// Given either the string or the `GQuark` identifier it is possible to
16// retrieve the other.
17//
18// Quarks are used for both
19// [datasets and keyed data lists](datalist-and-dataset.html).
20//
21// To create a new quark from a string, use [func@GLib.quark_from_string]
22// or [func@GLib.quark_from_static_string].
23//
24// To find the string corresponding to a given `GQuark`, use
25// [func@GLib.quark_to_string].
26//
27// To find the `GQuark` corresponding to a given string, use
28// [func@GLib.quark_try_string].
29//
30// Another use for the string pool maintained for the quark functions
31// is string interning, using [func@GLib.intern_string] or
32// [func@GLib.intern_static_string]. An interned string is a canonical
33// representation for a string. One important advantage of interned
34// strings is that they can be compared for equality by a simple
35// pointer comparison, rather than using `strcmp()`.
36type Quark = uint32
37
38var xInternStaticString func(uintptr) string
39
40// Returns a canonical representation for @string. Interned strings
41// can be compared for equality by comparing the pointers, instead of
42// using strcmp(). g_intern_static_string() does not copy the string,
43// therefore @string must not be freed or modified.
44//
45// This function must not be used before library constructors have finished
46// running. In particular, this means it cannot be used to initialize global
47// variables in C++.
48func InternStaticString(StringVar *string) string {
49
50 StringVarPtr := core.GStrdupNullable(StringVar)
51 defer core.GFreeNullable(StringVarPtr)
52
53 cret := xInternStaticString(StringVarPtr)
54
55 return cret
56}
57
58var xInternString func(uintptr) string
59
60// Returns a canonical representation for @string. Interned strings
61// can be compared for equality by comparing the pointers, instead of
62// using strcmp().
63//
64// This function must not be used before library constructors have finished
65// running. In particular, this means it cannot be used to initialize global
66// variables in C++.
67func InternString(StringVar *string) string {
68
69 StringVarPtr := core.GStrdupNullable(StringVar)
70 defer core.GFreeNullable(StringVarPtr)
71
72 cret := xInternString(StringVarPtr)
73
74 return cret
75}
76
77var xQuarkFromStaticString func(uintptr) Quark
78
79// Gets the #GQuark identifying the given (static) string. If the
80// string does not currently have an associated #GQuark, a new #GQuark
81// is created, linked to the given string.
82//
83// Note that this function is identical to g_quark_from_string() except
84// that if a new #GQuark is created the string itself is used rather
85// than a copy. This saves memory, but can only be used if the string
86// will continue to exist until the program terminates. It can be used
87// with statically allocated strings in the main program, but not with
88// statically allocated memory in dynamically loaded modules, if you
89// expect to ever unload the module again (e.g. do not use this
90// function in GTK theme engines).
91//
92// This function must not be used before library constructors have finished
93// running. In particular, this means it cannot be used to initialize global
94// variables in C++.
95func QuarkFromStaticString(StringVar *string) Quark {
96
97 StringVarPtr := core.GStrdupNullable(StringVar)
98 defer core.GFreeNullable(StringVarPtr)
99
100 cret := xQuarkFromStaticString(StringVarPtr)
101
102 return cret
103}
104
105var xQuarkFromString func(uintptr) Quark
106
107// Gets the #GQuark identifying the given string. If the string does
108// not currently have an associated #GQuark, a new #GQuark is created,
109// using a copy of the string.
110//
111// This function must not be used before library constructors have finished
112// running. In particular, this means it cannot be used to initialize global
113// variables in C++.
114func QuarkFromString(StringVar *string) Quark {
115
116 StringVarPtr := core.GStrdupNullable(StringVar)
117 defer core.GFreeNullable(StringVarPtr)
118
119 cret := xQuarkFromString(StringVarPtr)
120
121 return cret
122}
123
124var xQuarkToString func(Quark) string
125
126// Gets the string associated with the given #GQuark.
127func QuarkToString(QuarkVar Quark) string {
128
129 cret := xQuarkToString(QuarkVar)
130
131 return cret
132}
133
134var xQuarkTryString func(uintptr) Quark
135
136// Gets the #GQuark associated with the given string, or 0 if string is
137// %NULL or it has no associated #GQuark.
138//
139// If you want the GQuark to be created if it doesn't already exist,
140// use g_quark_from_string() or g_quark_from_static_string().
141//
142// This function must not be used before library constructors have finished
143// running.
144func QuarkTryString(StringVar *string) Quark {
145
146 StringVarPtr := core.GStrdupNullable(StringVar)
147 defer core.GFreeNullable(StringVarPtr)
148
149 cret := xQuarkTryString(StringVarPtr)
150
151 return cret
152}
153
154func init() {
155 core.SetPackageName("GLIB", "glib-2.0")
156 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
157 var libs []uintptr
158 for _, libPath := range core.GetPaths("GLIB") {
159 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
160 if err != nil {
161 panic(err)
162 }
163 libs = append(libs, lib)
164 }
165
166 core.PuregoSafeRegister(&xInternStaticString, libs, "g_intern_static_string")
167 core.PuregoSafeRegister(&xInternString, libs, "g_intern_string")
168 core.PuregoSafeRegister(&xQuarkFromStaticString, libs, "g_quark_from_static_string")
169 core.PuregoSafeRegister(&xQuarkFromString, libs, "g_quark_from_string")
170 core.PuregoSafeRegister(&xQuarkToString, libs, "g_quark_to_string")
171 core.PuregoSafeRegister(&xQuarkTryString, libs, "g_quark_try_string")
172
173}