// 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 typedef for a reference-counted string. A pointer to a #GRefString can be // treated like a standard `char*` array by all code, but can additionally have // `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be // called on `char*` arrays not allocated using g_ref_string_new(). // // If using #GRefString with autocleanups, g_autoptr() must be used rather than // g_autofree(), so that the reference counting metadata is also freed. type RefString = byte var xRefStringAcquire func(string) string // Acquires a reference on a string. func RefStringAcquire(StrVar string) string { cret := xRefStringAcquire(StrVar) return cret } var xRefStringEqual func(string, string) bool // Compares two ref-counted strings for byte-by-byte equality. // // It can be passed to [func@GLib.HashTable.new] as the key equality function, // and behaves exactly the same as [func@GLib.str_equal] (or `strcmp()`), but // can return slightly faster as it can check the string lengths before checking // all the bytes. func RefStringEqual(Str1Var string, Str2Var string) bool { cret := xRefStringEqual(Str1Var, Str2Var) return cret } var xRefStringLength func(string) uint // Retrieves the length of @str. func RefStringLength(StrVar string) uint { cret := xRefStringLength(StrVar) return cret } var xRefStringNew func(string) string // Creates a new reference counted string and copies the contents of @str // into it. func RefStringNew(StrVar string) string { cret := xRefStringNew(StrVar) return cret } var xRefStringNewIntern func(string) string // Creates a new reference counted string and copies the content of @str // into it. // // If you call this function multiple times with the same @str, or with // the same contents of @str, it will return a new reference, instead of // creating a new string. func RefStringNewIntern(StrVar string) string { cret := xRefStringNewIntern(StrVar) return cret } var xRefStringNewLen func(string, int) string // Creates a new reference counted string and copies the contents of @str // into it, up to @len bytes. // // Since this function does not stop at nul bytes, it is the caller's // responsibility to ensure that @str has at least @len addressable bytes. func RefStringNewLen(StrVar string, LenVar int) string { cret := xRefStringNewLen(StrVar, LenVar) return cret } var xRefStringRelease func(string) // Releases a reference on a string; if it was the last reference, the // resources allocated by the string are freed as well. func RefStringRelease(StrVar string) { xRefStringRelease(StrVar) } 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(&xRefStringAcquire, libs, "g_ref_string_acquire") core.PuregoSafeRegister(&xRefStringEqual, libs, "g_ref_string_equal") core.PuregoSafeRegister(&xRefStringLength, libs, "g_ref_string_length") core.PuregoSafeRegister(&xRefStringNew, libs, "g_ref_string_new") core.PuregoSafeRegister(&xRefStringNewIntern, libs, "g_ref_string_new_intern") core.PuregoSafeRegister(&xRefStringNewLen, libs, "g_ref_string_new_len") core.PuregoSafeRegister(&xRefStringRelease, libs, "g_ref_string_release") }