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 typedef for a reference-counted string. A pointer to a #GRefString can be
11// treated like a standard `char*` array by all code, but can additionally have
12// `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be
13// called on `char*` arrays not allocated using g_ref_string_new().
14//
15// If using #GRefString with autocleanups, g_autoptr() must be used rather than
16// g_autofree(), so that the reference counting metadata is also freed.
17type RefString = byte
18
19var xRefStringAcquire func(string) string
20
21// Acquires a reference on a string.
22func RefStringAcquire(StrVar string) string {
23
24 cret := xRefStringAcquire(StrVar)
25
26 return cret
27}
28
29var xRefStringEqual func(string, string) bool
30
31// Compares two ref-counted strings for byte-by-byte equality.
32//
33// It can be passed to [func@GLib.HashTable.new] as the key equality function,
34// and behaves exactly the same as [func@GLib.str_equal] (or `strcmp()`), but
35// can return slightly faster as it can check the string lengths before checking
36// all the bytes.
37func RefStringEqual(Str1Var string, Str2Var string) bool {
38
39 cret := xRefStringEqual(Str1Var, Str2Var)
40
41 return cret
42}
43
44var xRefStringLength func(string) uint
45
46// Retrieves the length of @str.
47func RefStringLength(StrVar string) uint {
48
49 cret := xRefStringLength(StrVar)
50
51 return cret
52}
53
54var xRefStringNew func(string) string
55
56// Creates a new reference counted string and copies the contents of @str
57// into it.
58func RefStringNew(StrVar string) string {
59
60 cret := xRefStringNew(StrVar)
61
62 return cret
63}
64
65var xRefStringNewIntern func(string) string
66
67// Creates a new reference counted string and copies the content of @str
68// into it.
69//
70// If you call this function multiple times with the same @str, or with
71// the same contents of @str, it will return a new reference, instead of
72// creating a new string.
73func RefStringNewIntern(StrVar string) string {
74
75 cret := xRefStringNewIntern(StrVar)
76
77 return cret
78}
79
80var xRefStringNewLen func(string, int) string
81
82// Creates a new reference counted string and copies the contents of @str
83// into it, up to @len bytes.
84//
85// Since this function does not stop at nul bytes, it is the caller's
86// responsibility to ensure that @str has at least @len addressable bytes.
87func RefStringNewLen(StrVar string, LenVar int) string {
88
89 cret := xRefStringNewLen(StrVar, LenVar)
90
91 return cret
92}
93
94var xRefStringRelease func(string)
95
96// Releases a reference on a string; if it was the last reference, the
97// resources allocated by the string are freed as well.
98func RefStringRelease(StrVar string) {
99
100 xRefStringRelease(StrVar)
101
102}
103
104func init() {
105 core.SetPackageName("GLIB", "glib-2.0")
106 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
107 var libs []uintptr
108 for _, libPath := range core.GetPaths("GLIB") {
109 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
110 if err != nil {
111 panic(err)
112 }
113 libs = append(libs, lib)
114 }
115
116 core.PuregoSafeRegister(&xRefStringAcquire, libs, "g_ref_string_acquire")
117 core.PuregoSafeRegister(&xRefStringEqual, libs, "g_ref_string_equal")
118 core.PuregoSafeRegister(&xRefStringLength, libs, "g_ref_string_length")
119 core.PuregoSafeRegister(&xRefStringNew, libs, "g_ref_string_new")
120 core.PuregoSafeRegister(&xRefStringNewIntern, libs, "g_ref_string_new_intern")
121 core.PuregoSafeRegister(&xRefStringNewLen, libs, "g_ref_string_new_len")
122 core.PuregoSafeRegister(&xRefStringRelease, libs, "g_ref_string_release")
123
124}