| File: | _build/tmp-introspecthq_66wld/CtkSource-4.c |
| Warning: | line 239, column 11 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* This file is generated, do not edit */ |
| 2 | |
| 3 | #undef GLIB_VERSION_MIN_REQUIRED((((2) << 16 | (84) << 8))) |
| 4 | #undef GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (84) << 8))) |
| 5 | |
| 6 | #include <glib.h> |
| 7 | #include <string.h> |
| 8 | #include <stdlib.h> |
| 9 | |
| 10 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- |
| 11 | * GObject introspection: Dump introspection data |
| 12 | * |
| 13 | * Copyright (C) 2008 Colin Walters <walters@verbum.org> |
| 14 | * |
| 15 | * SPDX-License-Identifier: LGPL-2.1-or-later |
| 16 | * |
| 17 | * This library is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU Lesser General Public |
| 19 | * License as published by the Free Software Foundation; either |
| 20 | * version 2 of the License, or (at your option) any later version. |
| 21 | * |
| 22 | * This library is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 25 | * Lesser General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU Lesser General Public |
| 28 | * License along with this library; if not, write to the |
| 29 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 30 | * Boston, MA 02111-1307, USA. |
| 31 | */ |
| 32 | |
| 33 | /* This file is both compiled into libgirepository.so, and installed |
| 34 | * on the filesystem. But for the dumper, we want to avoid linking |
| 35 | * to libgirepository; see |
| 36 | * https://bugzilla.gnome.org/show_bug.cgi?id=630342 |
| 37 | */ |
| 38 | #ifdef G_IREPOSITORY_COMPILATION |
| 39 | #include "config.h" |
| 40 | #include "girepository.h" |
| 41 | #endif |
| 42 | |
| 43 | #include <glib.h> |
| 44 | #include <glib-object.h> |
| 45 | #include <gmodule.h> |
| 46 | |
| 47 | #include <stdlib.h> |
| 48 | #include <stdio.h> |
| 49 | #include <string.h> |
| 50 | |
| 51 | /* Analogue of g_output_stream_write_all(). */ |
| 52 | static gboolean |
| 53 | write_all (FILE *out, |
| 54 | const void *buffer, |
| 55 | gsize count, |
| 56 | gsize *bytes_written, |
| 57 | GError **error) |
| 58 | { |
| 59 | size_t ret; |
| 60 | |
| 61 | ret = fwrite (buffer, 1, count, out); |
| 62 | |
| 63 | if (bytes_written != NULL((void*)0)) |
| 64 | *bytes_written = ret; |
| 65 | |
| 66 | if (ret < count) |
| 67 | { |
| 68 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED, |
| 69 | "Failed to write to file"); |
| 70 | return FALSE(0); |
| 71 | } |
| 72 | |
| 73 | return TRUE(!(0)); |
| 74 | } |
| 75 | |
| 76 | /* Analogue of g_data_input_stream_read_line(). */ |
| 77 | static char * |
| 78 | read_line (FILE *input, |
| 79 | size_t *len_out) |
| 80 | { |
| 81 | GByteArray *buffer = g_byte_array_new (); |
| 82 | const guint8 nul = '\0'; |
| 83 | |
| 84 | while (TRUE(!(0))) |
| 85 | { |
| 86 | size_t ret; |
| 87 | guint8 byte; |
| 88 | |
| 89 | ret = fread (&byte, 1, 1, input); |
| 90 | if (ret == 0) |
| 91 | break; |
| 92 | |
| 93 | if (byte == '\n') |
| 94 | break; |
| 95 | |
| 96 | g_byte_array_append (buffer, &byte, 1); |
| 97 | } |
| 98 | |
| 99 | g_byte_array_append (buffer, &nul, 1); |
| 100 | |
| 101 | if (len_out != NULL((void*)0)) |
| 102 | *len_out = buffer->len - 1; /* don’t include terminating nul */ |
| 103 | |
| 104 | return (char *) g_byte_array_free (buffer, FALSE(0)); |
| 105 | } |
| 106 | |
| 107 | static void |
| 108 | escaped_printf (FILE *out, const char *fmt, ...) G_GNUC_PRINTF (2, 3)__attribute__((__format__ (__printf__, 2, 3))); |
| 109 | |
| 110 | static void |
| 111 | escaped_printf (FILE *out, const char *fmt, ...) |
| 112 | { |
| 113 | char *str; |
| 114 | va_list args; |
| 115 | gsize written; |
| 116 | GError *error = NULL((void*)0); |
| 117 | |
| 118 | va_start (args, fmt)__builtin_va_start(args, fmt); |
| 119 | |
| 120 | str = g_markup_vprintf_escaped (fmt, args); |
| 121 | if (!write_all (out, str, strlen (str), &written, &error)) |
| 122 | { |
| 123 | g_critical ("failed to write to iochannel: %s", error->message); |
| 124 | g_clear_error (&error); |
| 125 | } |
| 126 | g_free (str); |
| 127 | |
| 128 | va_end (args)__builtin_va_end(args); |
| 129 | } |
| 130 | |
| 131 | static void |
| 132 | goutput_write (FILE *out, const char *str) |
| 133 | { |
| 134 | gsize written; |
| 135 | GError *error = NULL((void*)0); |
| 136 | if (!write_all (out, str, strlen (str), &written, &error)) |
| 137 | { |
| 138 | g_critical ("failed to write to iochannel: %s", error->message); |
| 139 | g_clear_error (&error); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | typedef GType (*GetTypeFunc)(void); |
| 144 | typedef GQuark (*ErrorQuarkFunc)(void); |
| 145 | |
| 146 | static GType |
| 147 | invoke_get_type (GModule *self, const char *symbol, GError **error) |
| 148 | { |
| 149 | GetTypeFunc sym; |
| 150 | GType ret; |
| 151 | |
| 152 | if (!g_module_symbol (self, symbol, (void**)&sym)) |
| 153 | { |
| 154 | g_set_error (error, |
| 155 | G_FILE_ERRORg_file_error_quark (), |
| 156 | G_FILE_ERROR_FAILED, |
| 157 | "Failed to find symbol '%s'", symbol); |
| 158 | return G_TYPE_INVALID((GType) ((0) << (2))); |
| 159 | } |
| 160 | |
| 161 | ret = sym (); |
| 162 | if (ret == G_TYPE_INVALID((GType) ((0) << (2)))) |
| 163 | { |
| 164 | g_set_error (error, |
| 165 | G_FILE_ERRORg_file_error_quark (), |
| 166 | G_FILE_ERROR_FAILED, |
| 167 | "Function '%s' returned G_TYPE_INVALID", symbol); |
| 168 | } |
| 169 | return ret; |
| 170 | } |
| 171 | |
| 172 | static GQuark |
| 173 | invoke_error_quark (GModule *self, const char *symbol, GError **error) |
| 174 | { |
| 175 | ErrorQuarkFunc sym; |
| 176 | |
| 177 | if (!g_module_symbol (self, symbol, (void**)&sym)) |
| 178 | { |
| 179 | g_set_error (error, |
| 180 | G_FILE_ERRORg_file_error_quark (), |
| 181 | G_FILE_ERROR_FAILED, |
| 182 | "Failed to find symbol '%s'", symbol); |
| 183 | return G_TYPE_INVALID((GType) ((0) << (2))); |
| 184 | } |
| 185 | |
| 186 | return sym (); |
| 187 | } |
| 188 | |
| 189 | static char * |
| 190 | value_transform_to_string (const GValue *value) |
| 191 | { |
| 192 | GValue tmp = G_VALUE_INIT{ 0, { { 0 } } }; |
| 193 | char *s = NULL((void*)0); |
| 194 | |
| 195 | g_value_init (&tmp, G_TYPE_STRING((GType) ((16) << (2)))); |
| 196 | |
| 197 | if (g_value_transform (value, &tmp)) |
| 198 | { |
| 199 | const char *str = g_value_get_string (&tmp); |
| 200 | |
| 201 | if (str != NULL((void*)0)) |
| 202 | s = g_strescape (str, NULL((void*)0)); |
| 203 | } |
| 204 | |
| 205 | g_value_unset (&tmp); |
| 206 | |
| 207 | return s; |
| 208 | } |
| 209 | |
| 210 | /* A simpler version of g_strdup_value_contents(), but with stable |
| 211 | * output and less complex semantics |
| 212 | */ |
| 213 | static char * |
| 214 | value_to_string (const GValue *value) |
| 215 | { |
| 216 | if (value == NULL((void*)0)) |
| 217 | return NULL((void*)0); |
| 218 | |
| 219 | if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value )); GType __t = (((GType) ((16) << (2)))); gboolean __r ; if (!__val) __r = (0); else if (__val->g_type == __t) __r = (!(0)); else __r = g_type_check_value_holds (__val, __t); __r ; }))))) |
| 220 | { |
| 221 | const char *s = g_value_get_string (value); |
| 222 | |
| 223 | if (s == NULL((void*)0)) |
| 224 | return g_strdup ("NULL")g_strdup_inline ("NULL"); |
| 225 | |
| 226 | return g_strescape (s, NULL((void*)0)); |
| 227 | } |
| 228 | else |
| 229 | { |
| 230 | GType value_type = G_VALUE_TYPE (value)(((GValue*) (value))->g_type); |
| 231 | |
| 232 | switch (G_TYPE_FUNDAMENTAL (value_type)(g_type_fundamental (value_type))) |
| 233 | { |
| 234 | case G_TYPE_BOXED((GType) ((18) << (2))): |
| 235 | if (g_value_get_boxed (value) == NULL((void*)0)) |
| 236 | return NULL((void*)0); |
| 237 | else |
| 238 | return value_transform_to_string (value); |
| 239 | break; |
This statement is never executed | |
| 240 | |
| 241 | case G_TYPE_OBJECT((GType) ((20) << (2))): |
| 242 | if (g_value_get_object (value) == NULL((void*)0)) |
| 243 | return NULL((void*)0); |
| 244 | else |
| 245 | return value_transform_to_string (value); |
| 246 | break; |
| 247 | |
| 248 | case G_TYPE_POINTER((GType) ((17) << (2))): |
| 249 | return NULL((void*)0); |
| 250 | |
| 251 | default: |
| 252 | return value_transform_to_string (value); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | return NULL((void*)0); |
| 257 | } |
| 258 | |
| 259 | static void |
| 260 | dump_properties (GType type, FILE *out) |
| 261 | { |
| 262 | guint i; |
| 263 | guint n_properties = 0; |
| 264 | GParamSpec **props; |
| 265 | |
| 266 | if (G_TYPE_FUNDAMENTAL (type)(g_type_fundamental (type)) == G_TYPE_OBJECT((GType) ((20) << (2)))) |
| 267 | { |
| 268 | GObjectClass *klass; |
| 269 | klass = g_type_class_ref (type); |
| 270 | props = g_object_class_list_properties (klass, &n_properties); |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | void *klass; |
| 275 | klass = g_type_default_interface_ref (type); |
| 276 | props = g_object_interface_list_properties (klass, &n_properties); |
| 277 | } |
| 278 | |
| 279 | for (i = 0; i < n_properties; i++) |
| 280 | { |
| 281 | GParamSpec *prop; |
| 282 | |
| 283 | prop = props[i]; |
| 284 | if (prop->owner_type != type) |
| 285 | continue; |
| 286 | |
| 287 | const GValue *v = g_param_spec_get_default_value (prop); |
| 288 | char *default_value = value_to_string (v); |
| 289 | |
| 290 | if (v != NULL((void*)0) && default_value != NULL((void*)0)) |
| 291 | { |
| 292 | escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n", |
| 293 | prop->name, |
| 294 | g_type_name (prop->value_type), |
| 295 | prop->flags, |
| 296 | default_value); |
| 297 | } |
| 298 | else |
| 299 | { |
| 300 | escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\"/>\n", |
| 301 | prop->name, |
| 302 | g_type_name (prop->value_type), |
| 303 | prop->flags); |
| 304 | } |
| 305 | |
| 306 | g_free (default_value); |
| 307 | } |
| 308 | |
| 309 | g_free (props); |
| 310 | } |
| 311 | |
| 312 | static void |
| 313 | dump_signals (GType type, FILE *out) |
| 314 | { |
| 315 | guint i; |
| 316 | guint n_sigs; |
| 317 | guint *sig_ids; |
| 318 | |
| 319 | sig_ids = g_signal_list_ids (type, &n_sigs); |
| 320 | for (i = 0; i < n_sigs; i++) |
| 321 | { |
| 322 | guint sigid; |
| 323 | GSignalQuery query; |
| 324 | guint j; |
| 325 | |
| 326 | sigid = sig_ids[i]; |
| 327 | g_signal_query (sigid, &query); |
| 328 | |
| 329 | escaped_printf (out, " <signal name=\"%s\" return=\"%s\"", |
| 330 | query.signal_name, g_type_name (query.return_type)); |
| 331 | |
| 332 | if (query.signal_flags & G_SIGNAL_RUN_FIRST) |
| 333 | escaped_printf (out, " when=\"first\""); |
| 334 | else if (query.signal_flags & G_SIGNAL_RUN_LAST) |
| 335 | escaped_printf (out, " when=\"last\""); |
| 336 | else if (query.signal_flags & G_SIGNAL_RUN_CLEANUP) |
| 337 | escaped_printf (out, " when=\"cleanup\""); |
| 338 | else if (query.signal_flags & G_SIGNAL_MUST_COLLECT) |
| 339 | escaped_printf (out, " when=\"must-collect\""); |
| 340 | if (query.signal_flags & G_SIGNAL_NO_RECURSE) |
| 341 | escaped_printf (out, " no-recurse=\"1\""); |
| 342 | |
| 343 | if (query.signal_flags & G_SIGNAL_DETAILED) |
| 344 | escaped_printf (out, " detailed=\"1\""); |
| 345 | |
| 346 | if (query.signal_flags & G_SIGNAL_ACTION) |
| 347 | escaped_printf (out, " action=\"1\""); |
| 348 | |
| 349 | if (query.signal_flags & G_SIGNAL_NO_HOOKS) |
| 350 | escaped_printf (out, " no-hooks=\"1\""); |
| 351 | |
| 352 | goutput_write (out, ">\n"); |
| 353 | |
| 354 | for (j = 0; j < query.n_params; j++) |
| 355 | { |
| 356 | escaped_printf (out, " <param type=\"%s\"/>\n", |
| 357 | g_type_name (query.param_types[j])); |
| 358 | } |
| 359 | goutput_write (out, " </signal>\n"); |
| 360 | } |
| 361 | g_free (sig_ids); |
| 362 | } |
| 363 | |
| 364 | static void |
| 365 | dump_object_type (GType type, const char *symbol, FILE *out) |
| 366 | { |
| 367 | guint n_interfaces; |
| 368 | guint i; |
| 369 | GType *interfaces; |
| 370 | |
| 371 | escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"", |
| 372 | g_type_name (type), symbol); |
| 373 | if (type != G_TYPE_OBJECT((GType) ((20) << (2)))) |
| 374 | { |
| 375 | GString *parent_str; |
| 376 | GType parent; |
| 377 | gboolean first = TRUE(!(0)); |
| 378 | |
| 379 | parent = g_type_parent (type); |
| 380 | parent_str = g_string_new (""); |
| 381 | while (parent != G_TYPE_INVALID((GType) ((0) << (2)))) |
| 382 | { |
| 383 | if (first) |
| 384 | first = FALSE(0); |
| 385 | else |
| 386 | g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ','); |
| 387 | g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ ( { const char * const __val = (g_type_name (parent)); g_string_append_len_inline (parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen ( ((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (parent_str, g_type_name (parent), (gssize) -1)); |
| 388 | parent = g_type_parent (parent); |
| 389 | } |
| 390 | |
| 391 | escaped_printf (out, " parents=\"%s\"", parent_str->str); |
| 392 | |
| 393 | g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (parent_str), ((!(0)))) : g_string_free_and_steal (parent_str )) : (g_string_free) ((parent_str), ((!(0))))); |
| 394 | } |
| 395 | |
| 396 | if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))) |
| 397 | escaped_printf (out, " abstract=\"1\""); |
| 398 | |
| 399 | if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL))) |
| 400 | escaped_printf (out, " final=\"1\""); |
| 401 | |
| 402 | goutput_write (out, ">\n"); |
| 403 | |
| 404 | interfaces = g_type_interfaces (type, &n_interfaces); |
| 405 | for (i = 0; i < n_interfaces; i++) |
| 406 | { |
| 407 | GType itype = interfaces[i]; |
| 408 | escaped_printf (out, " <implements name=\"%s\"/>\n", |
| 409 | g_type_name (itype)); |
| 410 | } |
| 411 | g_free (interfaces); |
| 412 | |
| 413 | dump_properties (type, out); |
| 414 | dump_signals (type, out); |
| 415 | goutput_write (out, " </class>\n"); |
| 416 | } |
| 417 | |
| 418 | static void |
| 419 | dump_interface_type (GType type, const char *symbol, FILE *out) |
| 420 | { |
| 421 | guint n_interfaces; |
| 422 | guint i; |
| 423 | GType *interfaces; |
| 424 | |
| 425 | escaped_printf (out, " <interface name=\"%s\" get-type=\"%s\">\n", |
| 426 | g_type_name (type), symbol); |
| 427 | |
| 428 | interfaces = g_type_interface_prerequisites (type, &n_interfaces); |
| 429 | for (i = 0; i < n_interfaces; i++) |
| 430 | { |
| 431 | GType itype = interfaces[i]; |
| 432 | if (itype == G_TYPE_OBJECT((GType) ((20) << (2)))) |
| 433 | { |
| 434 | /* Treat this as implicit for now; in theory GInterfaces are |
| 435 | * supported on things like GstMiniObject, but right now |
| 436 | * the introspection system only supports GObject. |
| 437 | * http://bugzilla.gnome.org/show_bug.cgi?id=559706 |
| 438 | */ |
| 439 | continue; |
| 440 | } |
| 441 | escaped_printf (out, " <prerequisite name=\"%s\"/>\n", |
| 442 | g_type_name (itype)); |
| 443 | } |
| 444 | g_free (interfaces); |
| 445 | |
| 446 | dump_properties (type, out); |
| 447 | dump_signals (type, out); |
| 448 | goutput_write (out, " </interface>\n"); |
| 449 | } |
| 450 | |
| 451 | static void |
| 452 | dump_boxed_type (GType type, const char *symbol, FILE *out) |
| 453 | { |
| 454 | escaped_printf (out, " <boxed name=\"%s\" get-type=\"%s\"/>\n", |
| 455 | g_type_name (type), symbol); |
| 456 | } |
| 457 | |
| 458 | static void |
| 459 | dump_pointer_type (GType type, const char *symbol, FILE *out) |
| 460 | { |
| 461 | escaped_printf (out, " <pointer name=\"%s\" get-type=\"%s\"/>\n", |
| 462 | g_type_name (type), symbol); |
| 463 | } |
| 464 | |
| 465 | static void |
| 466 | dump_flags_type (GType type, const char *symbol, FILE *out) |
| 467 | { |
| 468 | guint i; |
| 469 | GFlagsClass *klass; |
| 470 | |
| 471 | klass = g_type_class_ref (type); |
| 472 | escaped_printf (out, " <flags name=\"%s\" get-type=\"%s\">\n", |
| 473 | g_type_name (type), symbol); |
| 474 | |
| 475 | for (i = 0; i < klass->n_values; i++) |
| 476 | { |
| 477 | GFlagsValue *value = &(klass->values[i]); |
| 478 | |
| 479 | escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%u\"/>\n", |
| 480 | value->value_name, value->value_nick, value->value); |
| 481 | } |
| 482 | goutput_write (out, " </flags>\n"); |
| 483 | } |
| 484 | |
| 485 | static void |
| 486 | dump_enum_type (GType type, const char *symbol, FILE *out) |
| 487 | { |
| 488 | guint i; |
| 489 | GEnumClass *klass; |
| 490 | |
| 491 | klass = g_type_class_ref (type); |
| 492 | escaped_printf (out, " <enum name=\"%s\" get-type=\"%s\">\n", |
| 493 | g_type_name (type), symbol); |
| 494 | |
| 495 | for (i = 0; i < klass->n_values; i++) |
| 496 | { |
| 497 | GEnumValue *value = &(klass->values[i]); |
| 498 | |
| 499 | escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n", |
| 500 | value->value_name, value->value_nick, value->value); |
| 501 | } |
| 502 | goutput_write (out, " </enum>"); |
| 503 | } |
| 504 | |
| 505 | static void |
| 506 | dump_fundamental_type (GType type, const char *symbol, FILE *out) |
| 507 | { |
| 508 | guint n_interfaces; |
| 509 | guint i; |
| 510 | GType *interfaces; |
| 511 | GString *parent_str; |
| 512 | GType parent; |
| 513 | gboolean first = TRUE(!(0)); |
| 514 | |
| 515 | |
| 516 | escaped_printf (out, " <fundamental name=\"%s\" get-type=\"%s\"", |
| 517 | g_type_name (type), symbol); |
| 518 | |
| 519 | if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))) |
| 520 | escaped_printf (out, " abstract=\"1\""); |
| 521 | |
| 522 | if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL))) |
| 523 | escaped_printf (out, " final=\"1\""); |
| 524 | |
| 525 | if (G_TYPE_IS_INSTANTIATABLE (type)(g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))) |
| 526 | escaped_printf (out, " instantiatable=\"1\""); |
| 527 | |
| 528 | parent = g_type_parent (type); |
| 529 | parent_str = g_string_new (""); |
| 530 | while (parent != G_TYPE_INVALID((GType) ((0) << (2)))) |
| 531 | { |
| 532 | if (first) |
| 533 | first = FALSE(0); |
| 534 | else |
| 535 | g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ','); |
| 536 | if (!g_type_name (parent)) |
| 537 | break; |
| 538 | g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ ( { const char * const __val = (g_type_name (parent)); g_string_append_len_inline (parent_str, __val, (__val != ((void*)0)) ? (gssize) strlen ( ((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline (parent_str, g_type_name (parent), (gssize) -1)); |
| 539 | parent = g_type_parent (parent); |
| 540 | } |
| 541 | |
| 542 | if (parent_str->len > 0) |
| 543 | escaped_printf (out, " parents=\"%s\"", parent_str->str); |
| 544 | g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) ( (parent_str), ((!(0)))) : g_string_free_and_steal (parent_str )) : (g_string_free) ((parent_str), ((!(0))))); |
| 545 | |
| 546 | goutput_write (out, ">\n"); |
| 547 | |
| 548 | interfaces = g_type_interfaces (type, &n_interfaces); |
| 549 | for (i = 0; i < n_interfaces; i++) |
| 550 | { |
| 551 | GType itype = interfaces[i]; |
| 552 | escaped_printf (out, " <implements name=\"%s\"/>\n", |
| 553 | g_type_name (itype)); |
| 554 | } |
| 555 | g_free (interfaces); |
| 556 | goutput_write (out, " </fundamental>\n"); |
| 557 | } |
| 558 | |
| 559 | static void |
| 560 | dump_type (GType type, const char *symbol, FILE *out) |
| 561 | { |
| 562 | /* XXX: We need to ensure that global ancillary structures like |
| 563 | * GParamSpecPool are initialized before we use the GType and |
| 564 | * GObject reflection API to poke at things like properties and |
| 565 | * signals; we cannot rely on GObject being instantiated at this |
| 566 | * point. |
| 567 | */ |
| 568 | GObjectClass *gobject_class = g_type_class_ref (G_TYPE_OBJECT((GType) ((20) << (2)))); |
| 569 | |
| 570 | switch (g_type_fundamental (type)) |
| 571 | { |
| 572 | case G_TYPE_OBJECT((GType) ((20) << (2))): |
| 573 | dump_object_type (type, symbol, out); |
| 574 | break; |
| 575 | case G_TYPE_INTERFACE((GType) ((2) << (2))): |
| 576 | dump_interface_type (type, symbol, out); |
| 577 | break; |
| 578 | case G_TYPE_BOXED((GType) ((18) << (2))): |
| 579 | dump_boxed_type (type, symbol, out); |
| 580 | break; |
| 581 | case G_TYPE_FLAGS((GType) ((13) << (2))): |
| 582 | dump_flags_type (type, symbol, out); |
| 583 | break; |
| 584 | case G_TYPE_ENUM((GType) ((12) << (2))): |
| 585 | dump_enum_type (type, symbol, out); |
| 586 | break; |
| 587 | case G_TYPE_POINTER((GType) ((17) << (2))): |
| 588 | dump_pointer_type (type, symbol, out); |
| 589 | break; |
| 590 | default: |
| 591 | dump_fundamental_type (type, symbol, out); |
| 592 | break; |
| 593 | } |
| 594 | |
| 595 | g_type_class_unref ((GTypeClass *) gobject_class); |
| 596 | } |
| 597 | |
| 598 | static void |
| 599 | dump_error_quark (GQuark quark, const char *symbol, FILE *out) |
| 600 | { |
| 601 | escaped_printf (out, " <error-quark function=\"%s\" domain=\"%s\"/>\n", |
| 602 | symbol, g_quark_to_string (quark)); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * g_irepository_dump: |
| 607 | * @input_filename: (type filename): Input filename (for example `input.txt`) |
| 608 | * @output_filename: (type filename): Output filename (for example `output.xml`) |
| 609 | * @error: a %GError |
| 610 | * |
| 611 | * Dump the introspection data from the types specified in @input_filename to |
| 612 | * @output_filename. |
| 613 | * |
| 614 | * The input file should be a |
| 615 | * UTF-8 Unix-line-ending text file, with each line containing either |
| 616 | * `get-type:` followed by the name of a [type@GObject.Type] `_get_type` |
| 617 | * function, or `error-quark:` followed by the name of an error quark function. |
| 618 | * No extra whitespace is allowed. |
| 619 | * |
| 620 | * This function will overwrite the contents of the output file. |
| 621 | * |
| 622 | * Returns: true on success, false on error |
| 623 | * Since: 2.80 |
| 624 | */ |
| 625 | #ifndef G_IREPOSITORY_COMPILATION |
| 626 | static gboolean |
| 627 | dump_irepository (const char *arg, |
| 628 | GError **error) G_GNUC_UNUSED__attribute__ ((__unused__)); |
| 629 | static gboolean |
| 630 | dump_irepository (const char *arg, |
| 631 | GError **error) |
| 632 | #else |
| 633 | gboolean |
| 634 | g_irepository_dump (const char *arg, |
| 635 | GError **error) |
| 636 | #endif |
| 637 | { |
| 638 | GHashTable *output_types; |
| 639 | FILE *input; |
| 640 | FILE *output; |
| 641 | GModule *self; |
| 642 | gboolean caught_error = FALSE(0); |
| 643 | |
| 644 | char **args = g_strsplit (arg, ",", 2); |
| 645 | if (args == NULL((void*)0)) |
| 646 | { |
| 647 | g_set_error (error, |
| 648 | G_FILE_ERRORg_file_error_quark (), |
| 649 | G_FILE_ERROR_FAILED, |
| 650 | "Usage: --introspect-dump=input,output"); |
| 651 | return FALSE(0); |
| 652 | } |
| 653 | |
| 654 | const char *input_filename = args[0]; |
| 655 | const char *output_filename = args[1]; |
| 656 | |
| 657 | self = g_module_open (NULL((void*)0), 0); |
| 658 | if (!self) |
| 659 | { |
| 660 | g_set_error (error, |
| 661 | G_FILE_ERRORg_file_error_quark (), |
| 662 | G_FILE_ERROR_FAILED, |
| 663 | "failed to open self: %s", |
| 664 | g_module_error ()); |
| 665 | g_strfreev (args); |
| 666 | return FALSE(0); |
| 667 | } |
| 668 | |
| 669 | input = fopen (input_filename, "rb"); |
| 670 | if (input == NULL((void*)0)) |
| 671 | { |
| 672 | int saved_errno = errno(*__errno_location ()); |
| 673 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno), |
| 674 | "Failed to open ‘%s’: %s", input_filename, g_strerror (saved_errno)); |
| 675 | |
| 676 | g_module_close (self); |
| 677 | g_strfreev (args); |
| 678 | |
| 679 | return FALSE(0); |
| 680 | } |
| 681 | |
| 682 | output = fopen (output_filename, "wb"); |
| 683 | if (output == NULL((void*)0)) |
| 684 | { |
| 685 | int saved_errno = errno(*__errno_location ()); |
| 686 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno), |
| 687 | "Failed to open ‘%s’: %s", output_filename, g_strerror (saved_errno)); |
| 688 | |
| 689 | fclose (input); |
| 690 | g_module_close (self); |
| 691 | g_strfreev (args); |
| 692 | |
| 693 | return FALSE(0); |
| 694 | } |
| 695 | |
| 696 | goutput_write (output, "<?xml version=\"1.0\"?>\n"); |
| 697 | goutput_write (output, "<dump>\n"); |
| 698 | |
| 699 | output_types = g_hash_table_new (NULL((void*)0), NULL((void*)0)); |
| 700 | |
| 701 | while (TRUE(!(0))) |
| 702 | { |
| 703 | gsize len; |
| 704 | char *line = read_line (input, &len); |
| 705 | const char *function; |
| 706 | |
| 707 | if (line == NULL((void*)0) || *line == '\0') |
| 708 | { |
| 709 | g_free (line); |
| 710 | break; |
| 711 | } |
| 712 | |
| 713 | g_strchomp (line); |
| 714 | |
| 715 | if (strncmp (line, "get-type:", strlen ("get-type:")) == 0) |
| 716 | { |
| 717 | GType type; |
| 718 | |
| 719 | function = line + strlen ("get-type:"); |
| 720 | |
| 721 | type = invoke_get_type (self, function, error); |
| 722 | |
| 723 | if (type == G_TYPE_INVALID((GType) ((0) << (2)))) |
| 724 | { |
| 725 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED, |
| 726 | "Invalid GType function: %s", function); |
| 727 | caught_error = TRUE(!(0)); |
| 728 | g_free (line); |
| 729 | break; |
| 730 | } |
| 731 | |
| 732 | if (g_hash_table_lookup (output_types, (gpointer) type)) |
| 733 | goto next; |
| 734 | g_hash_table_insert (output_types, (gpointer) type, (gpointer) type); |
| 735 | |
| 736 | dump_type (type, function, output); |
| 737 | } |
| 738 | else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0) |
| 739 | { |
| 740 | GQuark quark; |
| 741 | function = line + strlen ("error-quark:"); |
| 742 | quark = invoke_error_quark (self, function, error); |
| 743 | |
| 744 | if (quark == 0) |
| 745 | { |
| 746 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), G_FILE_ERROR_FAILED, |
| 747 | "Invalid error quark function: %s", function); |
| 748 | caught_error = TRUE(!(0)); |
| 749 | g_free (line); |
| 750 | break; |
| 751 | } |
| 752 | |
| 753 | dump_error_quark (quark, function, output); |
| 754 | } |
| 755 | |
| 756 | |
| 757 | next: |
| 758 | g_free (line); |
| 759 | } |
| 760 | |
| 761 | g_hash_table_destroy (output_types); |
| 762 | |
| 763 | goutput_write (output, "</dump>\n"); |
| 764 | |
| 765 | { |
| 766 | /* Avoid overwriting an earlier set error */ |
| 767 | if (fclose (input) != 0 && !caught_error) |
| 768 | { |
| 769 | int saved_errno = errno(*__errno_location ()); |
| 770 | |
| 771 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno), |
| 772 | "Error closing input file ‘%s’: %s", input_filename, |
| 773 | g_strerror (saved_errno)); |
| 774 | caught_error = TRUE(!(0)); |
| 775 | } |
| 776 | |
| 777 | if (fclose (output) != 0 && !caught_error) |
| 778 | { |
| 779 | int saved_errno = errno(*__errno_location ()); |
| 780 | |
| 781 | g_set_error (error, G_FILE_ERRORg_file_error_quark (), g_file_error_from_errno (saved_errno), |
| 782 | "Error closing output file ‘%s’: %s", output_filename, |
| 783 | g_strerror (saved_errno)); |
| 784 | caught_error = TRUE(!(0)); |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | g_strfreev (args); |
| 789 | |
| 790 | return !caught_error; |
| 791 | } |
| 792 | |
| 793 | |
| 794 | int |
| 795 | main(int argc, char **argv) |
| 796 | { |
| 797 | GError *error = NULL((void*)0); |
| 798 | const char *introspect_dump_prefix = "--introspect-dump="; |
| 799 | |
| 800 | #if !GLIB_CHECK_VERSION(2,35,0)(2 > (2) || (2 == (2) && 84 > (35)) || (2 == (2 ) && 84 == (35) && 3 >= (0))) |
| 801 | g_type_init (); |
| 802 | #endif |
| 803 | |
| 804 | |
| 805 | |
| 806 | if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix)(__builtin_constant_p (introspect_dump_prefix)? __extension__ ({ const char * const __str = (argv[1]); const char * const __prefix = (introspect_dump_prefix); gboolean __result = (0); if (__str == ((void*)0) || __prefix == ((void*)0)) __result = (g_str_has_prefix ) (__str, __prefix); else { const size_t __str_len = strlen ( ((__str) + !(__str))); const size_t __prefix_len = strlen ((( __prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result = memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len ) == 0; } __result; }) : (g_str_has_prefix) (argv[1], introspect_dump_prefix ) )) |
| 807 | { |
| 808 | g_printerr ("Usage: %s --introspect-dump=input,output\n", argv[0]); |
| 809 | exit (1); |
| 810 | } |
| 811 | |
| 812 | if (!dump_irepository (argv[1] + strlen (introspect_dump_prefix), &error)) |
| 813 | { |
| 814 | g_assert (error != NULL)do { if (error != ((void*)0)) ; else g_assertion_message_expr (((gchar*) 0), "/rootdir/_build/tmp-introspecthq_66wld/CtkSource-4.c" , 814, ((const char*) (__func__)), "error != NULL"); } while ( 0); /* help the static analyser */ |
| 815 | g_printerr ("%s\n", error->message); |
| 816 | exit (1); |
| 817 | } |
| 818 | exit (0); |
| 819 | } |
| 820 | extern GType ctk_source_completion_context_get_type(void); |
| 821 | extern GType ctk_source_completion_provider_get_type(void); |
| 822 | extern GType ctk_source_completion_words_get_type(void); |
| 823 | extern GType ctk_source_buffer_get_type(void); |
| 824 | extern GType ctk_source_completion_get_type(void); |
| 825 | extern GType ctk_source_completion_info_get_type(void); |
| 826 | extern GType ctk_source_completion_item_get_type(void); |
| 827 | extern GType ctk_source_completion_proposal_get_type(void); |
| 828 | extern GType ctk_source_encoding_get_type(void); |
| 829 | extern GType ctk_source_file_get_type(void); |
| 830 | extern GType ctk_source_file_loader_get_type(void); |
| 831 | extern GType ctk_source_file_saver_get_type(void); |
| 832 | extern GType ctk_source_gutter_get_type(void); |
| 833 | extern GType ctk_source_gutter_renderer_get_type(void); |
| 834 | extern GType ctk_source_gutter_renderer_text_get_type(void); |
| 835 | extern GType ctk_source_gutter_renderer_pixbuf_get_type(void); |
| 836 | extern GType ctk_source_language_get_type(void); |
| 837 | extern GType ctk_source_language_manager_get_type(void); |
| 838 | extern GType ctk_source_view_get_type(void); |
| 839 | extern GType ctk_source_map_get_type(void); |
| 840 | extern GType ctk_source_mark_get_type(void); |
| 841 | extern GType ctk_source_mark_attributes_get_type(void); |
| 842 | extern GType ctk_source_print_compositor_get_type(void); |
| 843 | extern GType ctk_source_region_get_type(void); |
| 844 | extern GType ctk_source_search_context_get_type(void); |
| 845 | extern GType ctk_source_search_settings_get_type(void); |
| 846 | extern GType ctk_source_space_drawer_get_type(void); |
| 847 | extern GType ctk_source_style_get_type(void); |
| 848 | extern GType ctk_source_style_scheme_get_type(void); |
| 849 | extern GType ctk_source_style_scheme_chooser_get_type(void); |
| 850 | extern GType ctk_source_style_scheme_chooser_button_get_type(void); |
| 851 | extern GType ctk_source_style_scheme_chooser_widget_get_type(void); |
| 852 | extern GType ctk_source_style_scheme_manager_get_type(void); |
| 853 | extern GType ctk_source_tag_get_type(void); |
| 854 | extern GType ctk_source_undo_manager_get_type(void); |
| 855 | extern GType ctk_source_bracket_match_type_get_type(void); |
| 856 | extern GType ctk_source_change_case_type_get_type(void); |
| 857 | extern GType ctk_source_sort_flags_get_type(void); |
| 858 | extern GType ctk_source_completion_error_get_type(void); |
| 859 | extern GType ctk_source_completion_activation_get_type(void); |
| 860 | extern GType ctk_source_newline_type_get_type(void); |
| 861 | extern GType ctk_source_compression_type_get_type(void); |
| 862 | extern GType ctk_source_file_loader_error_get_type(void); |
| 863 | extern GType ctk_source_file_saver_error_get_type(void); |
| 864 | extern GType ctk_source_file_saver_flags_get_type(void); |
| 865 | extern GType ctk_source_gutter_renderer_state_get_type(void); |
| 866 | extern GType ctk_source_gutter_renderer_alignment_mode_get_type(void); |
| 867 | extern GType ctk_source_space_type_flags_get_type(void); |
| 868 | extern GType ctk_source_space_location_flags_get_type(void); |
| 869 | extern GType ctk_source_view_gutter_position_get_type(void); |
| 870 | extern GType ctk_source_smart_home_end_type_get_type(void); |
| 871 | extern GType ctk_source_background_pattern_type_get_type(void); |
| 872 | G_MODULE_EXPORT__attribute__((visibility("default"))) GType (*GI_GET_TYPE_FUNCS_[])(void) = { |
| 873 | ctk_source_completion_context_get_type, |
| 874 | ctk_source_completion_provider_get_type, |
| 875 | ctk_source_completion_words_get_type, |
| 876 | ctk_source_buffer_get_type, |
| 877 | ctk_source_completion_get_type, |
| 878 | ctk_source_completion_info_get_type, |
| 879 | ctk_source_completion_item_get_type, |
| 880 | ctk_source_completion_proposal_get_type, |
| 881 | ctk_source_encoding_get_type, |
| 882 | ctk_source_file_get_type, |
| 883 | ctk_source_file_loader_get_type, |
| 884 | ctk_source_file_saver_get_type, |
| 885 | ctk_source_gutter_get_type, |
| 886 | ctk_source_gutter_renderer_get_type, |
| 887 | ctk_source_gutter_renderer_text_get_type, |
| 888 | ctk_source_gutter_renderer_pixbuf_get_type, |
| 889 | ctk_source_language_get_type, |
| 890 | ctk_source_language_manager_get_type, |
| 891 | ctk_source_view_get_type, |
| 892 | ctk_source_map_get_type, |
| 893 | ctk_source_mark_get_type, |
| 894 | ctk_source_mark_attributes_get_type, |
| 895 | ctk_source_print_compositor_get_type, |
| 896 | ctk_source_region_get_type, |
| 897 | ctk_source_search_context_get_type, |
| 898 | ctk_source_search_settings_get_type, |
| 899 | ctk_source_space_drawer_get_type, |
| 900 | ctk_source_style_get_type, |
| 901 | ctk_source_style_scheme_get_type, |
| 902 | ctk_source_style_scheme_chooser_get_type, |
| 903 | ctk_source_style_scheme_chooser_button_get_type, |
| 904 | ctk_source_style_scheme_chooser_widget_get_type, |
| 905 | ctk_source_style_scheme_manager_get_type, |
| 906 | ctk_source_tag_get_type, |
| 907 | ctk_source_undo_manager_get_type, |
| 908 | ctk_source_bracket_match_type_get_type, |
| 909 | ctk_source_change_case_type_get_type, |
| 910 | ctk_source_sort_flags_get_type, |
| 911 | ctk_source_completion_error_get_type, |
| 912 | ctk_source_completion_activation_get_type, |
| 913 | ctk_source_newline_type_get_type, |
| 914 | ctk_source_compression_type_get_type, |
| 915 | ctk_source_file_loader_error_get_type, |
| 916 | ctk_source_file_saver_error_get_type, |
| 917 | ctk_source_file_saver_flags_get_type, |
| 918 | ctk_source_gutter_renderer_state_get_type, |
| 919 | ctk_source_gutter_renderer_alignment_mode_get_type, |
| 920 | ctk_source_space_type_flags_get_type, |
| 921 | ctk_source_space_location_flags_get_type, |
| 922 | ctk_source_view_gutter_position_get_type, |
| 923 | ctk_source_smart_home_end_type_get_type, |
| 924 | ctk_source_background_pattern_type_get_type |
| 925 | }; |
| 926 | extern GQuark ctk_source_completion_error_quark(void); |
| 927 | extern GQuark ctk_source_file_loader_error_quark(void); |
| 928 | extern GQuark ctk_source_file_saver_error_quark(void); |
| 929 | G_MODULE_EXPORT__attribute__((visibility("default"))) GQuark (*GI_ERROR_QUARK_FUNCS_[])(void) = { |
| 930 | ctk_source_completion_error_quark, |
| 931 | ctk_source_file_loader_error_quark, |
| 932 | ctk_source_file_saver_error_quark |
| 933 | }; |