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 a comparison function used to compare two
14// values. The function should return a negative integer if the first
15// value comes before the second, 0 if they are equal, or a positive
16// integer if the first value comes after the second.
17type CompareDataFunc func(uintptr, uintptr, uintptr) int
18
19// Specifies the type of a comparison function used to compare two
20// values. The function should return a negative integer if the first
21// value comes before the second, 0 if they are equal, or a positive
22// integer if the first value comes after the second.
23type CompareFunc func(uintptr, uintptr) int
24
25// A function of this signature is used to copy the node data
26// when doing a deep-copy of a tree.
27type CopyFunc func(uintptr, uintptr) uintptr
28
29// Specifies the type of function which is called when a data element
30// is destroyed. It is passed the pointer to the data element and
31// should free any memory and resources allocated for it.
32type DestroyNotify func(uintptr)
33
34// Specifies the type of a function used to test two values for
35// equality. The function should return %TRUE if both values are equal
36// and %FALSE otherwise.
37type EqualFunc func(uintptr, uintptr) bool
38
39// Specifies the type of a function used to test two values for
40// equality. The function should return %TRUE if both values are equal
41// and %FALSE otherwise.
42//
43// This is a version of #GEqualFunc which provides a @user_data closure from
44// the caller.
45type EqualFuncFull func(uintptr, uintptr, uintptr) bool
46
47// Declares a type of function which takes an arbitrary
48// data pointer argument and has no return value. It is
49// not currently used in GLib or GTK.
50type FreeFunc func(uintptr)
51
52// Specifies the type of functions passed to g_list_foreach() and
53// g_slist_foreach().
54type Func func(uintptr, uintptr)
55
56// Specifies the type of the function passed to g_hash_table_foreach().
57// It is called with each key/value pair, together with the @user_data
58// parameter which is passed to g_hash_table_foreach().
59type HFunc func(uintptr, uintptr, uintptr)
60
61// Specifies the type of the hash function which is passed to
62// g_hash_table_new() when a #GHashTable is created.
63//
64// The function is passed a key and should return a #guint hash value.
65// The functions g_direct_hash(), g_int_hash() and g_str_hash() provide
66// hash functions which can be used when the key is a #gpointer, #gint*,
67// and #gchar* respectively.
68//
69// g_direct_hash() is also the appropriate hash function for keys
70// of the form `GINT_TO_POINTER (n)` (or similar macros).
71//
72// A good hash functions should produce
73// hash values that are evenly distributed over a fairly large range.
74// The modulus is taken with the hash table size (a prime number) to
75// find the 'bucket' to place each key into. The function should also
76// be very fast, since it is called for each key lookup.
77//
78// Note that the hash functions provided by GLib have these qualities,
79// but are not particularly robust against manufactured keys that
80// cause hash collisions. Therefore, you should consider choosing
81// a more secure hash function when using a GHashTable with keys
82// that originate in untrusted data (such as HTTP requests).
83// Using g_str_hash() in that situation might make your application
84// vulnerable to
85// [Algorithmic Complexity Attacks](https://lwn.net/Articles/474912/).
86//
87// The key to choosing a good hash is unpredictability. Even
88// cryptographic hashes are very easy to find collisions for when the
89// remainder is taken modulo a somewhat predictable prime number. There
90// must be an element of randomness that an attacker is unable to guess.
91type HashFunc func(uintptr) uint
92
93// The type of functions which are used to translate user-visible
94// strings, for <option>--help</option> output.
95type TranslateFunc func(string, uintptr) string
96
97// Represents a precise time, with seconds and microseconds.
98//
99// Similar to the struct timeval returned by the `gettimeofday()`
100// UNIX system call.
101//
102// GLib is attempting to unify around the use of 64-bit integers to
103// represent microsecond-precision time. As such, this type will be
104// removed from a future version of GLib. A consequence of using `glong` for
105// `tv_sec` is that on 32-bit systems `GTimeVal` is subject to the year 2038
106// problem.
107type TimeVal struct {
108 _ structs.HostLayout
109
110 TvSec int
111
112 TvUsec int
113}
114
115func (x *TimeVal) GoPointer() uintptr {
116 return uintptr(unsafe.Pointer(x))
117}
118
119var xTimeValAdd func(uintptr, int)
120
121// Adds the given number of microseconds to @time_. @microseconds can
122// also be negative to decrease the value of @time_.
123func (x *TimeVal) Add(MicrosecondsVar int) {
124
125 xTimeValAdd(x.GoPointer(), MicrosecondsVar)
126
127}
128
129var xTimeValToIso8601 func(uintptr) string
130
131// Converts @time_ into an RFC 3339 encoded string, relative to the
132// Coordinated Universal Time (UTC). This is one of the many formats
133// allowed by ISO 8601.
134//
135// ISO 8601 allows a large number of date/time formats, with or without
136// punctuation and optional elements. The format returned by this function
137// is a complete date and time, with optional punctuation included, the
138// UTC time zone represented as "Z", and the @tv_usec part included if
139// and only if it is nonzero, i.e. either
140// "YYYY-MM-DDTHH:MM:SSZ" or "YYYY-MM-DDTHH:MM:SS.fffffZ".
141//
142// This corresponds to the Internet date/time format defined by
143// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt),
144// and to either of the two most-precise formats defined by
145// the W3C Note
146// [Date and Time Formats](http://www.w3.org/TR/NOTE-datetime-19980827).
147// Both of these documents are profiles of ISO 8601.
148//
149// Use g_date_time_format() or g_strdup_printf() if a different
150// variation of ISO 8601 format is required.
151//
152// If @time_ represents a date which is too large to fit into a `struct tm`,
153// %NULL will be returned. This is platform dependent. Note also that since
154// `GTimeVal` stores the number of seconds as a `glong`, on 32-bit systems it
155// is subject to the year 2038 problem. Accordingly, since GLib 2.62, this
156// function has been deprecated. Equivalent functionality is available using:
157// |[
158// GDateTime *dt = g_date_time_new_from_unix_utc (time_val);
159// iso8601_string = g_date_time_format_iso8601 (dt);
160// g_date_time_unref (dt);
161// ]|
162//
163// The return value of g_time_val_to_iso8601() has been nullable since GLib
164// 2.54; before then, GLib would crash under the same conditions.
165func (x *TimeVal) ToIso8601() string {
166
167 cret := xTimeValToIso8601(x.GoPointer())
168 return cret
169}
170
171// The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
172// mantissa and exponent of IEEE floats and doubles. These unions are defined
173// as appropriate for a given platform. IEEE floats and doubles are supported
174// (used for storage) by at least Intel, PPC and Sparc.
175type DoubleIEEE754 = uintptr
176
177// The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
178// mantissa and exponent of IEEE floats and doubles. These unions are defined
179// as appropriate for a given platform. IEEE floats and doubles are supported
180// (used for storage) by at least Intel, PPC and Sparc.
181type FloatIEEE754 = uintptr
182
183const (
184 // Specifies one of the possible types of byte order.
185 // See %G_BYTE_ORDER.
186 BIG_ENDIAN int = 4321
187 // The base of natural logarithms.
188 E float64 = 2.718282
189 // The bias by which exponents in double-precision floats are offset.
190 IEEE754_DOUBLE_BIAS int = 1023
191 // The bias by which exponents in single-precision floats are offset.
192 IEEE754_FLOAT_BIAS int = 127
193 // Specifies one of the possible types of byte order.
194 // See %G_BYTE_ORDER.
195 LITTLE_ENDIAN int = 1234
196 // The natural logarithm of 10.
197 LN10 float64 = 2.302585
198 // The natural logarithm of 2.
199 LN2 float64 = 0.693147
200 // Multiplying the base 2 exponent by this number yields the base 10 exponent.
201 LOG_2_BASE_10 float64 = 0.301030
202
203 MAXINT16 int16 = 32767
204
205 MAXINT32 int32 = 2147483647
206
207 MAXINT64 int64 = 9223372036854775807
208
209 MAXINT8 int8 = 127
210
211 MAXUINT16 uint16 = 65535
212
213 MAXUINT32 uint32 = 4294967295
214
215 MAXUINT64 uint64 = 18446744073709551615
216
217 MAXUINT8 byte = 255
218 // The minimum value which can be held in a #gint16.
219 MININT16 int16 = -32768
220 // The minimum value which can be held in a #gint32.
221 MININT32 int32 = -2147483648
222 // The minimum value which can be held in a #gint64.
223 MININT64 int64 = -9223372036854775808
224 // The minimum value which can be held in a #gint8.
225 MININT8 int8 = -128
226 // Specifies one of the possible types of byte order
227 // (currently unused). See %G_BYTE_ORDER.
228 PDP_ENDIAN int = 3412
229 // The value of pi (ratio of circle's circumference to its diameter).
230 PI float64 = 3.141593
231 // Pi divided by 2.
232 PI_2 float64 = 1.570796
233 // Pi divided by 4.
234 PI_4 float64 = 0.785398
235 // The square root of two.
236 SQRT2 float64 = 1.414214
237)
238
239func init() {
240 core.SetPackageName("GLIB", "glib-2.0")
241 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
242 var libs []uintptr
243 for _, libPath := range core.GetPaths("GLIB") {
244 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
245 if err != nil {
246 panic(err)
247 }
248 libs = append(libs, lib)
249 }
250
251 core.PuregoSafeRegister(&xTimeValAdd, libs, "g_time_val_add")
252 core.PuregoSafeRegister(&xTimeValToIso8601, libs, "g_time_val_to_iso8601")
253
254}