Debian Codegraph @

gtk/gtkbuilderscope.c

raw symbols SCIP
1 /*
2 * Copyright © 2019 Benjamin Otte
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authors: Benjamin Otte <[email protected]>
18 */
19
20 #include "config.h"cxx . . $ `<file>/build/config.h`/
21
22 #include "gtkbuilderscopeprivate.h"cxx . . $ `<file>/gtk/gtkbuilderscopeprivate.h`/
23
24 #include "gtkbuilder.h"cxx . . $ `<file>/gtk/gtkbuilder.h`/
25 #include "gtktestutils.h"cxx . . $ `<file>/gtk/gtktestutils.h`/
26
27 /**
28 * GtkBuilderScope:
29 *
30 * Provides language binding support to `GtkBuilder`.
31 *
32 * The goal of `GtkBuilderScope` is to look up programming-language-specific
33 * values for strings that are given in a `GtkBuilder` UI file.
34 *
35 * The primary intended audience is bindings that want to provide deeper
36 * integration of `GtkBuilder` into the language.
37 *
38 * A `GtkBuilderScope` instance may be used with multiple `GtkBuilder` objects,
39 * even at once.
40 *
41 * By default, GTK will use its own implementation of `GtkBuilderScope`
42 * for the C language which can be created via [[email protected]].
43 *
44 * If you implement `GtkBuilderScope` for a language binding, you
45 * may want to (partially) derive from or fall back to a [[email protected]],
46 * as that class implements support for automatic lookups from C symbols.
47 */
48
49 /**
50 * GtkBuilderCScope:
51 *
52 * A `GtkBuilderScope` implementation for the C language.
53 *
54 * `GtkBuilderCScope` instances use symbols explicitly added to @builder
55 * with prior calls to [[email protected]_callback_symbol].
56 * If developers want to do that, they are encouraged to create their
57 * own scopes for that purpose.
58 *
59 * In the case that symbols are not explicitly added; GTK will uses
60 * `GModule`’s introspective features (by opening the module %NULL) to
61 * look at the application’s symbol table. From here it tries to match
62 * the signal function names given in the interface description with
63 * symbols in the application.
64 *
65 * Note that unless [[email protected]_callback_symbol] is
66 * called for all signal callbacks which are referenced by the loaded XML,
67 * this functionality will require that `GModule` be supported on the platform.
68 */
69
70
71 G_DEFINE_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2078:9`! (GtkBuilderScope, gtk_builder_scope, G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!)
72
73 static GTypecxx . . $ GType#
74 gtk_builder_scope_default_get_type_from_namecxx . . $ gtk_builder_scope_default_get_type_from_name(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
75 GtkBuildercxx . . $ GtkBuilder# *builder,
76 const char *type_name)
77 {
78 GTypecxx . . $ GType# type;
79
80 type = g_type_from_namecxx . . $ g_type_from_name(751346f8406fd082). (type_name);
81 if (type != G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!)
82 return type;
83
84 gtk_test_register_all_typescxx . . $ gtk_test_register_all_types(49f6e7a06ebc5aa8). ();
85 return g_type_from_namecxx . . $ g_type_from_name(751346f8406fd082). (type_name);
86 }
87
88 static GTypecxx . . $ GType#
89 gtk_builder_scope_default_get_type_from_functioncxx . . $ gtk_builder_scope_default_get_type_from_function(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
90 GtkBuildercxx . . $ GtkBuilder# *builder,
91 const char *type_name)
92 {
93 return G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!;
94 }
95
96 static GClosurecxx . . $ GClosure# *
97 gtk_builder_scope_default_create_closurecxx . . $ gtk_builder_scope_default_create_closure(f2905e6c671eb72e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
98 GtkBuildercxx . . $ GtkBuilder# *builder,
99 const char *function_name,
100 GtkBuilderClosureFlagscxx . . $ GtkBuilderClosureFlags# flags,
101 GObjectcxx . . $ GObject# *object,
102 GErrorcxx . . $ GError# **error)
103 {
104 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
105 GTK_BUILDER_ERRORcxx . . $ `gtk/gtkbuilder.h:37:9`!,
106 GTK_BUILDER_ERROR_INVALID_FUNCTIONcxx . . $ GTK_BUILDER_ERROR_INVALID_FUNCTION.,
107 "Creating closures is not supported by %s",
108 G_OBJECT_TYPE_NAMEcxx . . $ `<external>/1341695927569185362/gobject.h:108:9`! (self));
109 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
110 }
111
112 static void
113 gtk_builder_scope_default_initcxx . . $ gtk_builder_scope_default_init(f72630809ae9c26). (GtkBuilderScopeInterfacecxx . . $ GtkBuilderScopeInterface# *iface)
114 {
115 iface->get_type_from_namecxx . . $ _GtkBuilderScopeInterface#get_type_from_name. = gtk_builder_scope_default_get_type_from_namecxx . . $ gtk_builder_scope_default_get_type_from_name(c93c38a2c4e7489e).;
116 iface->get_type_from_functioncxx . . $ _GtkBuilderScopeInterface#get_type_from_function. = gtk_builder_scope_default_get_type_from_functioncxx . . $ gtk_builder_scope_default_get_type_from_function(c93c38a2c4e7489e).;
117 iface->create_closurecxx . . $ _GtkBuilderScopeInterface#create_closure. = gtk_builder_scope_default_create_closurecxx . . $ gtk_builder_scope_default_create_closure(f2905e6c671eb72e).;
118 }
119
120 GTypecxx . . $ GType#
121 gtk_builder_scope_get_type_from_namecxx . . $ gtk_builder_scope_get_type_from_name(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
122 GtkBuildercxx . . $ GtkBuilder# *builder,
123 const char *type_name)
124 {
125 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDER_SCOPE (self), G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
126 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDERcxx . . $ `gtk/gtkbuilder.h:33:9`! (builder), G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
127 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (type_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
128
129 return GTK_BUILDER_SCOPE_GET_IFACEcxx . . $ GTK_BUILDER_SCOPE_GET_IFACE(6742f0085e6bfa2). (self)->get_type_from_namecxx . . $ _GtkBuilderScopeInterface#get_type_from_name. (self, builder, type_name);
130 }
131
132 GTypecxx . . $ GType#
133 gtk_builder_scope_get_type_from_functioncxx . . $ gtk_builder_scope_get_type_from_function(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
134 GtkBuildercxx . . $ GtkBuilder# *builder,
135 const char *function_name)
136 {
137 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDER_SCOPE (self), G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
138 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDERcxx . . $ `gtk/gtkbuilder.h:33:9`! (builder), G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
139 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (function_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!);
140
141 return GTK_BUILDER_SCOPE_GET_IFACEcxx . . $ GTK_BUILDER_SCOPE_GET_IFACE(6742f0085e6bfa2). (self)->get_type_from_functioncxx . . $ _GtkBuilderScopeInterface#get_type_from_function. (self, builder, function_name);
142 }
143
144 GClosurecxx . . $ GClosure# *
145 gtk_builder_scope_create_closurecxx . . $ gtk_builder_scope_create_closure(f2905e6c671eb72e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *self,
146 GtkBuildercxx . . $ GtkBuilder# *builder,
147 const char *function_name,
148 GtkBuilderClosureFlagscxx . . $ GtkBuilderClosureFlags# flags,
149 GObjectcxx . . $ GObject# *object,
150 GErrorcxx . . $ GError# **error)
151 {
152 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDER_SCOPE (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
153 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDERcxx . . $ `gtk/gtkbuilder.h:33:9`! (builder), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
154 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (function_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
155 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (object == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || G_IS_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:69:9`! (object), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
156 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (error == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || *error == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
157
158 return GTK_BUILDER_SCOPE_GET_IFACEcxx . . $ GTK_BUILDER_SCOPE_GET_IFACE(6742f0085e6bfa2). (self)->create_closurecxx . . $ _GtkBuilderScopeInterface#create_closure. (self, builder, function_name, flags, object, error);
159 }
160
161 /*** GTK_BUILDER_CSCOPE ***/
162
163 typedef struct _GtkBuilderCScopePrivatecxx . . $ _GtkBuilderCScopePrivate# GtkBuilderCScopePrivatecxx . . $ GtkBuilderCScopePrivate#;
164
165 struct _GtkBuilderCScopePrivatecxx . . $ _GtkBuilderCScopePrivate#
166 {
167 GModulecxx . . $ GModule# *modulecxx . . $ _GtkBuilderCScopePrivate#module.;
168 GHashTablecxx . . $ GHashTable# *callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks.;
169 };
170
171 static void gtk_builder_cscope_scope_initcxx . . $ gtk_builder_cscope_scope_init(f72630809ae9c26). (GtkBuilderScopeInterfacecxx . . $ GtkBuilderScopeInterface# *iface);
172
173 G_DEFINE_TYPE_WITH_CODEcxx . . $ `<external>/9567554376676449156/gtype.h:1850:9`! (GtkBuilderCScope, gtk_builder_cscope, G_TYPE_OBJECTcxx . . $ `<external>/9567554376676449156/gtype.h:189:9`!,
174 G_ADD_PRIVATEcxx . . $ `<external>/9567554376676449156/gtype.h:2194:9`!(GtkBuilderCScope)
175 G_IMPLEMENT_INTERFACEcxx . . $ `<external>/9567554376676449156/gtype.h:2115:9`! (GTK_TYPE_BUILDER_SCOPEcxx . . $ `gtk/gtkbuilderscope.h:30:9`!,
176 gtk_builder_cscope_scope_init))
177
178 static GModulecxx . . $ GModule# *
179 gtk_builder_cscope_get_modulecxx . . $ gtk_builder_cscope_get_module(a22c3f84a9132fd2). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self)
180 {
181 GtkBuilderCScopePrivatecxx . . $ GtkBuilderCScopePrivate# *priv = gtk_builder_cscope_get_instance_privatecxx . . $ gtk_builder_cscope_get_instance_private(3ec2f35a9aa53088). (self);
182
183 if (priv->modulecxx . . $ _GtkBuilderCScopePrivate#module. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
184 {
185 if (!g_module_supportedcxx . . $ g_module_supported(b126dc7c1de90089). ())
186 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
187
188 priv->modulecxx . . $ _GtkBuilderCScopePrivate#module. = g_module_opencxx . . $ g_module_open(76b1160a1f4b8ece). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, G_MODULE_BIND_LAZYcxx . . $ G_MODULE_BIND_LAZY.);
189 }
190
191 return priv->modulecxx . . $ _GtkBuilderCScopePrivate#module.;
192 }
193
194 /*
195 * Try to map a type name to a _get_type function
196 * and call it, eg:
197 *
198 * GtkWindow -> gtk_window_get_type
199 * GtkHBox -> gtk_hbox_get_type
200 * GtkUIManager -> gtk_ui_manager_get_type
201 * GWeatherLocation -> gweather_location_get_type (split_first_cap == FALSE)
202 * GThemedIcon -> g_themed_icon_get_type (slit_first_cap == TRUE)
203 *
204 * Keep in sync with testsuite/gtk/typename.c !
205 */
206 static char *
207 type_name_manglecxx . . $ type_name_mangle(2050848944e00d54). (const char *name,
208 gbooleancxx . . $ gboolean# split_first_cap)
209 {
210 GStringcxx . . $ GString# *symbol_name = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). ("");
211 int i;
212
213 for (i = 0; name[i] != '\0'; i++)
214 {
215 /* skip if uppercase, first or previous is uppercase */
216 if ((name[i] == g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[i]) &&
217 ((i > 0 && name[i-1] != g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[i-1])) ||
218 (i == 1 && name[0] == g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[0]) && split_first_cap))) ||
219 (i > 2 && name[i] == g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[i]) &&
220 name[i-1] == g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[i-1]) &&
221 name[i-2] == g_ascii_touppercxx . . $ g_ascii_toupper(e6e5e845b55315fc). (name[i-2])))
222 g_string_append_ccxx . . $ `<external>/2906017559248664336/gstring.h:215:9`! (symbol_name, '_');
223 g_string_append_ccxx . . $ `<external>/2906017559248664336/gstring.h:215:9`! (symbol_name, g_ascii_tolower (name[i]));
224 }
225 g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (symbol_name, "_get_type");
226
227 return g_string_freecxx . . $ `<external>/2906017559248664336/gstring.h:73:9`! (symbol_name, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
228 }
229
230 static GTypecxx . . $ GType#
231 gtk_builder_cscope_resolve_type_lazilycxx . . $ gtk_builder_cscope_resolve_type_lazily(11487d999e2c81ea). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
232 const char *name)
233 {
234 GModulecxx . . $ GModule# *module;
235 GTypecxx . . $ GType# (*func) (void);
236 char *symbol;
237 GTypecxx . . $ GType# gtype = G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!;
238
239 module = gtk_builder_cscope_get_modulecxx . . $ gtk_builder_cscope_get_module(a22c3f84a9132fd2). (self);
240 if (!module)
241 return G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!;
242
243 symbol = type_name_manglecxx . . $ type_name_mangle(2050848944e00d54). (name, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
244
245 if (g_module_symbolcxx . . $ g_module_symbol(9abba96d28f5e864). (module, symbol, (gpointercxx . . $ gpointer#)&func))
246 gtype = func ();
247
248 g_freecxx . . $ g_free(5d22bdacc48458e8). (symbol);
249
250 symbol = type_name_manglecxx . . $ type_name_mangle(2050848944e00d54). (name, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
251
252 if (g_module_symbolcxx . . $ g_module_symbol(9abba96d28f5e864). (module, symbol, (gpointercxx . . $ gpointer#)&func))
253 gtype = func ();
254
255 g_freecxx . . $ g_free(5d22bdacc48458e8). (symbol);
256
257 return gtype;
258 }
259
260 static GTypecxx . . $ GType#
261 gtk_builder_cscope_get_type_from_namecxx . . $ gtk_builder_cscope_get_type_from_name(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *scope,
262 GtkBuildercxx . . $ GtkBuilder# *builder,
263 const char *type_name)
264 {
265 GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self = GTK_BUILDER_CSCOPEcxx . . $ GTK_BUILDER_CSCOPE(30ace4310d4a7096). (scope);
266 GTypecxx . . $ GType# type;
267
268 type = g_type_from_namecxx . . $ g_type_from_name(751346f8406fd082). (type_name);
269 if (type != G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!)
270 return type;
271
272 type = gtk_builder_cscope_resolve_type_lazilycxx . . $ gtk_builder_cscope_resolve_type_lazily(11487d999e2c81ea). (self, type_name);
273 if (type != G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!)
274 return type;
275
276 gtk_test_register_all_typescxx . . $ gtk_test_register_all_types(49f6e7a06ebc5aa8). ();
277 type = g_type_from_namecxx . . $ g_type_from_name(751346f8406fd082). (type_name);
278
279 return type;
280 }
281
282 static GCallbackcxx . . $ GCallback#
283 gtk_builder_cscope_get_callbackcxx . . $ gtk_builder_cscope_get_callback(4b2e61304c070363). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
284 const char *function_name,
285 GErrorcxx . . $ GError# **error)
286 {
287 GModulecxx . . $ GModule# *module;
288 GCallbackcxx . . $ GCallback# func;
289
290 func = gtk_builder_cscope_lookup_callback_symbolcxx . . $ gtk_builder_cscope_lookup_callback_symbol(744102708ba20df). (self, function_name);
291 if (func)
292 return func;
293
294 module = gtk_builder_cscope_get_modulecxx . . $ gtk_builder_cscope_get_module(a22c3f84a9132fd2). (self);
295 if (module == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
296 {
297 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
298 GTK_BUILDER_ERRORcxx . . $ `gtk/gtkbuilder.h:37:9`!,
299 GTK_BUILDER_ERROR_INVALID_FUNCTIONcxx . . $ GTK_BUILDER_ERROR_INVALID_FUNCTION.,
300 "Could not look up function `%s`: GModule is not supported.",
301 function_name);
302 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
303 }
304
305 if (!g_module_symbolcxx . . $ g_module_symbol(9abba96d28f5e864). (module, function_name, (gpointercxx . . $ gpointer#)&func))
306 {
307 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error,
308 GTK_BUILDER_ERRORcxx . . $ `gtk/gtkbuilder.h:37:9`!,
309 GTK_BUILDER_ERROR_INVALID_FUNCTIONcxx . . $ GTK_BUILDER_ERROR_INVALID_FUNCTION.,
310 "No function named `%s`.",
311 function_name);
312 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
313 }
314
315 return func;
316 }
317
318 static GTypecxx . . $ GType#
319 gtk_builder_cscope_get_type_from_functioncxx . . $ gtk_builder_cscope_get_type_from_function(c93c38a2c4e7489e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *scope,
320 GtkBuildercxx . . $ GtkBuilder# *builder,
321 const char *function_name)
322 {
323 GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self = GTK_BUILDER_CSCOPEcxx . . $ GTK_BUILDER_CSCOPE(30ace4310d4a7096). (scope);
324 GTypecxx . . $ GType# (* type_func) (void);
325
326 type_func = (GTypecxx . . $ GType# (*) (void)) gtk_builder_cscope_get_callbackcxx . . $ gtk_builder_cscope_get_callback(4b2e61304c070363). (self, function_name, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
327 if (!type_func)
328 return G_TYPE_INVALIDcxx . . $ `<external>/9567554376676449156/gtype.h:65:9`!;
329
330 return type_func();
331 }
332
333 static GClosurecxx . . $ GClosure# *
334 gtk_builder_cscope_create_closure_for_funcptrcxx . . $ gtk_builder_cscope_create_closure_for_funcptr(179a4886af06f0b4). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
335 GtkBuildercxx . . $ GtkBuilder# *builder,
336 GCallbackcxx . . $ GCallback# callback,
337 gbooleancxx . . $ gboolean# swapped,
338 GObjectcxx . . $ GObject# *object)
339 {
340 GClosurecxx . . $ GClosure# *closure;
341
342 if (object == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
343 object = gtk_builder_get_current_objectcxx . . $ gtk_builder_get_current_object(39b4f88217bebd68). (builder);
344
345 if (object)
346 {
347 if (swapped)
348 closure = g_cclosure_new_object_swapcxx . . $ g_cclosure_new_object_swap(595e38432ff1d462). (callback, object);
349 else
350 closure = g_cclosure_new_objectcxx . . $ g_cclosure_new_object(595e38432ff1d462). (callback, object);
351 }
352 else
353 {
354 if (swapped)
355 closure = g_cclosure_new_swapcxx . . $ g_cclosure_new_swap(6a2e4334238305f5). (callback, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
356 else
357 closure = g_cclosure_newcxx . . $ g_cclosure_new(6a2e4334238305f5). (callback, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
358 }
359
360 return closure;
361 }
362
363 static GClosurecxx . . $ GClosure# *
364 gtk_builder_cscope_create_closurecxx . . $ gtk_builder_cscope_create_closure(f2905e6c671eb72e). (GtkBuilderScopecxx . . $ GtkBuilderScope# *scope,
365 GtkBuildercxx . . $ GtkBuilder# *builder,
366 const char *function_name,
367 GtkBuilderClosureFlagscxx . . $ GtkBuilderClosureFlags# flags,
368 GObjectcxx . . $ GObject# *object,
369 GErrorcxx . . $ GError# **error)
370 {
371 GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self = GTK_BUILDER_CSCOPEcxx . . $ GTK_BUILDER_CSCOPE(30ace4310d4a7096). (scope);
372 GCallbackcxx . . $ GCallback# func;
373 gbooleancxx . . $ gboolean# swapped;
374
375 swapped = flags & GTK_BUILDER_CLOSURE_SWAPPEDcxx . . $ GTK_BUILDER_CLOSURE_SWAPPED.;
376
377 func = gtk_builder_cscope_get_callbackcxx . . $ gtk_builder_cscope_get_callback(4b2e61304c070363). (self, function_name, error);
378 if (!func)
379 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
380
381 return gtk_builder_cscope_create_closure_for_funcptrcxx . . $ gtk_builder_cscope_create_closure_for_funcptr(179a4886af06f0b4). (self, builder, func, swapped, object);
382 }
383
384 static void
385 gtk_builder_cscope_scope_initcxx . . $ gtk_builder_cscope_scope_init(f72630809ae9c26). (GtkBuilderScopeInterfacecxx . . $ GtkBuilderScopeInterface# *iface)
386 {
387 iface->get_type_from_namecxx . . $ _GtkBuilderScopeInterface#get_type_from_name. = gtk_builder_cscope_get_type_from_namecxx . . $ gtk_builder_cscope_get_type_from_name(c93c38a2c4e7489e).;
388 iface->get_type_from_functioncxx . . $ _GtkBuilderScopeInterface#get_type_from_function. = gtk_builder_cscope_get_type_from_functioncxx . . $ gtk_builder_cscope_get_type_from_function(c93c38a2c4e7489e).;
389 iface->create_closurecxx . . $ _GtkBuilderScopeInterface#create_closure. = gtk_builder_cscope_create_closurecxx . . $ gtk_builder_cscope_create_closure(f2905e6c671eb72e).;
390 }
391
392 static void
393 gtk_builder_cscope_finalizecxx . . $ gtk_builder_cscope_finalize(6087475fa43034d3). (GObjectcxx . . $ GObject# *object)
394 {
395 GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self = GTK_BUILDER_CSCOPEcxx . . $ GTK_BUILDER_CSCOPE(30ace4310d4a7096). (object);
396 GtkBuilderCScopePrivatecxx . . $ GtkBuilderCScopePrivate# *priv = gtk_builder_cscope_get_instance_privatecxx . . $ gtk_builder_cscope_get_instance_private(3ec2f35a9aa53088). (self);
397
398 g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&priv->callbacks, g_hash_table_destroy);
399 g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&priv->module, g_module_close);
400
401 G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (gtk_builder_cscope_parent_class)->finalizecxx . . $ _GObjectClass#finalize. (object);
402 }
403
404 static void
405 gtk_builder_cscope_class_initcxx . . $ gtk_builder_cscope_class_init(4f021fd95053471a). (GtkBuilderCScopeClasscxx . . $ GtkBuilderCScopeClass# *klass)
406 {
407 GObjectClasscxx . . $ GObjectClass# *object_class = G_OBJECT_CLASScxx . . $ `<external>/1341695927569185362/gobject.h:61:9`! (klass);
408
409 object_class->finalizecxx . . $ _GObjectClass#finalize. = gtk_builder_cscope_finalizecxx . . $ gtk_builder_cscope_finalize(6087475fa43034d3).;
410 }
411
412 static void
413 gtk_builder_cscope_initcxx . . $ gtk_builder_cscope_init(24b29f9d5f2ac31e). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self)
414 {
415 }
416
417 /**
418 * gtk_builder_cscope_new:
419 *
420 * Creates a new `GtkBuilderCScope` object to use with future
421 * `GtkBuilder` instances.
422 *
423 * Calling this function is only necessary if you want to add
424 * custom callbacks via [[email protected]_callback_symbol].
425 *
426 * Returns: (transfer full) (type GtkBuilderCScope): a new `GtkBuilderCScope`
427 */
428 GtkBuilderScopecxx . . $ GtkBuilderScope# *
429 gtk_builder_cscope_newcxx . . $ gtk_builder_cscope_new(5d26662d63978141). (void)
430 {
431 return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (GTK_TYPE_BUILDER_CSCOPEcxx . . $ `gtk/gtkbuilderscope.h:101:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
432 }
433
434 /**
435 * gtk_builder_cscope_add_callback:
436 * @scope: a `GtkBuilderCScope`
437 * @callback: (scope async): The callback pointer
438 *
439 * Adds the @callback to the scope of @builder under its own name.
440 *
441 * This is a convenience wrapper of [[email protected]_callback_symbol].
442 *
443 * Since: 4.8
444 */
445
446 /**
447 * gtk_builder_cscope_add_callback_symbol:
448 * @self: a `GtkBuilderCScope`
449 * @callback_name: The name of the callback, as expected in the XML
450 * @callback_symbol: (scope async): The callback pointer
451 *
452 * Adds the @callback_symbol to the scope of @builder under the
453 * given @callback_name.
454 *
455 * Using this function overrides the behavior of
456 * [[email protected]_closure] for any callback symbols that
457 * are added. Using this method allows for better encapsulation as it
458 * does not require that callback symbols be declared in the global
459 * namespace.
460 */
461 void
462 gtk_builder_cscope_add_callback_symbolcxx . . $ gtk_builder_cscope_add_callback_symbol(f36adce1b9e0d506). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
463 const char *callback_name,
464 GCallbackcxx . . $ GCallback# callback_symbol)
465 {
466 GtkBuilderCScopePrivatecxx . . $ GtkBuilderCScopePrivate# *priv = gtk_builder_cscope_get_instance_privatecxx . . $ gtk_builder_cscope_get_instance_private(3ec2f35a9aa53088). (self);
467
468 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_BUILDER_CSCOPE (self));
469 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (callback_name && callback_name[0]);
470 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (callback_symbol != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
471
472 if (!priv->callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks.)
473 priv->callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks. = g_hash_table_new_fullcxx . . $ g_hash_table_new_full(e2dd12b570de7430). (g_str_hashcxx . . $ g_str_hash(b11f534102b1ad6)., g_str_equalcxx . . $ g_str_equal(9148c8c3ff42c9d8).,
474 g_freecxx . . $ g_free(5d22bdacc48458e8)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
475
476 g_hash_table_insertcxx . . $ g_hash_table_insert(6a7c46015dd5ef26). (priv->callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks., g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (callback_name), callback_symbol);
477 }
478
479 /**
480 * gtk_builder_cscope_add_callback_symbols: (skip)
481 * @self: a `GtkBuilderCScope`
482 * @first_callback_name: The name of the callback, as expected in the XML
483 * @first_callback_symbol: (scope async): The callback pointer
484 * @...: A list of callback name and callback symbol pairs terminated with %NULL
485 *
486 * A convenience function to add many callbacks.
487 *
488 * This is equivalent to calling [[email protected]_callback_symbol]
489 * for each symbol.
490 */
491 void
492 gtk_builder_cscope_add_callback_symbolscxx . . $ gtk_builder_cscope_add_callback_symbols(9e0b2d74e69fe4fa). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
493 const char *first_callback_name,
494 GCallbackcxx . . $ GCallback# first_callback_symbol,
495 ...)
496 {
497 va_listcxx . . $ va_list# var_args;
498 const char *callback_name;
499 GCallbackcxx . . $ GCallback# callback_symbol;
500
501 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (GTK_IS_BUILDER_CSCOPE (self));
502 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (first_callback_name && first_callback_name[0]);
503 g_return_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:652:9`! (first_callback_symbol != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
504
505 callback_name = first_callback_name;
506 callback_symbol = first_callback_symbol;
507
508 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`! (var_args, first_callback_symbol);
509
510 do {
511
512 gtk_builder_cscope_add_callback_symbolcxx . . $ gtk_builder_cscope_add_callback_symbol(f36adce1b9e0d506). (self, callback_name, callback_symbol);
513
514 callback_name = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`! (var_args, const char *);
515
516 if (callback_name)
517 callback_symbol = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`! (var_args, GCallback);
518
519 } while (callback_name != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
520
521 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`! (var_args);
522 }
523
524 /**
525 * gtk_builder_cscope_lookup_callback_symbol: (skip)
526 * @self: a `GtkBuilderCScope`
527 * @callback_name: The name of the callback
528 *
529 * Fetches a symbol previously added with
530 * gtk_builder_cscope_add_callback_symbol().
531 *
532 * Returns: (nullable) (transfer none): The callback symbol
533 * in @builder for @callback_name
534 */
535 GCallbackcxx . . $ GCallback#
536 gtk_builder_cscope_lookup_callback_symbolcxx . . $ gtk_builder_cscope_lookup_callback_symbol(744102708ba20df). (GtkBuilderCScopecxx . . $ GtkBuilderCScope# *self,
537 const char *callback_name)
538 {
539 GtkBuilderCScopePrivatecxx . . $ GtkBuilderCScopePrivate# *priv = gtk_builder_cscope_get_instance_privatecxx . . $ gtk_builder_cscope_get_instance_private(3ec2f35a9aa53088). (self);
540
541 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (GTK_IS_BUILDER_CSCOPE (self), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
542 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (callback_name && callback_name[0], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
543
544 if (priv->callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
545 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
546
547 return g_hash_table_lookupcxx . . $ g_hash_table_lookup(8183d62c39a6a245). (priv->callbackscxx . . $ _GtkBuilderCScopePrivate#callbacks., callback_name);
548 }
549