// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" ) // A GQuark is a non-zero integer which uniquely identifies a // particular string. // // A GQuark value of zero is associated to `NULL`. // // Given either the string or the `GQuark` identifier it is possible to // retrieve the other. // // Quarks are used for both // [datasets and keyed data lists](datalist-and-dataset.html). // // To create a new quark from a string, use [func@GLib.quark_from_string] // or [func@GLib.quark_from_static_string]. // // To find the string corresponding to a given `GQuark`, use // [func@GLib.quark_to_string]. // // To find the `GQuark` corresponding to a given string, use // [func@GLib.quark_try_string]. // // Another use for the string pool maintained for the quark functions // is string interning, using [func@GLib.intern_string] or // [func@GLib.intern_static_string]. An interned string is a canonical // representation for a string. One important advantage of interned // strings is that they can be compared for equality by a simple // pointer comparison, rather than using `strcmp()`. type Quark = uint32 var xInternStaticString func(uintptr) string // Returns a canonical representation for @string. Interned strings // can be compared for equality by comparing the pointers, instead of // using strcmp(). g_intern_static_string() does not copy the string, // therefore @string must not be freed or modified. // // This function must not be used before library constructors have finished // running. In particular, this means it cannot be used to initialize global // variables in C++. func InternStaticString(StringVar *string) string { StringVarPtr := core.GStrdupNullable(StringVar) defer core.GFreeNullable(StringVarPtr) cret := xInternStaticString(StringVarPtr) return cret } var xInternString func(uintptr) string // Returns a canonical representation for @string. Interned strings // can be compared for equality by comparing the pointers, instead of // using strcmp(). // // This function must not be used before library constructors have finished // running. In particular, this means it cannot be used to initialize global // variables in C++. func InternString(StringVar *string) string { StringVarPtr := core.GStrdupNullable(StringVar) defer core.GFreeNullable(StringVarPtr) cret := xInternString(StringVarPtr) return cret } var xQuarkFromStaticString func(uintptr) Quark // Gets the #GQuark identifying the given (static) string. If the // string does not currently have an associated #GQuark, a new #GQuark // is created, linked to the given string. // // Note that this function is identical to g_quark_from_string() except // that if a new #GQuark is created the string itself is used rather // than a copy. This saves memory, but can only be used if the string // will continue to exist until the program terminates. It can be used // with statically allocated strings in the main program, but not with // statically allocated memory in dynamically loaded modules, if you // expect to ever unload the module again (e.g. do not use this // function in GTK theme engines). // // This function must not be used before library constructors have finished // running. In particular, this means it cannot be used to initialize global // variables in C++. func QuarkFromStaticString(StringVar *string) Quark { StringVarPtr := core.GStrdupNullable(StringVar) defer core.GFreeNullable(StringVarPtr) cret := xQuarkFromStaticString(StringVarPtr) return cret } var xQuarkFromString func(uintptr) Quark // Gets the #GQuark identifying the given string. If the string does // not currently have an associated #GQuark, a new #GQuark is created, // using a copy of the string. // // This function must not be used before library constructors have finished // running. In particular, this means it cannot be used to initialize global // variables in C++. func QuarkFromString(StringVar *string) Quark { StringVarPtr := core.GStrdupNullable(StringVar) defer core.GFreeNullable(StringVarPtr) cret := xQuarkFromString(StringVarPtr) return cret } var xQuarkToString func(Quark) string // Gets the string associated with the given #GQuark. func QuarkToString(QuarkVar Quark) string { cret := xQuarkToString(QuarkVar) return cret } var xQuarkTryString func(uintptr) Quark // Gets the #GQuark associated with the given string, or 0 if string is // %NULL or it has no associated #GQuark. // // If you want the GQuark to be created if it doesn't already exist, // use g_quark_from_string() or g_quark_from_static_string(). // // This function must not be used before library constructors have finished // running. func QuarkTryString(StringVar *string) Quark { StringVarPtr := core.GStrdupNullable(StringVar) defer core.GFreeNullable(StringVarPtr) cret := xQuarkTryString(StringVarPtr) return cret } func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xInternStaticString, libs, "g_intern_static_string") core.PuregoSafeRegister(&xInternString, libs, "g_intern_string") core.PuregoSafeRegister(&xQuarkFromStaticString, libs, "g_quark_from_static_string") core.PuregoSafeRegister(&xQuarkFromString, libs, "g_quark_from_string") core.PuregoSafeRegister(&xQuarkToString, libs, "g_quark_to_string") core.PuregoSafeRegister(&xQuarkTryString, libs, "g_quark_try_string") }