From cf28391d5b7e8b415ebac027ce29abbf35ffc561 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 8 Nov 2023 12:39:19 +0000 Subject: [PATCH 01/31] gir: Build introspection data for libgirepository We currently add the GI and gi prefixes, but outside of visibility macros we should move every identifier to the G namespace. --- girepository/meson.build | 46 ++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/girepository/meson.build b/girepository/meson.build index 0c4e9d100..f8ab670b3 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -23,10 +23,10 @@ subdir('cmph') gir_dir_prefix = get_option('gir_dir_prefix') if gir_dir_prefix == '' or gir_dir_prefix == get_option('datadir') - gir_dir_prefix = get_option('datadir') - gir_dir_pc_prefix = '${datadir}' + gir_dir_prefix = get_option('datadir') + gir_dir_pc_prefix = '${datadir}' else - gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix) + gir_dir_pc_prefix = join_paths('${prefix}', gir_dir_prefix) endif glib_girdir = get_option('prefix') / gir_dir_prefix / 'gir-1.0' @@ -54,7 +54,6 @@ girepo_headers = files( 'gipropertyinfo.h', 'giregisteredtypeinfo.h', 'girepository.h', - 'girffi.h', 'gisignalinfo.h', 'gistructinfo.h', 'gitypeinfo.h', @@ -64,7 +63,15 @@ girepo_headers = files( 'givfuncinfo.h', ) -install_headers(girepo_headers, install_dir: gir_includedir) +girepo_ffi_headers = [ + 'girffi.h', +] + +girepo_ffi_sources = files( + 'girffi.c', +) + +install_headers(girepo_headers + girepo_ffi_headers, install_dir: gir_includedir) gir_c_args = [ '-DGI_COMPILATION', @@ -165,7 +172,7 @@ if cc.get_id() != 'msvc' endif libgirepo = shared_library('girepository-2.0', - sources: girepo_sources + [gi_visibility_h], + sources: girepo_sources + girepo_ffi_sources + [gi_visibility_h], include_directories: [configinc, girepoinc], c_args: gir_c_args, version: library_version, @@ -214,3 +221,30 @@ pkg.generate(libgirepo, libraries: [libglib_dep, libgobject_dep], ) +if enable_gir + libgirepo_gir_sources = [ + gi_visibility_h, + girepo_headers, + girepo_sources, + ] + libgirepo_gir_packages = [ 'girepository-2.0' ] + libgirepo_gir_args = [ + '-DGI_COMPILATION', + '--symbol-prefix=gi', + '--identifier-prefix=GI', + ] + + girepository_gir = gnome.generate_gir(libgirepo, + sources: libgirepo_gir_sources, + namespace: 'GIRepository', + nsversion: '2.0', + identifier_prefix: 'GI', + symbol_prefix: 'gi', + export_packages: libgirepo_gir_packages, + header: 'girepository/girepository.h', + includes: [ glib_gir[0], gmodule_gir[0], gobject_gir[0], gio_gir[0] ], + install: true, + dependencies: [ libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep ], + extra_args: gir_args + libgirepo_gir_args, + ) +endif From ab3454a51544017ffb55286dfcb9fd446f63fd1b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:17:00 +0000 Subject: [PATCH 02/31] girepository: Remove duplicate macro definitions Not sure what was going on there. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypeinfo.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index f2de6c23f..2924b689b 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -61,26 +61,6 @@ G_BEGIN_DECLS */ #define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) -/** - * GI_TYPE_TAG_IS_NUMERIC: - * @tag: a type tag - * - * Checks if @tag is a numeric type. That is, integer or floating point. - * - * Since: 1.72 - */ -#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) - -/** - * GI_TYPE_TAG_IS_NUMERIC: - * @tag: a type tag - * - * Checks if @tag is a numeric type. That is, integer or floating point. - * - * Since: 1.72 - */ -#define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) - /** * GI_TYPE_TAG_IS_CONTAINER: * @tag: a type tag From bd803f8a117cc65ca835bb430ef107ccfc22e354 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:17:23 +0000 Subject: [PATCH 03/31] girepository: Add missing #include to gitypes.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the GIR generation for libgirepository doesn’t work, as GLib doesn’t get pulled in to provide basic types. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypes.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 4df37900c..3d382c974 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -28,6 +28,8 @@ #error "Only can be included directly." #endif +#include + G_BEGIN_DECLS typedef struct _GIBaseInfoStub { From 11e46361efe5c7f861ae65313fb207d70e3b5015 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:16:43 +0000 Subject: [PATCH 04/31] docs: Add GIRepository documentation build using gi-docgen Signed-off-by: Philip Withnall Helps: #3155 --- .../girepository/girepository.toml.in | 50 +++++++++++++++++++ docs/reference/girepository/meson.build | 23 +++++++++ docs/reference/girepository/urlmap.js | 10 ++++ docs/reference/meson.build | 1 + 4 files changed, 84 insertions(+) create mode 100644 docs/reference/girepository/girepository.toml.in create mode 100644 docs/reference/girepository/meson.build create mode 100644 docs/reference/girepository/urlmap.js diff --git a/docs/reference/girepository/girepository.toml.in b/docs/reference/girepository/girepository.toml.in new file mode 100644 index 000000000..a8102e32e --- /dev/null +++ b/docs/reference/girepository/girepository.toml.in @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# Copyright 2023 Matthias Clasen +# Copyright 2023 Philip Withnall + +[library] +name = "Girepository" +version = "@VERSION@" +browse_url = "https://gitlab.gnome.org/GNOME/glib/" +repository_url = "https://gitlab.gnome.org/GNOME/glib.git" +website_url = "https://www.gtk.org" +docs_urls = "https://docs.gtk.org/girepository/" +authors = "GLib Development Team" +license = "LGPL-2.1-or-later" +description = "GIRepository is a library providing access to typelibs and introspection data which describes C APIs" +dependencies = [ "GLib-2.0", "GModule-2.0", "GObject-2.0", "Gio-2.0" ] +devhelp = true +search_index = true + + [dependencies."GLib-2.0"] + name = "GLib" + description = "The base utility library" + docs_url = "https://docs.gtk.org/glib/" + + [dependencies."GModule-2.0"] + name = "GModule" + description = "Portable API for dynamically loading modules" + docs_url = "https://docs.gtk.org/gmodule/" + + [dependencies."GObject-2.0"] + name = "GObject" + description = "The base type system library" + docs_url = "https://docs.gtk.org/gobject/" + + [dependencies."Gio-2.0"] + name = "Gio" + description = "Useful classes for general purpose I/O, networking, IPC, settings, etc." + docs_url = "https://docs.gtk.org/gio/" + +[theme] +name = "basic" +show_index_summary = true +show_class_hierarchy = true + +[extra] +urlmap_file = "urlmap.js" +# The same order will be used when generating the index +content_files = [ +] +content_images = [ +] diff --git a/docs/reference/girepository/meson.build b/docs/reference/girepository/meson.build new file mode 100644 index 000000000..f5e8e6d4d --- /dev/null +++ b/docs/reference/girepository/meson.build @@ -0,0 +1,23 @@ +girepository_toml = configure_file( + input: 'girepository.toml.in', + output: 'girepository.toml', + configuration: toml_conf, +) + +custom_target('girepository-docs', + input: [ girepository_toml, girepository_gir[0] ], + output: 'girepository', + command: [ + gidocgen, + 'generate', + gidocgen_common_args, + '--config=@INPUT0@', + '--output-dir=@OUTPUT@', + '--content-dir=@0@'.format(meson.current_source_dir()), + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gobject'), + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gmodule'), + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../gio'), + '@INPUT1@', + ], + build_by_default: true, +) diff --git a/docs/reference/girepository/urlmap.js b/docs/reference/girepository/urlmap.js new file mode 100644 index 000000000..32243001c --- /dev/null +++ b/docs/reference/girepository/urlmap.js @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +// SPDX-FileCopyrightText: 2023 Matthias Clasen +var baseURLs = [ + [ 'GdkPixbuf', 'https://docs.gtk.org/gdk-pixbuf/' ], + [ 'GLib', 'https://docs.gtk.org/glib/' ], + [ 'GModule', 'https://docs.gtk.org/gmodule/' ], + [ 'GObject', 'https://docs.gtk.org/gobject/' ], + [ 'Gio', 'https://docs.gtk.org/gio/' ], + [ 'Gtk', 'https://docs.gtk.org/gtk4/' ], +]; diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 9f52de48d..b3fe14d74 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -18,4 +18,5 @@ if get_option('documentation') and enable_gir subdir('gmodule') subdir('gobject') subdir('gio') + subdir('girepository') endif From c42e63c6377d492619821233ea689f48b34ec17b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:24:11 +0000 Subject: [PATCH 05/31] girepository: Update existing Since tags to 2.80 Since the APIs are new to libgirepository-2.0 in version 2.80. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giarginfo.c | 2 +- girepository/gicallableinfo.c | 8 ++++---- girepository/giconstantinfo.c | 2 +- girepository/gienuminfo.c | 6 +++--- girepository/giinterfaceinfo.c | 2 +- girepository/giobjectinfo.c | 2 +- girepository/girepository.c | 6 +++--- girepository/gistructinfo.c | 6 +++--- girepository/gitypeinfo.c | 10 +++++----- girepository/gitypeinfo.h | 6 +++--- girepository/gitypelib.c | 2 +- girepository/giunioninfo.c | 4 ++-- 12 files changed, 28 insertions(+), 28 deletions(-) diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index aec94dc22..775a6aa36 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -175,7 +175,7 @@ gi_arg_info_may_be_null (GIArgInfo *info) * Obtain if an argument is only useful in C. * * Returns: %TRUE if argument is only useful in C. - * Since: 1.30 + * Since: 2.80 */ gboolean gi_arg_info_is_skip (GIArgInfo *info) diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 37997eef3..0b44c2323 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -87,7 +87,7 @@ signature_offset (GICallableInfo *info) * * TODO * - * Since: 1.34 + * Since: 2.80 * Returns: %TRUE if this #GICallableInfo can throw a #GError */ gboolean @@ -141,7 +141,7 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info) * or "this" object. * * Returns: %TRUE if @info is a method, %FALSE otherwise - * Since: 1.34 + * Since: 2.80 */ gboolean gi_callable_info_is_method (GICallableInfo *info) @@ -293,7 +293,7 @@ gi_callable_info_get_caller_owns (GICallableInfo *info) * Obtains the ownership transfer for the instance argument. * #GITransfer contains a list of possible transfer values. * - * Since: 1.42 + * Since: 2.80 * Returns: the transfer mode of the instance argument */ GITransfer @@ -489,7 +489,7 @@ gi_callable_info_iterate_return_attributes (GICallableInfo *info, * The @interface_type argument only applies if @return_tag is * %GI_TYPE_TAG_INTERFACE. Otherwise it is ignored. * - * Since: 1.72 + * Since: 2.80 */ void gi_type_tag_extract_ffi_return_value (GITypeTag return_tag, diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index 01223e236..f9dd7ed2d 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -75,7 +75,7 @@ gi_constant_info_get_type (GIConstantInfo *info) * * Free the value returned from gi_constant_info_get_value(). * - * Since: 1.32 + * Since: 2.80 */ void gi_constant_info_free_value (GIConstantInfo *info, diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index e03aff3cd..4176ab2fc 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -76,7 +76,7 @@ gi_enum_info_get_n_values (GIEnumInfo *info) * * Returns: (transfer none): the string form of the error domain associated * with this enum, or %NULL. - * Since: 1.30 + * Since: 2.80 */ const gchar * gi_enum_info_get_error_domain (GIEnumInfo *info) @@ -130,7 +130,7 @@ gi_enum_info_get_value (GIEnumInfo *info, * Obtain the number of methods that this enum type has. * * Returns: number of methods - * Since: 1.30 + * Since: 2.80 */ gint gi_enum_info_get_n_methods (GIEnumInfo *info) @@ -155,7 +155,7 @@ gi_enum_info_get_n_methods (GIEnumInfo *info) * * Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling * gi_base_info_unref() when done. - * Since: 1.30 + * Since: 2.80 */ GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index e2072f492..460947573 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -297,7 +297,7 @@ gi_interface_info_get_signal (GIInterfaceInfo *info, * * Returns: (transfer full): Info for the signal with name @name in @info, or * %NULL on failure. - * Since: 1.34 + * Since: 2.80 */ GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 4a8ef5300..4c1e1f0a1 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -141,7 +141,7 @@ gi_object_info_get_abstract (GIObjectInfo *info) * * Returns: %TRUE if the object type is final * - * Since: 1.70 + * Since: 2.80 */ gboolean gi_object_info_get_final (GIObjectInfo *info) diff --git a/girepository/girepository.c b/girepository/girepository.c index 95b693c4c..1b19040e6 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -468,7 +468,7 @@ register_internal (GIRepository *repository, * Returns: (transfer full): Zero-terminated string array of immediate versioned * dependencies * - * Since: 1.44 + * Since: 2.80 */ char ** gi_repository_get_immediate_dependencies (GIRepository *repository, @@ -943,7 +943,7 @@ find_by_error_domain_foreach (gpointer key, * * Returns: (transfer full): #GIEnumInfo representing metadata about @domain's * enum type, or %NULL - * Since: 1.30 + * Since: 2.80 */ GIEnumInfo * gi_repository_find_by_error_domain (GIRepository *repository, @@ -1002,7 +1002,7 @@ gi_repository_find_by_error_domain (GIRepository *repository, * returning a concrete class of #GLocalFile, which is a #GType we * see at runtime, but not statically. * - * Since: 1.62 + * Since: 2.80 */ void gi_repository_get_object_gtype_interfaces (GIRepository *repository, diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index 8be89544a..4b36cbb9a 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -117,7 +117,7 @@ gi_struct_info_get_field (GIStructInfo *info, * * Obtain the type information for field named @name. * - * Since: 1.46 + * Since: 2.80 * Returns: (transfer full): the #GIFieldInfo or %NULL if not found, * free it with gi_base_info_unref() when done. */ @@ -293,7 +293,7 @@ gi_struct_info_is_gtype_struct (GIStructInfo *info) * * Returns: (transfer none) (nullable): the name of the copy function * - * Since: 1.76 + * Since: 2.80 */ const char * gi_struct_info_get_copy_function (GIStructInfo *info) @@ -320,7 +320,7 @@ gi_struct_info_get_copy_function (GIStructInfo *info) * * Returns: (transfer none) (nullable): the name of the free function * - * Since: 1.76 + * Since: 2.80 */ const char * gi_struct_info_get_free_function (GIStructInfo *info) diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index a7be761bf..3e9ca0083 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -355,7 +355,7 @@ gi_type_info_get_array_type (GITypeInfo *info) * * Returns: the type tag * - * Since: 1.66 + * Since: 2.80 */ GITypeTag gi_type_info_get_storage_type (GITypeInfo *info) @@ -392,7 +392,7 @@ gi_type_info_get_storage_type (GITypeInfo *info) * This function fills in the appropriate field of @arg with the value extracted * from @hash_pointer, depending on @storage_type. * - * Since: 1.72 + * Since: 2.80 */ void gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, @@ -465,7 +465,7 @@ gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, * This function fills in the appropriate field of @arg with the value extracted * from @hash_pointer, depending on the storage type of @info. * - * Since: 1.66 + * Since: 2.80 */ void gi_type_info_argument_from_hash_pointer (GITypeInfo *info, @@ -496,7 +496,7 @@ gi_type_info_argument_from_hash_pointer (GITypeInfo *info, * * Returns: A stuffed pointer, that can be stored in a #GHashTable, for example * - * Since: 1.72 + * Since: 2.80 */ gpointer gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, @@ -560,7 +560,7 @@ gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, * * Returns: A stuffed pointer, that can be stored in a #GHashTable, for example * - * Since: 1.66 + * Since: 2.80 */ gpointer gi_type_info_hash_pointer_from_argument (GITypeInfo *info, diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 2924b689b..527f9496d 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -47,7 +47,7 @@ G_BEGIN_DECLS * * Checks if @tag is a basic type. * - * Since: 1.72 + * Since: 2.80 */ #define GI_TYPE_TAG_IS_BASIC(tag) ((tag) < GI_TYPE_TAG_ARRAY || (tag) == GI_TYPE_TAG_UNICHAR) @@ -57,7 +57,7 @@ G_BEGIN_DECLS * * Checks if @tag is a numeric type. That is, integer or floating point. * - * Since: 1.72 + * Since: 2.80 */ #define GI_TYPE_TAG_IS_NUMERIC(tag) ((tag) >= GI_TYPE_TAG_INT8 && (tag) <= GI_TYPE_TAG_DOUBLE) @@ -68,7 +68,7 @@ G_BEGIN_DECLS * Checks if @tag is a container type. That is, a type which may have a nonnull * return from gi_type_info_get_param_type(). * - * Since: 1.72 + * Since: 2.80 */ #define GI_TYPE_TAG_IS_CONTAINER(tag) ((tag) == GI_TYPE_TAG_ARRAY || \ ((tag) >= GI_TYPE_TAG_GLIST && (tag) <= GI_TYPE_TAG_GHASH)) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 550e9b0ef..b49b5cdf8 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -2242,7 +2242,7 @@ static GSList *library_paths; * path (ie. LD_LIBRARY_PATH and DT_RPATH in ELF systems). * See the documentation of your dynamic linker for full details. * - * Since: 1.36 + * Since: 2.80 */ void gi_repository_prepend_library_path (const char *directory) diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 41966db35..54b9c0776 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -279,7 +279,7 @@ gi_union_info_get_alignment (GIUnionInfo *info) * * Returns: (transfer none) (nullable): the name of the copy function * - * Since: 1.76 + * Since: 2.80 */ const char * gi_union_info_get_copy_function (GIUnionInfo *info) @@ -306,7 +306,7 @@ gi_union_info_get_copy_function (GIUnionInfo *info) * * Returns: (transfer none) (nullable): the name of the free function * - * Since: 1.76 + * Since: 2.80 */ const char * gi_union_info_get_free_function (GIUnionInfo *info) From 458cc700ce060c7dabe185744b8f988463e115d9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:36:19 +0000 Subject: [PATCH 06/31] girepository: Update docs for GIVFuncInfo for gi-docgen Move the SECTION into the struct docs, update the documentation comment syntax, and add `Since: 2.80` everywhere. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypes.h | 6 +--- girepository/givfuncinfo.c | 57 ++++++++++++++++++++++---------------- girepository/givfuncinfo.h | 6 ++-- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 3d382c974..592110dfd 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -145,11 +145,7 @@ typedef GIBaseInfo GIValueInfo; */ typedef GIBaseInfo GISignalInfo; -/** - * GIVFuncInfo: - * - * Represents a virtual function. - */ +/* Documented in givfuncinfo.c */ typedef GIBaseInfo GIVFuncInfo; /** diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 2dfe73f04..d9de05aa8 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -34,14 +34,14 @@ #include "givfuncinfo.h" /** - * SECTION:givfuncinfo - * @title: GIVFuncInfo - * @short_description: Struct representing a virtual function + * GIVFuncInfo: * - * GIVfuncInfo represents a virtual function. + * `GIVfuncInfo` represents a virtual function. * * A virtual function is a callable object that belongs to either a - * #GIObjectInfo or a #GIInterfaceInfo. + * [alias@GIRepository.ObjectInfo] or a [alias@GIRepository.InterfaceInfo]. + * + * Since: 2.80 */ GIVFuncInfo * @@ -73,10 +73,13 @@ gi_base_info_find_vfunc (GIRealInfo *rinfo, * gi_vfunc_info_get_flags: * @info: a #GIVFuncInfo * - * Obtain the flags for this virtual function info. See #GIVFuncInfoFlags for - * more information about possible flag values. + * Obtain the flags for this virtual function info. + * + * See [flags@GIRepository.VFuncInfoFlags] for more information about possible + * flag values. * * Returns: the flags + * Since: 2.80 */ GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info) @@ -112,9 +115,10 @@ gi_vfunc_info_get_flags (GIVFuncInfo *info) * @info: a #GIVFuncInfo * * Obtain the offset of the function pointer in the class struct. The value - * 0xFFFF indicates that the struct offset is unknown. + * `0xFFFF` indicates that the struct offset is unknown. * - * Returns: the struct offset or 0xFFFF if it's unknown + * Returns: the struct offset or `0xFFFF` if it’s unknown + * Since: 2.80 */ gint gi_vfunc_info_get_offset (GIVFuncInfo *info) @@ -135,10 +139,12 @@ gi_vfunc_info_get_offset (GIVFuncInfo *info) * @info: a #GIVFuncInfo * * Obtain the signal for the virtual function if one is set. + * * The signal comes from the object or interface to which * this virtual function belongs. * - * Returns: (transfer full): the signal or %NULL if none set + * Returns: (transfer full): the signal or `NULL` if none set + * Since: 2.80 */ GISignalInfo * gi_vfunc_info_get_signal (GIVFuncInfo *info) @@ -166,8 +172,9 @@ gi_vfunc_info_get_signal (GIVFuncInfo *info) * * Not all virtuals will have invokers. * - * Returns: (transfer full): the #GIVFuncInfo or %NULL. Free it with - * gi_base_info_unref() when done. + * Returns: (transfer full): the [alias@GIRepository.FunctionInfo] or `NULL`. + * Free it with gi_base_info_unref() when done. + * Since: 2.80 */ GIFunctionInfo * gi_vfunc_info_get_invoker (GIVFuncInfo *info) @@ -202,10 +209,11 @@ gi_vfunc_info_get_invoker (GIVFuncInfo *info) * @implementor_gtype: #GType implementing this virtual function * @error: return location for a #GError * - * This method will look up where inside the type struct of @implementor_gtype - * is the implementation for @info. + * Looks up where inside the type struct of @implementor_gtype is the + * implementation for @info. * - * Returns: address to a function or %NULL if an error happened + * Returns: address to a function or `NULL` if an error happened + * Since: 2.80 */ gpointer gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, @@ -299,25 +307,26 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, * gi_vfunc_info_invoke: (skip) * @info: a #GIVFuncInfo describing the virtual function to invoke * @implementor: #GType of the type that implements this virtual function - * @in_args: (array length=n_in_args): an array of #GIArguments, one for each in - * parameter of @info. If there are no in parameter, @in_args - * can be %NULL + * @in_args: (array length=n_in_args): an array of [struct@GIRepository.Argument]s, + * one for each in parameter of @info. If there are no in parameter, @in_args + * can be `NULL` * @n_in_args: the length of the @in_args array - * @out_args: (array length=n_out_args): an array of #GIArguments, one for each out - * parameter of @info. If there are no out parameters, @out_args - * may be %NULL + * @out_args: (array length=n_out_args): an array of [struct@GIRepository.Argument]s, + * one for each out parameter of @info. If there are no out parameters, + * @out_args may be `NULL` * @n_out_args: the length of the @out_args array * @return_value: return location for the return value of the * function. If the function returns void, @return_value may be - * %NULL - * @error: return location for detailed error information, or %NULL + * `NULL` + * @error: return location for detailed error information, or `NULL` * * Invokes the function described in @info with the given * arguments. Note that inout parameters must appear in both * argument lists. * - * Returns: %TRUE if the function has been invoked, %FALSE if an + * Returns: true if the function has been invoked, false if an * error occurred. + * Since: 2.80 */ gboolean gi_vfunc_info_invoke (GIVFuncInfo *info, diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index 2fb67a78e..fce453d48 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -33,10 +33,12 @@ G_BEGIN_DECLS /** - * GI_IS_VFUNC_INFO + * GI_IS_VFUNC_INFO: * @info: an info structure * - * Checks if @info is a #GIVfuncInfo. + * Checks if @info is a [struct@GIRepository.VFuncInfo]. + * + * Since: 2.80 */ #define GI_IS_VFUNC_INFO(info) \ (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VFUNC) From e79310e1d23c17f9821e928b110c55ee475db218 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:42:11 +0000 Subject: [PATCH 07/31] givfuncinfo: Add missing introspection annotations in GIVFuncInfo Signed-off-by: Philip Withnall Helps: #3155 --- girepository/givfuncinfo.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index d9de05aa8..710aad691 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -143,7 +143,7 @@ gi_vfunc_info_get_offset (GIVFuncInfo *info) * The signal comes from the object or interface to which * this virtual function belongs. * - * Returns: (transfer full): the signal or `NULL` if none set + * Returns: (transfer full) (nullable): the signal or `NULL` if none set * Since: 2.80 */ GISignalInfo * @@ -172,8 +172,8 @@ gi_vfunc_info_get_signal (GIVFuncInfo *info) * * Not all virtuals will have invokers. * - * Returns: (transfer full): the [alias@GIRepository.FunctionInfo] or `NULL`. - * Free it with gi_base_info_unref() when done. + * Returns: (transfer full) (nullable): the [alias@GIRepository.FunctionInfo] or + * `NULL`. Free it with gi_base_info_unref() when done. * Since: 2.80 */ GIFunctionInfo * @@ -307,15 +307,15 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, * gi_vfunc_info_invoke: (skip) * @info: a #GIVFuncInfo describing the virtual function to invoke * @implementor: #GType of the type that implements this virtual function - * @in_args: (array length=n_in_args): an array of [struct@GIRepository.Argument]s, - * one for each in parameter of @info. If there are no in parameter, @in_args - * can be `NULL` + * @in_args: (array length=n_in_args) (nullable): an array of + * [struct@GIRepository.Argument]s, one for each in parameter of @info. If + * there are no in parameter, @in_args can be `NULL` * @n_in_args: the length of the @in_args array - * @out_args: (array length=n_out_args): an array of [struct@GIRepository.Argument]s, - * one for each out parameter of @info. If there are no out parameters, - * @out_args may be `NULL` + * @out_args: (array length=n_out_args) (nullable): an array of + * [struct@GIRepository.Argument]s, one for each out parameter of @info. If + * there are no out parameters, @out_args may be `NULL` * @n_out_args: the length of the @out_args array - * @return_value: return location for the return value of the + * @return_value: (nullable): return location for the return value of the * function. If the function returns void, @return_value may be * `NULL` * @error: return location for detailed error information, or `NULL` From 7d90780bbb383352d5036a4f475c8da6a9382a3a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:42:44 +0000 Subject: [PATCH 08/31] =?UTF-8?q?givfuncinfo:=20Fix=20crash=20in=20GIVFunc?= =?UTF-8?q?Info=20if=20a=20GError=20isn=E2=80=99t=20passed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Philip Withnall Helps: #3155 --- girepository/givfuncinfo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 710aad691..f29e7d49d 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -339,10 +339,14 @@ gi_vfunc_info_invoke (GIVFuncInfo *info, GError **error) { gpointer func; + GError *local_error = NULL; - func = gi_vfunc_info_get_address (info, implementor, error); - if (*error != NULL) - return FALSE; + func = gi_vfunc_info_get_address (info, implementor, &local_error); + if (local_error != NULL) + { + g_propagate_error (error, g_steal_pointer (&local_error)); + return FALSE; + } return gi_callable_info_invoke ((GICallableInfo*) info, func, From ca9291a87de786e9fd1349ff2a379b89d0724822 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:45:46 +0000 Subject: [PATCH 09/31] givfuncinfo: Add missing precondition checks Signed-off-by: Philip Withnall Helps: #3155 --- girepository/givfuncinfo.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index f29e7d49d..3fba0c028 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -229,6 +229,10 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, gpointer implementor_class, implementor_vtable; gpointer func = NULL; + g_return_val_if_fail (vfunc_info != NULL, NULL); + g_return_val_if_fail (GI_IS_VFUNC_INFO (vfunc_info), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + container_info = gi_base_info_get_container (vfunc_info); if (gi_base_info_get_type (container_info) == GI_INFO_TYPE_OBJECT) { @@ -341,6 +345,12 @@ gi_vfunc_info_invoke (GIVFuncInfo *info, gpointer func; GError *local_error = NULL; + g_return_val_if_fail (info != NULL, FALSE); + g_return_val_if_fail (GI_IS_VFUNC_INFO (info), FALSE); + g_return_val_if_fail (in_args != NULL || n_in_args == 0, FALSE); + g_return_val_if_fail (out_args != NULL || n_out_args == 0, FALSE); + g_return_val_if_fail (error == NULL || *error == NULL, FALSE); + func = gi_vfunc_info_get_address (info, implementor, &local_error); if (local_error != NULL) { From 5e0c402f38ebf36b184edca9b66f1e3abb8e627c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:52:42 +0000 Subject: [PATCH 10/31] girepository: Update docs for GIUnionInfo for gi-docgen Move the SECTION into the struct docs, update the documentation comment syntax, and add `Since: 2.80` everywhere. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypes.h | 6 +--- girepository/giunioninfo.c | 71 ++++++++++++++++++++++---------------- girepository/giunioninfo.h | 6 ++-- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 592110dfd..aa2682586 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -88,11 +88,7 @@ typedef GIBaseInfo GIRegisteredTypeInfo; */ typedef GIBaseInfo GIStructInfo; -/** - * GIUnionInfo: - * - * Represents a union. - */ +/* Documented in giunioninfo.c */ typedef GIBaseInfo GIUnionInfo; /** diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 54b9c0776..7b305c981 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -32,15 +32,15 @@ #include "giunioninfo.h" /** - * SECTION:giunioninfo - * @title: GIUnionInfo - * @short_description: Struct representing a union. + * GIUnionInfo: * - * GIUnionInfo represents a union type. + * `GIUnionInfo` represents a union type. * * A union has methods and fields. Unions can optionally have a * discriminator, which is a field deciding what type of real union * fields is valid for specified instance. + * + * Since: 2.80 */ /** @@ -50,6 +50,7 @@ * Obtain the number of fields this union has. * * Returns: number of fields + * Since: 2.80 */ gint gi_union_info_get_n_fields (GIUnionInfo *info) @@ -65,10 +66,11 @@ gi_union_info_get_n_fields (GIUnionInfo *info) * @info: a #GIUnionInfo * @n: a field index * - * Obtain the type information for field with specified index. + * Obtain the type information for the field with the specified index. * - * Returns: (transfer full): the #GIFieldInfo, free it with gi_base_info_unref() - * when done. + * Returns: (transfer full): the [alias@GIRepository.FieldInfo], free it with + * gi_base_info_unref() when done. + * Since: 2.80 */ GIFieldInfo * gi_union_info_get_field (GIUnionInfo *info, @@ -89,6 +91,7 @@ gi_union_info_get_field (GIUnionInfo *info, * Obtain the number of methods this union has. * * Returns: number of methods + * Since: 2.80 */ gint gi_union_info_get_n_methods (GIUnionInfo *info) @@ -104,10 +107,11 @@ gi_union_info_get_n_methods (GIUnionInfo *info) * @info: a #GIUnionInfo * @n: a method index * - * Obtain the type information for method with specified index. + * Obtain the type information for the method with the specified index. * - * Returns: (transfer full): the #GIFunctionInfo, free it with gi_base_info_unref() - * when done. + * Returns: (transfer full): the [alias@GIRepository.FunctionInfo], free it + * with gi_base_info_unref() when done. + * Since: 2.80 */ GIFunctionInfo * gi_union_info_get_method (GIUnionInfo *info, @@ -129,9 +133,10 @@ gi_union_info_get_method (GIUnionInfo *info, * gi_union_info_is_discriminated: * @info: a #GIUnionInfo * - * Return true if this union contains discriminator field. + * Return true if this union contains a discriminator field. * - * Returns: %TRUE if this is a discriminated union, %FALSE otherwise + * Returns: true if this is a discriminated union, false otherwise + * Since: 2.80 */ gboolean gi_union_info_is_discriminated (GIUnionInfo *info) @@ -146,9 +151,10 @@ gi_union_info_is_discriminated (GIUnionInfo *info) * gi_union_info_get_discriminator_offset: * @info: a #GIUnionInfo * - * Returns offset of the discriminator field in the structure. + * Returns the offset of the discriminator field in the structure. * - * Returns: offset in bytes of the discriminator + * Returns: offset, in bytes, of the discriminator + * Since: 2.80 */ gint gi_union_info_get_discriminator_offset (GIUnionInfo *info) @@ -165,8 +171,9 @@ gi_union_info_get_discriminator_offset (GIUnionInfo *info) * * Obtain the type information of the union discriminator. * - * Returns: (transfer full): the #GITypeInfo, free it with gi_base_info_unref() - * when done. + * Returns: (transfer full): the [alias@GIRepository.TypeInfo], free it with + * gi_base_info_unref() when done. + * Since: 2.80 */ GITypeInfo * gi_union_info_get_discriminator_type (GIUnionInfo *info) @@ -181,12 +188,15 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info) * @info: a #GIUnionInfo * @n: a union field index * - * Obtain discriminator value assigned for n-th union field, i.e. n-th - * union field is the active one if discriminator contains this + * Obtain the discriminator value assigned for n-th union field, i.e. the n-th + * union field is the active one if the discriminator contains this * constant. * - * Returns: (transfer full): the #GIConstantInfo, free it with gi_base_info_unref() - * when done. + * If the union is not discriminated, `NULL` is returned. + * + * Returns: (transfer full): the [alias@GIRepository.ConstantInfo], free it + * with gi_base_info_unref() when done. + * Since: 2.80 */ GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, @@ -217,10 +227,11 @@ gi_union_info_get_discriminator (GIUnionInfo *info, * @info: a #GIUnionInfo * @name: a method name * - * Obtain the type information for method named @name. + * Obtain the type information for the method named @name. * - * Returns: (transfer full): the #GIFunctionInfo, free it with gi_base_info_unref() - * when done. + * Returns: (transfer full): the [alias@GIRepository.FunctionInfo], free it + * with gi_base_info_unref() when done. + * Since: 2.80 */ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, @@ -243,7 +254,8 @@ gi_union_info_find_method (GIUnionInfo *info, * * Obtain the total size of the union. * - * Returns: size of the union in bytes + * Returns: size of the union, in bytes + * Since: 2.80 */ gsize gi_union_info_get_size (GIUnionInfo *info) @@ -260,7 +272,8 @@ gi_union_info_get_size (GIUnionInfo *info) * * Obtain the required alignment of the union. * - * Returns: required alignment in bytes + * Returns: required alignment, in bytes + * Since: 2.80 */ gsize gi_union_info_get_alignment (GIUnionInfo *info) @@ -277,8 +290,8 @@ gi_union_info_get_alignment (GIUnionInfo *info) * * Retrieves the name of the copy function for @info, if any is set. * - * Returns: (transfer none) (nullable): the name of the copy function - * + * Returns: (transfer none) (nullable): the name of the copy function, or `NULL` + * if none is set * Since: 2.80 */ const char * @@ -304,8 +317,8 @@ gi_union_info_get_copy_function (GIUnionInfo *info) * * Retrieves the name of the free function for @info, if any is set. * - * Returns: (transfer none) (nullable): the name of the free function - * + * Returns: (transfer none) (nullable): the name of the free function, or `NULL` + * if none is set * Since: 2.80 */ const char * diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index d45389b2b..ed941dc0c 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -33,10 +33,12 @@ G_BEGIN_DECLS /** - * GI_IS_UNION_INFO + * GI_IS_UNION_INFO: * @info: an info structure * - * Checks if @info is a #GIUnionInfo. + * Checks if @info is a [struct@GIRepository.UnionInfo]. + * + * Since: 2.80 */ #define GI_IS_UNION_INFO(info) \ (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION) From 85bed115d848324966652faa08ddd8a1dea9c453 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 8 Nov 2023 23:56:10 +0000 Subject: [PATCH 11/31] giunioninfo: Add missing introspection annotations in GIUnionInfo Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giunioninfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 7b305c981..d80f50c0f 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -194,8 +194,8 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info) * * If the union is not discriminated, `NULL` is returned. * - * Returns: (transfer full): the [alias@GIRepository.ConstantInfo], free it - * with gi_base_info_unref() when done. + * Returns: (transfer full) (nullable): the [alias@GIRepository.ConstantInfo], + * free it with gi_base_info_unref() when done. * Since: 2.80 */ GIConstantInfo * From 2d2263fa4f474f4ef195d52071e2b096607649b9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 9 Nov 2023 00:06:57 +0000 Subject: [PATCH 12/31] girepository: Update docs for GITypelib for gi-docgen Move the SECTION into the struct docs, update the documentation comment syntax, and add `Since: 2.80` everywhere. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypelib.c | 42 ++++++++++++++++++++++++++++------------ girepository/gitypelib.h | 13 ------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index b49b5cdf8..c4bd52901 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -32,6 +32,15 @@ #include "gitypelib-internal.h" #include "gitypelib.h" +/** + * GITypelib: + * + * `GITypelib` represents a loaded `.typelib` file, which contains a description + * of a single module’s API. + * + * Since: 2.80 + */ + typedef struct { GITypelib *typelib; GSList *context_stack; @@ -2373,11 +2382,13 @@ gi_typelib_ensure_open (GITypelib *typelib) * @len: length of memory chunk containing the typelib * @error: a #GError * - * Creates a new #GITypelib from a memory location. The memory block - * pointed to by @typelib will be automatically g_free()d when the + * Creates a new `GITypelib` from a memory location. + * + * The memory block pointed to by @typelib will be automatically freed when the * repository is destroyed. * * Returns: the new #GITypelib + * Since: 2.80 */ GITypelib * gi_typelib_new_from_memory (guint8 *memory, @@ -2402,11 +2413,12 @@ gi_typelib_new_from_memory (guint8 *memory, * gi_typelib_new_from_const_memory: (skip) * @memory: address of memory chunk containing the typelib * @len: length of memory chunk containing the typelib - * @error: A #GError + * @error: a #GError * - * Creates a new #GITypelib from a memory location. + * Creates a new `GITypelib` from a memory location. * * Returns: the new #GITypelib + * Since: 2.80 */ GITypelib * gi_typelib_new_from_const_memory (const guchar *memory, @@ -2429,12 +2441,14 @@ gi_typelib_new_from_const_memory (const guchar *memory, /** * gi_typelib_new_from_mapped_file: (skip) - * @mfile: a #GMappedFile, that will be free'd when the repository is destroyed + * @mfile: a [type@GLib.MappedFile], that will be freed when the repository is + * destroyed * @error: a #GError * - * Creates a new #GITypelib from a #GMappedFile. + * Creates a new `GITypelib` from a [type@GLib.MappedFile]. * * Returns: the new #GITypelib + * Since: 2.80 */ GITypelib * gi_typelib_new_from_mapped_file (GMappedFile *mfile, @@ -2460,7 +2474,9 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile, * gi_typelib_free: * @typelib: a #GITypelib * - * Free a #GITypelib. + * Free a `GITypelib`. + * + * Since: 2.80 */ void gi_typelib_free (GITypelib *typelib) @@ -2480,11 +2496,12 @@ gi_typelib_free (GITypelib *typelib) /** * gi_typelib_get_namespace: - * @typelib: TODO + * @typelib: a #GITypelib * - * TODO + * Get the name of the namespace represented by @typelib. * - * Returns: TODO + * Returns: name of the namespace represented by @typelib + * Since: 2.80 */ const gchar * gi_typelib_get_namespace (GITypelib *typelib) @@ -2498,9 +2515,10 @@ gi_typelib_get_namespace (GITypelib *typelib) * @symbol_name: name of symbol to be loaded * @symbol: returns a pointer to the symbol value * - * Loads a symbol from #GITypelib. + * Loads a symbol from a `GITypelib`. * - * Returns: #TRUE on success + * Returns: true on success + * Since: 2.80 */ gboolean gi_typelib_symbol (GITypelib *typelib, const char *symbol_name, gpointer *symbol) diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index ee647ec5c..0f965a062 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -34,19 +34,6 @@ G_BEGIN_DECLS -/** - * SECTION:gitypelib - * @title: GITypelib - * @short_description: TODO - * - * TODO - */ - -/** - * GITypelib: - * - * TODO - */ typedef struct _GITypelib GITypelib; GI_AVAILABLE_IN_ALL From fcb328a76224144b9ea40571861eb31eea4f0dad Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 9 Nov 2023 00:09:45 +0000 Subject: [PATCH 13/31] gitypelib: Add missing introspection annotations in GITypelib Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypelib.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index c4bd52901..9d75de28c 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -2378,7 +2378,7 @@ gi_typelib_ensure_open (GITypelib *typelib) /** * gi_typelib_new_from_memory: (skip) - * @memory: address of memory chunk containing the typelib + * @memory: (array length=len): address of memory chunk containing the typelib * @len: length of memory chunk containing the typelib * @error: a #GError * @@ -2387,7 +2387,7 @@ gi_typelib_ensure_open (GITypelib *typelib) * The memory block pointed to by @typelib will be automatically freed when the * repository is destroyed. * - * Returns: the new #GITypelib + * Returns: (transfer full): the new #GITypelib * Since: 2.80 */ GITypelib * @@ -2411,13 +2411,13 @@ gi_typelib_new_from_memory (guint8 *memory, /** * gi_typelib_new_from_const_memory: (skip) - * @memory: address of memory chunk containing the typelib + * @memory: (array length=len): address of memory chunk containing the typelib * @len: length of memory chunk containing the typelib * @error: a #GError * * Creates a new `GITypelib` from a memory location. * - * Returns: the new #GITypelib + * Returns: (transfer full): the new #GITypelib * Since: 2.80 */ GITypelib * @@ -2441,13 +2441,13 @@ gi_typelib_new_from_const_memory (const guchar *memory, /** * gi_typelib_new_from_mapped_file: (skip) - * @mfile: a [type@GLib.MappedFile], that will be freed when the repository is - * destroyed + * @mfile: (transfer full): a [type@GLib.MappedFile], that will be freed when + * the repository is destroyed * @error: a #GError * * Creates a new `GITypelib` from a [type@GLib.MappedFile]. * - * Returns: the new #GITypelib + * Returns: (transfer full): the new #GITypelib * Since: 2.80 */ GITypelib * @@ -2472,7 +2472,7 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile, /** * gi_typelib_free: - * @typelib: a #GITypelib + * @typelib: (transfer full): a #GITypelib * * Free a `GITypelib`. * @@ -2513,7 +2513,8 @@ gi_typelib_get_namespace (GITypelib *typelib) * gi_typelib_symbol: * @typelib: the typelib * @symbol_name: name of symbol to be loaded - * @symbol: returns a pointer to the symbol value + * @symbol: (out) (nullable): returns a pointer to the symbol value, or `NULL` + * on failure * * Loads a symbol from a `GITypelib`. * From 392833b67fac45c9a49914e97fd60518cad6bfc6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 9 Nov 2023 00:13:52 +0000 Subject: [PATCH 14/31] gitypes: Remove obsolete non-fixed-width types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These can safely be removed now we’ve bumped the major library version. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypes.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/girepository/gitypes.h b/girepository/gitypes.h index aa2682586..cd432c762 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -417,16 +417,6 @@ typedef enum { */ #define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_UNICHAR+1) -#ifndef __GTK_DOC_IGNORE__ -/* These were removed and no longer appear in the typelib; - * instead, the machine-specific versions like INT32 are - * always used. - */ -#define GI_TYPE_TAG_SHORT GI_TYPE_TAG_SHORT_WAS_REMOVED -#define GI_TYPE_TAG_INT GI_TYPE_TAG_INT_WAS_REMOVED -#define GI_TYPE_TAG_LONG GI_TYPE_TAG_LONG_WAS_REMOVED -#endif - /** * GIArrayType: * @GI_ARRAY_TYPE_C: a C array, char[] for instance From a16be963b4ad3d6a2a36ed9370d250a736063ea0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 9 Nov 2023 00:38:56 +0000 Subject: [PATCH 15/31] gitypeinfo: Add missing introspection annotations in GITypeInfo Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypeinfo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 3e9ca0083..c66504aaf 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -120,9 +120,9 @@ gi_type_info_get_tag (GITypeInfo *info) * @info: a #GITypeInfo * @n: index of the parameter * - * Obtain the parameter type @n. + * Obtain the parameter type @n, or `-1` if the type is not an array. * - * Returns: (transfer full): the param type info + * Returns: (transfer full) (nullable): the param type info */ GITypeInfo * gi_type_info_get_param_type (GITypeInfo *info, @@ -167,7 +167,7 @@ gi_type_info_get_param_type (GITypeInfo *info, * inspect the type of the returned #GIBaseInfo to further query whether it is * a concrete GObject, a GInterface, a structure, etc. using gi_base_info_get_type(). * - * Returns: (transfer full): the #GIBaseInfo, or %NULL. Free it with + * Returns: (transfer full) (nullable): the #GIBaseInfo, or %NULL. Free it with * gi_base_info_unref() when done. */ GIBaseInfo * From 9eabdd7c2e3539a8cc9d0b96fa7a586dcc0d8354 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:09:26 +0000 Subject: [PATCH 16/31] girepository: Rename get_type() methods to get_type_info() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These methods don’t return a `GType`, so when the code gets ported to `GTypeInstance` in an upcoming commit, that will become quite confusing. Rename them all to `get_type_info()` instead. This introduces no functional changes, but it is an API break. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giarginfo.c | 6 +++--- girepository/giarginfo.h | 2 +- girepository/gicallableinfo.c | 2 +- girepository/giconstantinfo.c | 6 +++--- girepository/giconstantinfo.h | 2 +- girepository/gifieldinfo.c | 8 ++++---- girepository/gifieldinfo.h | 2 +- girepository/gipropertyinfo.c | 4 ++-- girepository/gipropertyinfo.h | 2 +- girepository/girwriter.c | 10 +++++----- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index 775a6aa36..9d169ab01 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -291,7 +291,7 @@ gi_arg_info_get_destroy (GIArgInfo *info) } /** - * gi_arg_info_get_type: + * gi_arg_info_get_type_info: * @info: a #GIArgInfo * * Obtain the type information for @info. @@ -301,7 +301,7 @@ gi_arg_info_get_destroy (GIArgInfo *info) * when done. */ GITypeInfo * -gi_arg_info_get_type (GIArgInfo *info) +gi_arg_info_get_type_info (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -317,7 +317,7 @@ gi_arg_info_get_type (GIArgInfo *info) * @type: (out caller-allocates): Initialized with information about type of @info * * Obtain information about a the type of given argument @info; this - * function is a variant of gi_arg_info_get_type() designed for stack + * function is a variant of gi_arg_info_get_type_info() designed for stack * allocation. * * The initialized @type must not be referenced after @info is deallocated. diff --git a/girepository/giarginfo.h b/girepository/giarginfo.h index 685949721..448e6cc81 100644 --- a/girepository/giarginfo.h +++ b/girepository/giarginfo.h @@ -73,7 +73,7 @@ GI_AVAILABLE_IN_ALL gint gi_arg_info_get_destroy (GIArgInfo *info); GI_AVAILABLE_IN_ALL -GITypeInfo * gi_arg_info_get_type (GIArgInfo *info); +GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info); GI_AVAILABLE_IN_ALL void gi_arg_info_load_type (GIArgInfo *info, diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 0b44c2323..6c6193f35 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -666,7 +666,7 @@ gi_callable_info_invoke (GIFunctionInfo *info, switch (gi_arg_info_get_direction (ainfo)) { case GI_DIRECTION_IN: - tinfo = gi_arg_info_get_type (ainfo); + tinfo = gi_arg_info_get_type_info (ainfo); atypes[i+offset] = gi_type_info_get_ffi_type (tinfo); gi_base_info_unref ((GIBaseInfo *)ainfo); gi_base_info_unref ((GIBaseInfo *)tinfo); diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index f9dd7ed2d..28ef282b5 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -40,13 +40,13 @@ * GIConstantInfo represents a constant. * * A constant has a type associated which can be obtained by calling - * gi_constant_info_get_type() and a value, which can be obtained by + * gi_constant_info_get_type_info() and a value, which can be obtained by * calling gi_constant_info_get_value(). */ /** - * gi_constant_info_get_type: + * gi_constant_info_get_type_info: * @info: a #GIConstantInfo * * Obtain the type of the constant as a #GITypeInfo. @@ -55,7 +55,7 @@ * gi_base_info_unref() when done. */ GITypeInfo * -gi_constant_info_get_type (GIConstantInfo *info) +gi_constant_info_get_type_info (GIConstantInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giconstantinfo.h b/girepository/giconstantinfo.h index 175e78e2e..21795acf0 100644 --- a/girepository/giconstantinfo.h +++ b/girepository/giconstantinfo.h @@ -43,7 +43,7 @@ G_BEGIN_DECLS GI_AVAILABLE_IN_ALL -GITypeInfo * gi_constant_info_get_type (GIConstantInfo *info); +GITypeInfo * gi_constant_info_get_type_info (GIConstantInfo *info); GI_AVAILABLE_IN_ALL void gi_constant_info_free_value (GIConstantInfo *info, diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index ec8f7af7a..d5be687ab 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -127,7 +127,7 @@ gi_field_info_get_offset (GIFieldInfo *info) } /** - * gi_field_info_get_type: + * gi_field_info_get_type_info: * @info: a #GIFieldInfo * * Obtain the type of a field as a #GITypeInfo. @@ -136,7 +136,7 @@ gi_field_info_get_offset (GIFieldInfo *info) * gi_base_info_unref() when done. */ GITypeInfo * -gi_field_info_get_type (GIFieldInfo *info) +gi_field_info_get_type_info (GIFieldInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; @@ -190,7 +190,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, return FALSE; offset = gi_field_info_get_offset (field_info); - type_info = gi_field_info_get_type (field_info); + type_info = gi_field_info_get_type_info (field_info); if (gi_type_info_is_pointer (type_info)) { @@ -384,7 +384,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, return FALSE; offset = gi_field_info_get_offset (field_info); - type_info = gi_field_info_get_type (field_info); + type_info = gi_field_info_get_type_info (field_info); if (!gi_type_info_is_pointer (type_info)) { diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index 00ef1d06c..b11dd777b 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -53,7 +53,7 @@ GI_AVAILABLE_IN_ALL gint gi_field_info_get_offset (GIFieldInfo *info); GI_AVAILABLE_IN_ALL -GITypeInfo * gi_field_info_get_type (GIFieldInfo *info); +GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info); GI_AVAILABLE_IN_ALL gboolean gi_field_info_get_field (GIFieldInfo *field_info, diff --git a/girepository/gipropertyinfo.c b/girepository/gipropertyinfo.c index 829d9089a..3e65e15d1 100644 --- a/girepository/gipropertyinfo.c +++ b/girepository/gipropertyinfo.c @@ -80,7 +80,7 @@ gi_property_info_get_flags (GIPropertyInfo *info) } /** - * gi_property_info_get_type: + * gi_property_info_get_type_info: * @info: a #GIPropertyInfo * * Obtain the type information for the property @info. @@ -89,7 +89,7 @@ gi_property_info_get_flags (GIPropertyInfo *info) * gi_base_info_unref() when done. */ GITypeInfo * -gi_property_info_get_type (GIPropertyInfo *info) +gi_property_info_get_type_info (GIPropertyInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/gipropertyinfo.h b/girepository/gipropertyinfo.h index 6b26d69ab..d5ba46c72 100644 --- a/girepository/gipropertyinfo.h +++ b/girepository/gipropertyinfo.h @@ -46,7 +46,7 @@ GI_AVAILABLE_IN_ALL GParamFlags gi_property_info_get_flags (GIPropertyInfo *info); GI_AVAILABLE_IN_ALL -GITypeInfo * gi_property_info_get_type (GIPropertyInfo *info); +GITypeInfo *gi_property_info_get_type_info (GIPropertyInfo *info); GI_AVAILABLE_IN_ALL GITransfer gi_property_info_get_ownership_transfer (GIPropertyInfo *info); diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 453e9eb3d..44300cb72 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -423,13 +423,13 @@ write_field_info (const gchar *ns, write_attributes (file, (GIBaseInfo*) info); - type = gi_field_info_get_type (info); + type = gi_field_info_get_type_info (info); if (branch) { xml_printf (file, " branch=\""); gi_base_info_unref ((GIBaseInfo *)type); - type = gi_constant_info_get_type (branch); + type = gi_constant_info_get_type_info (branch); gi_constant_info_get_value (branch, &value); write_constant_value (ns, type, &value, file); xml_printf (file, "\""); @@ -555,7 +555,7 @@ write_callable_info (const gchar *ns, write_attributes (file, (GIBaseInfo*) arg); - type = gi_arg_info_get_type (arg); + type = gi_arg_info_get_type_info (arg); write_type_info (ns, type, file); xml_end_element (file, "parameter"); @@ -813,7 +813,7 @@ write_constant_info (const gchar *ns, xml_start_element (file, "constant"); xml_printf (file, " name=\"%s\"", name); - type = gi_constant_info_get_type (info); + type = gi_constant_info_get_type_info (info); xml_printf (file, " value=\""); gi_constant_info_get_value (info, &value); @@ -1020,7 +1020,7 @@ write_property_info (const gchar *ns, write_attributes (file, (GIBaseInfo*) info); - type = gi_property_info_get_type (info); + type = gi_property_info_get_type_info (info); write_type_info (ns, type, file); From 20fea9515d90ddd00bb65d78acf3a9eb47db6ad7 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:14:30 +0000 Subject: [PATCH 17/31] girepository: Add various missing casts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These aren’t needed at the moment, since all the `TypeInfo` structs in libgirepository are all aliases for each other. An upcoming commit will change that, however, so we need to be a little bit stricter about type safety in advance. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giarginfo.c | 2 +- girepository/gicallableinfo.c | 4 ++-- girepository/gifieldinfo.c | 2 +- girepository/giinterfaceinfo.c | 2 +- girepository/giobjectinfo.c | 12 ++++++------ girepository/girepository.c | 10 +++++----- girepository/girffi.c | 2 +- girepository/girwriter.c | 2 +- girepository/gitypeinfo.c | 2 +- girepository/givfuncinfo.c | 6 +++--- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index 9d169ab01..58eed2c5f 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -331,5 +331,5 @@ gi_arg_info_load_type (GIArgInfo *info, g_return_if_fail (info != NULL); g_return_if_fail (GI_IS_ARG_INFO (info)); - gi_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); + gi_type_info_init ((GIBaseInfo *) type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); } diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 6c6193f35..2bdcd1b8e 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -211,7 +211,7 @@ gi_callable_info_load_return_type (GICallableInfo *info, offset = signature_offset (info); - gi_type_info_init (type, (GIBaseInfo*)info, rinfo->typelib, offset); + gi_type_info_init ((GIBaseInfo *) type, (GIBaseInfo*)info, rinfo->typelib, offset); } /** @@ -458,7 +458,7 @@ gi_callable_info_iterate_return_attributes (GICallableInfo *info, if (iterator->data != NULL) next = (AttributeBlob *) iterator->data; else - next = _attribute_blob_find_first (info, blob_offset); + next = _attribute_blob_find_first ((GIBaseInfo *) info, blob_offset); if (next == NULL || next->offset != blob_offset || next >= after) return FALSE; diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index d5be687ab..4e7c0fb27 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -158,7 +158,7 @@ gi_field_info_get_type_info (GIFieldInfo *info) else return gi_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (FieldBlob, type)); - return (GIBaseInfo*)type_info; + return (GITypeInfo *) type_info; } /** diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index 460947573..1097c9537 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -311,7 +311,7 @@ gi_interface_info_find_signal (GIInterfaceInfo *info, { GISignalInfo *siginfo = gi_interface_info_get_signal (info, i); - if (g_strcmp0 (gi_base_info_get_name (siginfo), name) != 0) + if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0) { gi_base_info_unref ((GIBaseInfo*)siginfo); continue; diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 4c1e1f0a1..f9248f260 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -496,7 +496,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info, result = gi_object_info_find_method (info, name); if (result) - implementor_result = gi_base_info_ref ((GIBaseInfo*) info); + implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info); if (result == NULL) { @@ -514,7 +514,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info, if (result != NULL) { - implementor_result = iface_info; + implementor_result = (GIObjectInfo *) iface_info; break; } gi_base_info_unref ((GIBaseInfo*) iface_info); @@ -607,7 +607,7 @@ gi_object_info_find_signal (GIObjectInfo *info, { GISignalInfo *siginfo = gi_object_info_get_signal (info, i); - if (g_strcmp0 (gi_base_info_get_name (siginfo), name) != 0) + if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0) { gi_base_info_unref ((GIBaseInfo*)siginfo); continue; @@ -750,7 +750,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, result = gi_object_info_find_vfunc (info, name); if (result) - implementor_result = gi_base_info_ref ((GIBaseInfo*) info); + implementor_result = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo*) info); if (result == NULL) { @@ -768,7 +768,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, if (result != NULL) { - implementor_result = iface_info; + implementor_result = (GIObjectInfo *) iface_info; break; } gi_base_info_unref ((GIBaseInfo*) iface_info); @@ -881,7 +881,7 @@ _get_func(GIObjectInfo *info, GIObjectInfo *parent_info; gpointer func = NULL; - parent_info = gi_base_info_ref (info); + parent_info = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo *) info); while (parent_info != NULL) { parents = g_slist_prepend (parents, parent_info); diff --git a/girepository/girepository.c b/girepository/girepository.c index 1b19040e6..c7ad8abcb 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -958,7 +958,7 @@ gi_repository_find_by_error_domain (GIRepository *repository, GUINT_TO_POINTER (domain)); if (cached != NULL) - return gi_base_info_ref ((GIBaseInfo *)cached); + return (GIEnumInfo *) gi_base_info_ref ((GIBaseInfo *)cached); data.repository = repository; data.domain = domain; @@ -971,13 +971,13 @@ gi_repository_find_by_error_domain (GIRepository *repository, if (data.result != NULL) { - cached = gi_info_new_full (data.result->blob_type, - repository, - NULL, data.result_typelib, data.result->offset); + cached = (GIEnumInfo *) gi_info_new_full (data.result->blob_type, + repository, + NULL, data.result_typelib, data.result->offset); g_hash_table_insert (repository->priv->info_by_error_domain, GUINT_TO_POINTER (domain), - gi_base_info_ref (cached)); + gi_base_info_ref ((GIBaseInfo *) cached)); return cached; } return NULL; diff --git a/girepository/girffi.c b/girepository/girffi.c index ad2c57006..a9e64fa55 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -293,7 +293,7 @@ gi_function_info_prep_invoker (GIFunctionInfo *info, return FALSE; } - return gi_function_invoker_new_for_address (addr, info, invoker, error); + return gi_function_invoker_new_for_address (addr, (GICallableInfo *) info, invoker, error); } /** diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 44300cb72..1a039fff1 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -607,7 +607,7 @@ write_function_info (const gchar *ns, else if (flags & GI_FUNCTION_IS_GETTER) xml_printf (file, " glib:get-property=\"%s\"", property_name); - gi_base_info_unref (property); + gi_base_info_unref ((GIBaseInfo *) property); } } diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index c66504aaf..c614bffc4 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -367,7 +367,7 @@ gi_type_info_get_storage_type (GITypeInfo *info) GIBaseInfo *interface = gi_type_info_get_interface (info); GIInfoType info_type = gi_base_info_get_type (interface); if (info_type == GI_INFO_TYPE_ENUM || info_type == GI_INFO_TYPE_FLAGS) - type_tag = gi_enum_info_get_storage_type (interface); + type_tag = gi_enum_info_get_storage_type ((GIEnumInfo *) interface); gi_base_info_unref (interface); } diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 3fba0c028..c15df8a60 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -233,7 +233,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, g_return_val_if_fail (GI_IS_VFUNC_INFO (vfunc_info), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); - container_info = gi_base_info_get_container (vfunc_info); + container_info = gi_base_info_get_container ((GIBaseInfo *) vfunc_info); if (gi_base_info_get_type (container_info) == GI_INFO_TYPE_OBJECT) { object_info = (GIObjectInfo*) container_info; @@ -254,7 +254,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, if (strcmp (gi_base_info_get_name ( (GIBaseInfo*) field_info), gi_base_info_get_name ( (GIBaseInfo*) vfunc_info)) != 0) { - gi_base_info_unref (field_info); + gi_base_info_unref ((GIBaseInfo *) field_info); field_info = NULL; continue; } @@ -288,7 +288,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, offset = gi_field_info_get_offset (field_info); func = *(gpointer*) G_STRUCT_MEMBER_P (implementor_vtable, offset); g_type_class_unref (implementor_class); - gi_base_info_unref (field_info); + gi_base_info_unref ((GIBaseInfo *) field_info); if (func == NULL) { From b5dedf88cb14497e6ac8adedbab7b0b8500e289a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:15:28 +0000 Subject: [PATCH 18/31] gibaseinfo: Add a missing (transfer full) annotation Signed-off-by: Philip Withnall --- girepository/gibaseinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 27cb1d3aa..be2792253 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -85,7 +85,7 @@ gi_info_new_full (GIInfoType type, * * TODO * - * Returns: TODO + * Returns: (transfer full): TODO */ GIBaseInfo * gi_info_new (GIInfoType type, From aa50e6fd9d9554a298508d1a7d27f6e3e558ef54 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:19:51 +0000 Subject: [PATCH 19/31] girepository: Use gi_base_info_get_type() instead of field access The `type` field will eventually disappear, so use an accessor method to get it. This introduces no functional changes. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gibaseinfo.c | 6 +++--- girepository/gicallableinfo.c | 6 +++--- girepository/gifunctioninfo.c | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index be2792253..130c728ed 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -307,7 +307,7 @@ gi_base_info_get_name (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; g_assert (rinfo->ref_count > 0); - switch (rinfo->type) + switch (gi_base_info_get_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: @@ -407,7 +407,7 @@ gi_base_info_get_namespace (GIBaseInfo *info) g_assert (rinfo->ref_count > 0); - if (rinfo->type == GI_INFO_TYPE_UNRESOLVED) + if (gi_base_info_get_type (info) == GI_INFO_TYPE_UNRESOLVED) { GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info; @@ -430,7 +430,7 @@ gboolean gi_base_info_is_deprecated (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*) info; - switch (rinfo->type) + switch (gi_base_info_get_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 2bdcd1b8e..0acb65d9b 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -59,7 +59,7 @@ signature_offset (GICallableInfo *info) GIRealInfo *rinfo = (GIRealInfo*)info; int sigoff = -1; - switch (rinfo->type) + switch (gi_base_info_get_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: sigoff = G_STRUCT_OFFSET (FunctionBlob, signature); @@ -105,7 +105,7 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info) * to support the other callables. For Functions and VFuncs, * also check their legacy flag for compatibility. */ - switch (rinfo->type) { + switch (gi_base_info_get_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: { FunctionBlob *blob; @@ -147,7 +147,7 @@ gboolean gi_callable_info_is_method (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; - switch (rinfo->type) { + switch (gi_base_info_get_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: { FunctionBlob *blob; diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 6a7bedcdd..da2cab79f 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -158,7 +158,7 @@ gi_function_info_get_flags (GIFunctionInfo *info) GIPropertyInfo * gi_function_info_get_property (GIFunctionInfo *info) { - GIRealInfo *rinfo, *container_rinfo; + GIRealInfo *rinfo; FunctionBlob *blob; g_return_val_if_fail (info != NULL, NULL); @@ -166,15 +166,14 @@ gi_function_info_get_property (GIFunctionInfo *info) rinfo = (GIRealInfo *)info; blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset]; - container_rinfo = (GIRealInfo *)rinfo->container; - if (container_rinfo->type == GI_INFO_TYPE_INTERFACE) + if (gi_base_info_get_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_INTERFACE) { GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container; return gi_interface_info_get_property (container, blob->index); } - else if (container_rinfo->type == GI_INFO_TYPE_OBJECT) + else if (gi_base_info_get_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_OBJECT) { GIObjectInfo *container = (GIObjectInfo *)rinfo->container; From 64ad0ecebc0dbea31780a1ca566e532b3549f74a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 12 Dec 2023 16:16:30 +0000 Subject: [PATCH 20/31] girepository: Rename gi_base_info_get_type() to get_info_type() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This method doesn’t return a `GType`, so when the code gets ported to `GTypeInstance` in an upcoming commit, that will become quite confusing. Rename it to `gi_base_info_get_info_type()` instead. This introduces no functional changes, but it is an API break. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giarginfo.h | 2 +- girepository/gibaseinfo.c | 10 +++++----- girepository/gibaseinfo.h | 2 +- girepository/gicallableinfo.c | 8 ++++---- girepository/gicallableinfo.h | 8 ++++---- girepository/giconstantinfo.h | 2 +- girepository/gienuminfo.h | 6 +++--- girepository/gifieldinfo.c | 14 +++++++------- girepository/gifieldinfo.h | 2 +- girepository/gifunctioninfo.c | 4 ++-- girepository/gifunctioninfo.h | 2 +- girepository/giinterfaceinfo.h | 2 +- girepository/giobjectinfo.h | 2 +- girepository/gipropertyinfo.c | 4 ++-- girepository/gipropertyinfo.h | 2 +- girepository/giregisteredtypeinfo.h | 16 ++++++++-------- girepository/girepository.c | 2 +- girepository/girffi.c | 2 +- girepository/girwriter.c | 12 ++++++------ girepository/gisignalinfo.h | 2 +- girepository/gistructinfo.h | 2 +- girepository/gitypeinfo.c | 2 +- girepository/gitypeinfo.h | 2 +- girepository/giunioninfo.h | 2 +- girepository/givfuncinfo.c | 4 ++-- girepository/givfuncinfo.h | 2 +- 26 files changed, 59 insertions(+), 59 deletions(-) diff --git a/girepository/giarginfo.h b/girepository/giarginfo.h index 448e6cc81..eaff5f5c8 100644 --- a/girepository/giarginfo.h +++ b/girepository/giarginfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a GIArgInfo. */ #define GI_IS_ARG_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ARG) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ARG) GI_AVAILABLE_IN_ALL diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 130c728ed..6eaf9b09e 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -278,7 +278,7 @@ gi_base_info_unref (GIBaseInfo *info) } /** - * gi_base_info_get_type: + * gi_base_info_get_info_type: * @info: a #GIBaseInfo * * Obtain the info type of the GIBaseInfo. @@ -286,7 +286,7 @@ gi_base_info_unref (GIBaseInfo *info) * Returns: the info type of @info */ GIInfoType -gi_base_info_get_type (GIBaseInfo *info) +gi_base_info_get_info_type (GIBaseInfo *info) { return ((GIRealInfo*)info)->type; @@ -307,7 +307,7 @@ gi_base_info_get_name (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; g_assert (rinfo->ref_count > 0); - switch (gi_base_info_get_type ((GIBaseInfo *) info)) + switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: @@ -407,7 +407,7 @@ gi_base_info_get_namespace (GIBaseInfo *info) g_assert (rinfo->ref_count > 0); - if (gi_base_info_get_type (info) == GI_INFO_TYPE_UNRESOLVED) + if (gi_base_info_get_info_type (info) == GI_INFO_TYPE_UNRESOLVED) { GIUnresolvedInfo *unresolved = (GIUnresolvedInfo *)info; @@ -430,7 +430,7 @@ gboolean gi_base_info_is_deprecated (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*) info; - switch (gi_base_info_get_type ((GIBaseInfo *) info)) + switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index b6998293f..182c6bc08 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -61,7 +61,7 @@ GI_AVAILABLE_IN_ALL void gi_base_info_unref (GIBaseInfo *info); GI_AVAILABLE_IN_ALL -GIInfoType gi_base_info_get_type (GIBaseInfo *info); +GIInfoType gi_base_info_get_info_type (GIBaseInfo *info); GI_AVAILABLE_IN_ALL const gchar * gi_base_info_get_name (GIBaseInfo *info); diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 0acb65d9b..bb6c0d8e1 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -59,7 +59,7 @@ signature_offset (GICallableInfo *info) GIRealInfo *rinfo = (GIRealInfo*)info; int sigoff = -1; - switch (gi_base_info_get_type ((GIBaseInfo *) info)) + switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: sigoff = G_STRUCT_OFFSET (FunctionBlob, signature); @@ -105,7 +105,7 @@ gi_callable_info_can_throw_gerror (GICallableInfo *info) * to support the other callables. For Functions and VFuncs, * also check their legacy flag for compatibility. */ - switch (gi_base_info_get_type ((GIBaseInfo *) info)) { + switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: { FunctionBlob *blob; @@ -147,7 +147,7 @@ gboolean gi_callable_info_is_method (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; - switch (gi_base_info_get_type ((GIBaseInfo *) info)) { + switch (gi_base_info_get_info_type ((GIBaseInfo *) info)) { case GI_INFO_TYPE_FUNCTION: { FunctionBlob *blob; @@ -573,7 +573,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, if (return_tag == GI_TYPE_TAG_INTERFACE) { GIBaseInfo *interface_info = gi_type_info_get_interface (return_info); - interface_type = gi_base_info_get_type (interface_info); + interface_type = gi_base_info_get_info_type (interface_info); gi_base_info_unref (interface_info); } diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index 960734102..9c56d9404 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -39,10 +39,10 @@ G_BEGIN_DECLS * Checks if @info is a #GICallableInfo or derived from it. */ #define GI_IS_CALLABLE_INFO(info) \ - ((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FUNCTION) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CALLBACK) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_SIGNAL) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VFUNC)) + ((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FUNCTION) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_SIGNAL) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VFUNC)) GI_AVAILABLE_IN_ALL diff --git a/girepository/giconstantinfo.h b/girepository/giconstantinfo.h index 21795acf0..56c2cc85d 100644 --- a/girepository/giconstantinfo.h +++ b/girepository/giconstantinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIConstantInfo. */ #define GI_IS_CONSTANT_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_CONSTANT) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CONSTANT) GI_AVAILABLE_IN_ALL diff --git a/girepository/gienuminfo.h b/girepository/gienuminfo.h index a76d75bb1..d8aec74c7 100644 --- a/girepository/gienuminfo.h +++ b/girepository/gienuminfo.h @@ -39,8 +39,8 @@ G_BEGIN_DECLS * Checks if @info is a #GIEnumInfo. */ #define GI_IS_ENUM_INFO(info) \ - ((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS)) + ((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ENUM) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FLAGS)) /** * GI_IS_VALUE_INFO @@ -49,7 +49,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIValueInfo. */ #define GI_IS_VALUE_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VALUE) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VALUE) GI_AVAILABLE_IN_ALL diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 4e7c0fb27..8bb510a37 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -263,7 +263,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, case GI_TYPE_TAG_INTERFACE: { GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_type (interface)) + switch (gi_base_info_get_info_type (interface)) { case GI_INFO_TYPE_STRUCT: case GI_INFO_TYPE_UNION: @@ -317,7 +317,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, case GI_INFO_TYPE_CALLBACK: g_warning("Field %s: Interface type %d should have is_pointer set", gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_type (interface)); + gi_base_info_get_info_type (interface)); break; case GI_INFO_TYPE_INVALID: case GI_INFO_TYPE_INTERFACE: @@ -333,7 +333,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, case GI_INFO_TYPE_UNRESOLVED: g_warning("Field %s: Interface type %d not expected", gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_type (interface)); + gi_base_info_get_info_type (interface)); break; default: break; @@ -447,7 +447,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, case GI_TYPE_TAG_INTERFACE: { GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_type (interface)) + switch (gi_base_info_get_info_type (interface)) { case GI_INFO_TYPE_STRUCT: case GI_INFO_TYPE_UNION: @@ -497,7 +497,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, case GI_INFO_TYPE_CALLBACK: g_warning("Field%s: Interface type %d should have is_pointer set", gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_type (interface)); + gi_base_info_get_info_type (interface)); break; case GI_INFO_TYPE_INVALID: case GI_INFO_TYPE_INTERFACE: @@ -513,7 +513,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, case GI_INFO_TYPE_UNRESOLVED: g_warning("Field %s: Interface type %d not expected", gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_type (interface)); + gi_base_info_get_info_type (interface)); break; default: break; @@ -532,7 +532,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, case GI_TYPE_TAG_INTERFACE: { GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_type (interface)) + switch (gi_base_info_get_info_type (interface)) { case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index b11dd777b..6c5b7e06a 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -40,7 +40,7 @@ G_BEGIN_DECLS * */ #define GI_IS_FIELD_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FIELD) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FIELD) GI_AVAILABLE_IN_ALL diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index da2cab79f..5180299c1 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -167,13 +167,13 @@ gi_function_info_get_property (GIFunctionInfo *info) rinfo = (GIRealInfo *)info; blob = (FunctionBlob *)&rinfo->typelib->data[rinfo->offset]; - if (gi_base_info_get_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_INTERFACE) + if (gi_base_info_get_info_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_INTERFACE) { GIInterfaceInfo *container = (GIInterfaceInfo *)rinfo->container; return gi_interface_info_get_property (container, blob->index); } - else if (gi_base_info_get_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_OBJECT) + else if (gi_base_info_get_info_type ((GIBaseInfo *) rinfo->container) == GI_INFO_TYPE_OBJECT) { GIObjectInfo *container = (GIObjectInfo *)rinfo->container; diff --git a/girepository/gifunctioninfo.h b/girepository/gifunctioninfo.h index 7c3859d4d..3f95fe680 100644 --- a/girepository/gifunctioninfo.h +++ b/girepository/gifunctioninfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIFunctionInfo. */ #define GI_IS_FUNCTION_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FUNCTION) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FUNCTION) GI_AVAILABLE_IN_ALL diff --git a/girepository/giinterfaceinfo.h b/girepository/giinterfaceinfo.h index daaf5f038..7334f76c7 100644 --- a/girepository/giinterfaceinfo.h +++ b/girepository/giinterfaceinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIInterfaceInfo. */ #define GI_IS_INTERFACE_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_INTERFACE) GI_AVAILABLE_IN_ALL diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index 58fef90fb..4b661cbd4 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -76,7 +76,7 @@ typedef void * (*GIObjectInfoGetValueFunction) (const GValue *value); * Checks if @info is a #GIObjectInfo. */ #define GI_IS_OBJECT_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_OBJECT) GI_AVAILABLE_IN_ALL diff --git a/girepository/gipropertyinfo.c b/girepository/gipropertyinfo.c index 3e65e15d1..76255a711 100644 --- a/girepository/gipropertyinfo.c +++ b/girepository/gipropertyinfo.c @@ -160,7 +160,7 @@ gi_property_info_get_setter (GIPropertyInfo *info) return NULL; container = rinfo->container; - parent_type = gi_base_info_get_type (container); + parent_type = gi_base_info_get_info_type (container); if (parent_type == GI_INFO_TYPE_OBJECT) return gi_object_info_get_method ((GIObjectInfo *) container, blob->setter); else if (parent_type == GI_INFO_TYPE_INTERFACE) @@ -199,7 +199,7 @@ gi_property_info_get_getter (GIPropertyInfo *info) return NULL; container = rinfo->container; - parent_type = gi_base_info_get_type (container); + parent_type = gi_base_info_get_info_type (container); if (parent_type == GI_INFO_TYPE_OBJECT) return gi_object_info_get_method ((GIObjectInfo *) container, blob->getter); else if (parent_type == GI_INFO_TYPE_INTERFACE) diff --git a/girepository/gipropertyinfo.h b/girepository/gipropertyinfo.h index d5ba46c72..277b2d6da 100644 --- a/girepository/gipropertyinfo.h +++ b/girepository/gipropertyinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIPropertyInfo. */ #define GI_IS_PROPERTY_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_PROPERTY) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_PROPERTY) GI_AVAILABLE_IN_ALL diff --git a/girepository/giregisteredtypeinfo.h b/girepository/giregisteredtypeinfo.h index 3c9d5359d..c0707f3e4 100644 --- a/girepository/giregisteredtypeinfo.h +++ b/girepository/giregisteredtypeinfo.h @@ -40,14 +40,14 @@ G_BEGIN_DECLS * Checks if @info is a #GIRegisteredTypeInfo or derived from it. */ #define GI_IS_REGISTERED_TYPE_INFO(info) \ - ((gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_BOXED) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION) || \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_BOXED)) + ((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_BOXED) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_ENUM) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FLAGS) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_INTERFACE) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_OBJECT) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_STRUCT) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNION) || \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_BOXED)) GI_AVAILABLE_IN_ALL const gchar * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); diff --git a/girepository/girepository.c b/girepository/girepository.c index c7ad8abcb..76ed9ebfa 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -1034,7 +1034,7 @@ gi_repository_get_object_gtype_interfaces (GIRepository *repository, if (base_info == NULL) continue; - if (gi_base_info_get_type (base_info) != GI_INFO_TYPE_INTERFACE) + if (gi_base_info_get_info_type (base_info) != GI_INFO_TYPE_INTERFACE) { /* FIXME - could this really happen? */ gi_base_info_unref (base_info); diff --git a/girepository/girffi.c b/girepository/girffi.c index a9e64fa55..618216e3a 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -146,7 +146,7 @@ gi_type_info_get_ffi_type (GITypeInfo *info) if (gi_type_info_get_tag (info) == GI_TYPE_TAG_INTERFACE) { iinfo = gi_type_info_get_interface (info); - switch (gi_base_info_get_type (iinfo)) + switch (gi_base_info_get_info_type (iinfo)) { case GI_INFO_TYPE_ENUM: case GI_INFO_TYPE_FLAGS: diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 1a039fff1..fdbe9a23a 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -165,7 +165,7 @@ xml_free (Xml *xml) static void check_unresolved (GIBaseInfo *info) { - if (gi_base_info_get_type (info) != GI_INFO_TYPE_UNRESOLVED) + if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED) return; g_critical ("Found unresolved type '%s' '%s'\n", @@ -442,7 +442,7 @@ write_field_info (const gchar *ns, } interface = gi_type_info_get_interface (type); - if (interface && gi_base_info_get_type(interface) == GI_INFO_TYPE_CALLBACK) + if (interface && gi_base_info_get_info_type (interface) == GI_INFO_TYPE_CALLBACK) write_callback_info (ns, (GICallbackInfo *)interface, file); else write_type_info (ns, type, file); @@ -661,7 +661,7 @@ write_struct_info (const gchar *ns, type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_init = gi_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); - if (gi_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_BOXED) + if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_BOXED) { xml_start_element (file, "glib:boxed"); xml_printf (file, " glib:name=\"%s\"", name); @@ -849,7 +849,7 @@ write_enum_info (const gchar *ns, type_init = gi_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); error_domain = gi_enum_info_get_error_domain (info); - if (gi_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_ENUM) + if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_ENUM) xml_start_element (file, "enumeration"); else xml_start_element (file, "bitfield"); @@ -1414,7 +1414,7 @@ gi_ir_writer_write (const char *filename, for (j = 0; j < n_infos; j++) { GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j); - switch (gi_base_info_get_type (info)) + switch (gi_base_info_get_info_type (info)) { case GI_INFO_TYPE_FUNCTION: write_function_info (ns, (GIFunctionInfo *)info, xml); @@ -1451,7 +1451,7 @@ gi_ir_writer_write (const char *filename, break; default: - g_error ("unknown info type %d\n", gi_base_info_get_type (info)); + g_error ("unknown info type %d\n", gi_base_info_get_info_type (info)); } gi_base_info_unref (info); diff --git a/girepository/gisignalinfo.h b/girepository/gisignalinfo.h index cbf6d7992..ae2e712a1 100644 --- a/girepository/gisignalinfo.h +++ b/girepository/gisignalinfo.h @@ -40,7 +40,7 @@ G_BEGIN_DECLS * Checks if @info is a #GISignalInfo. */ #define GI_IS_SIGNAL_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_SIGNAL) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_SIGNAL) GI_AVAILABLE_IN_ALL diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index a44b1f43e..a1c9eedbc 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GIStructInfo. */ #define GI_IS_STRUCT_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_STRUCT) GI_AVAILABLE_IN_ALL diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index c614bffc4..4c4a37c14 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -365,7 +365,7 @@ gi_type_info_get_storage_type (GITypeInfo *info) if (type_tag == GI_TYPE_TAG_INTERFACE) { GIBaseInfo *interface = gi_type_info_get_interface (info); - GIInfoType info_type = gi_base_info_get_type (interface); + GIInfoType info_type = gi_base_info_get_info_type (interface); if (info_type == GI_INFO_TYPE_ENUM || info_type == GI_INFO_TYPE_FLAGS) type_tag = gi_enum_info_get_storage_type ((GIEnumInfo *) interface); gi_base_info_unref (interface); diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 527f9496d..54cd177f4 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * Checks if @info is a #GITypeInfo. */ #define GI_IS_TYPE_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_TYPE) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_TYPE) /** * GI_TYPE_TAG_IS_BASIC diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index ed941dc0c..b1d0ffe3d 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -41,7 +41,7 @@ G_BEGIN_DECLS * Since: 2.80 */ #define GI_IS_UNION_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNION) GI_AVAILABLE_IN_ALL gint gi_union_info_get_n_fields (GIUnionInfo *info); diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index c15df8a60..b979ebb33 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -194,7 +194,7 @@ gi_vfunc_info_get_invoker (GIVFuncInfo *info) return NULL; container = rinfo->container; - parent_type = gi_base_info_get_type (container); + parent_type = gi_base_info_get_info_type (container); if (parent_type == GI_INFO_TYPE_OBJECT) return gi_object_info_get_method ((GIObjectInfo*)container, blob->invoker); else if (parent_type == GI_INFO_TYPE_INTERFACE) @@ -234,7 +234,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, g_return_val_if_fail (error == NULL || *error == NULL, NULL); container_info = gi_base_info_get_container ((GIBaseInfo *) vfunc_info); - if (gi_base_info_get_type (container_info) == GI_INFO_TYPE_OBJECT) + if (gi_base_info_get_info_type (container_info) == GI_INFO_TYPE_OBJECT) { object_info = (GIObjectInfo*) container_info; interface_info = NULL; diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index fce453d48..598064e96 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -41,7 +41,7 @@ G_BEGIN_DECLS * Since: 2.80 */ #define GI_IS_VFUNC_INFO(info) \ - (gi_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VFUNC) + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_VFUNC) GI_AVAILABLE_IN_ALL GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info); From cdb5ab0cd2cbd6374d6795b2b2720fbc8891ebdc Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:20:42 +0000 Subject: [PATCH 21/31] gicallableinfo: Fix type of method self argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an API break, but that’s fine since we haven’t frozen the libgirepository API yet. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gicallableinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index bb6c0d8e1..b94cd677b 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -597,7 +597,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, * TODO */ gboolean -gi_callable_info_invoke (GIFunctionInfo *info, +gi_callable_info_invoke (GICallableInfo *info, gpointer function, const GIArgument *in_args, int n_in_args, From 52ac467426e9fe30dedf374b2a04425db028e70f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:24:20 +0000 Subject: [PATCH 22/31] girepository: Port GIBaseInfo to GTypeInstance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds more type safety to libgirepository, and allows differentiating the `GIBaseInfo` derived types using the type system. Two new derived types had to be added (previously they were just a collection of helper methods which worked directly on a `GIBaseInfo` and didn’t check types): `GICallbackInfo` and `GIUnresolvedInfo`. Further cleanups and refactoring might be needed on this, but the core of libgirepository now uses `GTypeInstance` and appears to still work (it’s difficult to be entirely sure because there are no unit tests yet). Signed-off-by: Philip Withnall Helps: #3155 --- girepository/giarginfo.c | 10 + girepository/gibaseinfo-private.h | 58 +++++ girepository/gibaseinfo.c | 323 ++++++++++++++++++++++++---- girepository/gicallableinfo.c | 10 + girepository/gicallbackinfo.c | 52 +++++ girepository/gicallbackinfo.h | 43 ++++ girepository/giconstantinfo.c | 9 + girepository/gienuminfo.c | 19 ++ girepository/gifieldinfo.c | 10 + girepository/gifunctioninfo.c | 10 + girepository/giinterfaceinfo.c | 9 + girepository/giobjectinfo.c | 10 + girepository/gipropertyinfo.c | 10 + girepository/giregisteredtypeinfo.c | 9 + girepository/girepository-private.h | 166 ++++++++++++-- girepository/girepository.h | 2 + girepository/gisignalinfo.c | 9 + girepository/gistructinfo.c | 10 + girepository/gitypeinfo.c | 10 + girepository/gitypes.h | 191 ++++++---------- girepository/giunioninfo.c | 30 ++- girepository/giunresolvedinfo.c | 52 +++++ girepository/giunresolvedinfo.h | 43 ++++ girepository/givfuncinfo.c | 14 +- girepository/meson.build | 4 + 25 files changed, 921 insertions(+), 192 deletions(-) create mode 100644 girepository/gibaseinfo-private.h create mode 100644 girepository/gicallbackinfo.c create mode 100644 girepository/gicallbackinfo.h create mode 100644 girepository/giunresolvedinfo.c create mode 100644 girepository/giunresolvedinfo.h diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index 58eed2c5f..04c67c019 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -26,6 +26,7 @@ #include +#include "gibaseinfo-private.h" #include "gitypelib-internal.h" #include "girepository-private.h" #include "giarginfo.h" @@ -333,3 +334,12 @@ gi_arg_info_load_type (GIArgInfo *info, gi_type_info_init ((GIBaseInfo *) type, (GIBaseInfo*)info, rinfo->typelib, rinfo->offset + G_STRUCT_OFFSET (ArgBlob, arg_type)); } + +void +gi_arg_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_ARG; +} diff --git a/girepository/gibaseinfo-private.h b/girepository/gibaseinfo-private.h new file mode 100644 index 000000000..3c115ee4a --- /dev/null +++ b/girepository/gibaseinfo-private.h @@ -0,0 +1,58 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Parsed GIR + * + * Copyright 2023 GNOME Foundation Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#include +#include + +#include "gitypes.h" + +G_BEGIN_DECLS + +/* Keep this in sync with the GIInfoType enumeration. + * + * We don't add an "n-types" value to avoid having to handle + * it in every single switch. + */ +#define GI_INFO_TYPE_N_TYPES (GI_INFO_TYPE_REGISTERED_TYPE + 1) + +#define GI_IS_BASE_INFO_TYPE(info,type) \ + (G_TYPE_INSTANCE_GET_CLASS ((info), GI_TYPE_BASE_INFO, GIBaseInfoClass)->info_type == (type)) + +struct _GIBaseInfoClass +{ + GTypeClass parent_class; + + GIInfoType info_type; + + void (* finalize) (GIBaseInfo *info); +}; + +void gi_base_info_init_types (void); + +GType gi_base_info_type_register_static (const char *type_name, + gsize instance_size, + GClassInitFunc class_init); + +G_END_DECLS diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 6eaf9b09e..1ed1ae162 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -29,26 +29,284 @@ #include #include +#include #include "gitypelib-internal.h" #include "girepository-private.h" #include "gibaseinfo.h" +#include "gibaseinfo-private.h" #define INVALID_REFCOUNT 0x7FFFFFFF -/* GBoxed registration of BaseInfo. */ +/* Type registration of BaseInfo. */ +#define GI_BASE_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GI_TYPE_BASE_INFO, GIBaseInfoClass)) + +static void +value_base_info_init (GValue *value) +{ + value->data[0].v_pointer = NULL; +} + +static void +value_base_info_free_value (GValue *value) +{ + if (value->data[0].v_pointer != NULL) + gi_base_info_unref (value->data[0].v_pointer); +} + +static void +value_base_info_copy_value (const GValue *src, + GValue *dst) +{ + if (src->data[0].v_pointer != NULL) + dst->data[0].v_pointer = gi_base_info_ref (src->data[0].v_pointer); + else + dst->data[0].v_pointer = NULL; +} + +static gpointer +value_base_info_peek_pointer (const GValue *value) +{ + return value->data[0].v_pointer; +} + +static char * +value_base_info_collect_value (GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags) +{ + GIBaseInfo *info = collect_values[0].v_pointer; + + if (info == NULL) + { + value->data[0].v_pointer = NULL; + return NULL; + } + + if (info->parent_instance.g_class == NULL) + return g_strconcat ("invalid unclassed GIBaseInfo pointer for " + "value type '", + G_VALUE_TYPE_NAME (value), + "'", + NULL); + + value->data[0].v_pointer = gi_base_info_ref (info); + + return NULL; +} + +static gchar * +value_base_info_lcopy_value (const GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags) +{ + GIBaseInfo **node_p = collect_values[0].v_pointer; + + if (node_p == NULL) + return g_strconcat ("value location for '", + G_VALUE_TYPE_NAME (value), + "' passed as NULL", + NULL); + + if (value->data[0].v_pointer == NULL) + *node_p = NULL; + else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + *node_p = value->data[0].v_pointer; + else + *node_p = gi_base_info_ref (value->data[0].v_pointer); + + return NULL; +} + +static void +gi_base_info_finalize (GIBaseInfo *self) +{ + if (self->container && self->container->ref_count != INVALID_REFCOUNT) + gi_base_info_unref (self->container); + + g_clear_object (&self->repository); + + g_type_free_instance ((GTypeInstance *) self); +} + +static void +gi_base_info_class_init (GIBaseInfoClass *klass) +{ + klass->info_type = GI_INFO_TYPE_INVALID; + klass->finalize = gi_base_info_finalize; +} + +static void +gi_base_info_init (GIBaseInfo *self) +{ + g_atomic_ref_count_init (&self->ref_count); +} + GType gi_base_info_gtype_get_type (void) { - static GType our_type = 0; - - if (our_type == 0) - our_type = - g_boxed_type_register_static ("GIBaseInfo", - (GBoxedCopyFunc) gi_base_info_ref, - (GBoxedFreeFunc) gi_base_info_unref); + static GType base_info_type = 0; - return our_type; + if (g_once_init_enter_pointer (&base_info_type)) + { + static const GTypeFundamentalInfo finfo = { + (G_TYPE_FLAG_CLASSED | + G_TYPE_FLAG_INSTANTIATABLE | + G_TYPE_FLAG_DERIVABLE | + G_TYPE_FLAG_DEEP_DERIVABLE), + }; + + static const GTypeValueTable value_table = { + value_base_info_init, + value_base_info_free_value, + value_base_info_copy_value, + value_base_info_peek_pointer, + "p", + value_base_info_collect_value, + "p", + value_base_info_lcopy_value, + }; + + const GTypeInfo type_info = { + /* Class */ + sizeof (GIBaseInfoClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) gi_base_info_class_init, + (GClassFinalizeFunc) NULL, + NULL, + + /* Instance */ + sizeof (GIBaseInfo), + 0, + (GInstanceInitFunc) gi_base_info_init, + + /* GValue */ + &value_table, + }; + + GType _base_info_type = + g_type_register_fundamental (g_type_fundamental_next (), + g_intern_static_string ("GIBaseInfo"), + &type_info, &finfo, + G_TYPE_FLAG_ABSTRACT); + + g_once_init_leave_pointer (&base_info_type, _base_info_type); + } + + return base_info_type; +} + +/*< private > + * gi_base_info_type_register_static: + * @type_name: the name of the type + * @instance_size: size (in bytes) of the type’s instance struct + * @class_init: class init function for the type + * + * Registers a new [type@GIRepository.BaseInfo] type for the given @type_name + * using the type information provided. + * + * Returns: the newly registered [type@GObject.Type] + * Since: 2.80 + */ +GType +gi_base_info_type_register_static (const char *type_name, + gsize instance_size, + GClassInitFunc class_init) +{ + GTypeInfo info; + + info.class_size = sizeof (GIBaseInfoClass); + info.base_init = NULL; + info.base_finalize = NULL; + info.class_init = class_init; + info.class_finalize = NULL; + info.instance_size = instance_size; + info.n_preallocs = 0; + info.instance_init = NULL; + info.value_table = NULL; + + return g_type_register_static (GI_TYPE_BASE_INFO, type_name, &info, 0); +} + +static GType gi_base_info_types[GI_INFO_TYPE_N_TYPES]; + +#define GI_DEFINE_BASE_INFO_TYPE(type_name, TYPE_ENUM_VALUE) \ +GType \ +type_name ## _get_type (void) \ +{ \ + gi_base_info_init_types (); \ + g_assert (gi_base_info_types[TYPE_ENUM_VALUE] != G_TYPE_INVALID); \ + return gi_base_info_types[TYPE_ENUM_VALUE]; \ +} + +GI_DEFINE_BASE_INFO_TYPE (gi_callable_info, GI_INFO_TYPE_CALLABLE) +GI_DEFINE_BASE_INFO_TYPE (gi_function_info, GI_INFO_TYPE_FUNCTION) +GI_DEFINE_BASE_INFO_TYPE (gi_callback_info, GI_INFO_TYPE_CALLBACK) +GI_DEFINE_BASE_INFO_TYPE (gi_registered_type_info, GI_INFO_TYPE_REGISTERED_TYPE) +GI_DEFINE_BASE_INFO_TYPE (gi_struct_info, GI_INFO_TYPE_STRUCT) +GI_DEFINE_BASE_INFO_TYPE (gi_union_info, GI_INFO_TYPE_UNION) +GI_DEFINE_BASE_INFO_TYPE (gi_enum_info, GI_INFO_TYPE_ENUM) +GI_DEFINE_BASE_INFO_TYPE (gi_object_info, GI_INFO_TYPE_OBJECT) +GI_DEFINE_BASE_INFO_TYPE (gi_interface_info, GI_INFO_TYPE_INTERFACE) +GI_DEFINE_BASE_INFO_TYPE (gi_constant_info, GI_INFO_TYPE_CONSTANT) +GI_DEFINE_BASE_INFO_TYPE (gi_value_info, GI_INFO_TYPE_VALUE) +GI_DEFINE_BASE_INFO_TYPE (gi_signal_info, GI_INFO_TYPE_SIGNAL) +GI_DEFINE_BASE_INFO_TYPE (gi_vfunc_info, GI_INFO_TYPE_VFUNC) +GI_DEFINE_BASE_INFO_TYPE (gi_property_info, GI_INFO_TYPE_PROPERTY) +GI_DEFINE_BASE_INFO_TYPE (gi_field_info, GI_INFO_TYPE_FIELD) +GI_DEFINE_BASE_INFO_TYPE (gi_arg_info, GI_INFO_TYPE_ARG) +GI_DEFINE_BASE_INFO_TYPE (gi_type_info, GI_INFO_TYPE_TYPE) +GI_DEFINE_BASE_INFO_TYPE (gi_unresolved_info, GI_INFO_TYPE_UNRESOLVED) + +void +gi_base_info_init_types (void) +{ + static gsize register_types_once = 0; + + if (g_once_init_enter (®ister_types_once)) + { + const struct + { + GIInfoType info_type; + const char *type_name; + gsize instance_size; + GClassInitFunc class_init; + } + types[] = + { + { GI_INFO_TYPE_CALLABLE, "GICallableInfo", sizeof (GICallableInfo), gi_callable_info_class_init }, + { GI_INFO_TYPE_FUNCTION, "GIFunctionInfo", sizeof (GIFunctionInfo), gi_function_info_class_init }, + { GI_INFO_TYPE_CALLBACK, "GICallbackInfo", sizeof (GICallbackInfo), gi_callback_info_class_init }, + { GI_INFO_TYPE_REGISTERED_TYPE, "GIRegisteredTypeInfo", sizeof (GIRegisteredTypeInfo), gi_registered_type_info_class_init }, + { GI_INFO_TYPE_STRUCT, "GIStructInfo", sizeof (GIStructInfo), gi_struct_info_class_init }, + { GI_INFO_TYPE_UNION, "GIUnionInfo", sizeof (GIUnionInfo), gi_union_info_class_init }, + { GI_INFO_TYPE_ENUM, "GIEnumInfo", sizeof (GIEnumInfo), gi_enum_info_class_init }, + { GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init }, + { GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init }, + { GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init }, + { GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init }, + { GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init }, + { GI_INFO_TYPE_VFUNC, "GIVFuncInfo", sizeof (GIVFuncInfo), gi_vfunc_info_class_init }, + { GI_INFO_TYPE_PROPERTY, "GIPropertyInfo", sizeof (GIPropertyInfo), gi_property_info_class_init }, + { GI_INFO_TYPE_FIELD, "GIFieldInfo", sizeof (GIFieldInfo), gi_field_info_class_init }, + { GI_INFO_TYPE_ARG, "GIArgInfo", sizeof (GIArgInfo), gi_arg_info_class_init }, + { GI_INFO_TYPE_TYPE, "GITypeInfo", sizeof (GITypeInfo), gi_type_info_class_init }, + { GI_INFO_TYPE_UNRESOLVED, "GIUnresolvedInfo", sizeof (GIUnresolvedInfo), gi_unresolved_info_class_init }, + }; + + for (gsize i = 0; i < G_N_ELEMENTS (types); i++) + { + GType registered_type = gi_base_info_type_register_static (g_intern_static_string (types[i].type_name), + types[i].instance_size, + types[i].class_init); + gi_base_info_types[types[i].info_type] = registered_type; + } + + g_once_init_leave (®ister_types_once, 1); + } } /* info creation */ @@ -62,16 +320,21 @@ gi_info_new_full (GIInfoType type, GIRealInfo *info; g_return_val_if_fail (container != NULL || repository != NULL, NULL); + g_return_val_if_fail (GI_IS_REPOSITORY (repository), NULL); - info = g_slice_new (GIRealInfo); + gi_base_info_init_types (); + g_assert (gi_base_info_types[type] != G_TYPE_INVALID); + info = (GIRealInfo *) g_type_create_instance (gi_base_info_types[type]); - gi_info_init (info, type, repository, container, typelib, offset); - info->ref_count = 1; + info->typelib = typelib; + info->offset = offset; - if (container && ((GIRealInfo *) container)->ref_count != INVALID_REFCOUNT) + if (container) + info->container = container; + if (container && container->ref_count != INVALID_REFCOUNT) gi_base_info_ref (info->container); - g_object_ref (info->repository); + info->repository = g_object_ref (repository); return (GIBaseInfo*)info; } @@ -108,8 +371,6 @@ gi_info_init (GIRealInfo *info, /* Invalid refcount used to flag stack-allocated infos */ info->ref_count = INVALID_REFCOUNT; - info->type = type; - info->typelib = typelib; info->offset = offset; @@ -140,12 +401,12 @@ gi_info_from_entry (GIRepository *repository, { GIUnresolvedInfo *unresolved; - unresolved = g_slice_new0 (GIUnresolvedInfo); + unresolved = (GIUnresolvedInfo *) gi_info_new_full (GI_INFO_TYPE_UNRESOLVED, + repository, + NULL, + typelib, + entry->offset); - unresolved->type = GI_INFO_TYPE_UNRESOLVED; - unresolved->ref_count = 1; - unresolved->repository = g_object_ref (repository); - unresolved->container = NULL; unresolved->name = name; unresolved->namespace = namespace; @@ -243,7 +504,7 @@ gi_base_info_ref (GIBaseInfo *info) GIRealInfo *rinfo = (GIRealInfo*)info; g_assert (rinfo->ref_count != INVALID_REFCOUNT); - g_atomic_int_inc (&rinfo->ref_count); + g_atomic_ref_count_inc (&rinfo->ref_count); return info; } @@ -262,19 +523,8 @@ gi_base_info_unref (GIBaseInfo *info) g_assert (rinfo->ref_count > 0 && rinfo->ref_count != INVALID_REFCOUNT); - if (!g_atomic_int_dec_and_test (&rinfo->ref_count)) - return; - - if (rinfo->container && ((GIRealInfo *) rinfo->container)->ref_count != INVALID_REFCOUNT) - gi_base_info_unref (rinfo->container); - - if (rinfo->repository) - g_object_unref (rinfo->repository); - - if (rinfo->type == GI_INFO_TYPE_UNRESOLVED) - g_slice_free (GIUnresolvedInfo, (GIUnresolvedInfo *) rinfo); - else - g_slice_free (GIRealInfo, rinfo); + if (g_atomic_ref_count_dec (&rinfo->ref_count)) + GI_BASE_INFO_GET_CLASS (info)->finalize (info); } /** @@ -288,8 +538,7 @@ gi_base_info_unref (GIBaseInfo *info) GIInfoType gi_base_info_get_info_type (GIBaseInfo *info) { - - return ((GIRealInfo*)info)->type; + return GI_BASE_INFO_GET_CLASS (info)->info_type; } /** diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index b94cd677b..1d0e001cd 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -29,6 +29,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "girffi.h" @@ -791,3 +792,12 @@ gi_callable_info_invoke (GICallableInfo *info, gi_base_info_unref ((GIBaseInfo *)rinfo); return success; } + +void +gi_callable_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_CALLABLE; +} diff --git a/girepository/gicallbackinfo.c b/girepository/gicallbackinfo.c new file mode 100644 index 000000000..b7e88ea97 --- /dev/null +++ b/girepository/gicallbackinfo.c @@ -0,0 +1,52 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable implementation + * + * Copyright (C) 2005 Matthias Clasen + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include +#include "gibaseinfo-private.h" +#include "girepository-private.h" +#include "gitypelib-internal.h" +#include "gicallbackinfo.h" + +/** + * SECTION:gicallback + * @title: GICallbackInfo + * @short_description: Struct representing a callback + * + * GICallbackInfo represents a callback. + */ + +void +gi_callback_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_CALLBACK; +} diff --git a/girepository/gicallbackinfo.h b/girepository/gicallbackinfo.h new file mode 100644 index 000000000..c14c6fd7a --- /dev/null +++ b/girepository/gicallbackinfo.h @@ -0,0 +1,43 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable + * + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GI_IS_CALLBACK_INFO + * @info: an info structure + * + * Checks if @info is a #GICallbackInfo or derived from it. + */ +#define GI_IS_CALLBACK_INFO(info) \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK) + +G_END_DECLS diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index 28ef282b5..69e103ba0 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -28,6 +28,7 @@ #include // memcpy #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "giconstantinfo.h" @@ -176,3 +177,11 @@ gi_constant_info_get_value (GIConstantInfo *info, return blob->size; } +void +gi_constant_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_CONSTANT; +} diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index 4176ab2fc..8daa3ff5b 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gienuminfo.h" @@ -207,6 +208,15 @@ gi_enum_info_get_storage_type (GIEnumInfo *info) return blob->storage_type; } +void +gi_enum_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_ENUM; +} + /** * gi_value_info_get_value: * @info: a #GIValueInfo @@ -233,3 +243,12 @@ gi_value_info_get_value (GIValueInfo *info) else return (gint64)blob->value; } + +void +gi_value_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_VALUE; +} diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 8bb510a37..a204ddd16 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "config.h" @@ -554,3 +555,12 @@ gi_field_info_set_field (GIFieldInfo *field_info, return result; } + +void +gi_field_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_FIELD; +} diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 5180299c1..abab97906 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -29,6 +29,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gifunctioninfo.h" @@ -294,3 +295,12 @@ gi_function_info_invoke (GIFunctionInfo *info, throws, error); } + +void +gi_function_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_FUNCTION; +} diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index 1097c9537..17ffeb4da 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "giinterfaceinfo.h" @@ -501,3 +502,11 @@ gi_interface_info_get_iface_struct (GIInterfaceInfo *info) return NULL; } +void +gi_interface_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_INTERFACE; +} diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index f9248f260..5afeafb1c 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "giobjectinfo.h" @@ -1097,3 +1098,12 @@ gi_object_info_get_get_value_function_pointer (GIObjectInfo *info) return (GIObjectInfoGetValueFunction)_get_func(info, (SymbolGetter)gi_object_info_get_get_value_function); } + +void +gi_object_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_OBJECT; +} diff --git a/girepository/gipropertyinfo.c b/girepository/gipropertyinfo.c index 76255a711..463a289b7 100644 --- a/girepository/gipropertyinfo.c +++ b/girepository/gipropertyinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gipropertyinfo.h" @@ -207,3 +208,12 @@ gi_property_info_get_getter (GIPropertyInfo *info) else return NULL; } + +void +gi_property_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_PROPERTY; +} diff --git a/girepository/giregisteredtypeinfo.c b/girepository/giregisteredtypeinfo.c index 3537cf188..d3274c867 100644 --- a/girepository/giregisteredtypeinfo.c +++ b/girepository/giregisteredtypeinfo.c @@ -29,6 +29,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "giregisteredtypeinfo.h" @@ -144,3 +145,11 @@ gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info) return (* get_type_func) (); } +void +gi_registered_type_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_REGISTERED_TYPE; +} diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index 18d784876..83b9c1ef5 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -32,7 +32,9 @@ #include #include -typedef struct _GIRealInfo GIRealInfo; +/* FIXME: For now, GIRealInfo is a compatibility define. This will eventually + * be removed. */ +typedef struct _GIBaseInfo GIRealInfo; /* We changed a gint32 -> gint in the structure below, which should be * valid everywhere we care about. @@ -45,39 +47,169 @@ G_STATIC_ASSERT (sizeof (int) == sizeof (gint32)); * from the typelib, and not having computed data in * per-type structures. */ -struct _GIRealInfo +struct _GIBaseInfo { - /* Keep this part in sync with GIUnresolvedInfo below */ - gint32 type; - volatile gint ref_count; + /*< private >*/ + GTypeInstance parent_instance; + gatomicrefcount ref_count; + GIRepository *repository; GIBaseInfo *container; - /* Resolved specific */ - GITypelib *typelib; guint32 offset; guint32 type_is_embedded : 1; /* Used by GITypeInfo */ - guint32 reserved : 31; - - gpointer reserved2[4]; }; +/* Subtypes */ +struct _GICallableInfo +{ + GIBaseInfo parent; +}; + +void gi_callable_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIFunctionInfo +{ + GIBaseInfo parent; +}; + +void gi_function_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GICallbackInfo +{ + GIBaseInfo parent; +}; + +void gi_callback_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIRegisteredTypeInfo +{ + GIBaseInfo parent; +}; + +void gi_registered_type_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIStructInfo +{ + GIBaseInfo parent; +}; + +void gi_struct_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIUnionInfo +{ + GIBaseInfo parent; +}; + +void gi_union_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIEnumInfo +{ + GIBaseInfo parent; +}; + +void gi_enum_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIObjectInfo +{ + GIBaseInfo parent; +}; + +void gi_object_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIInterfaceInfo +{ + GIBaseInfo parent; +}; + +void gi_interface_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIConstantInfo +{ + GIBaseInfo parent; +}; + +void gi_constant_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIValueInfo +{ + GIBaseInfo parent; +}; + +void gi_value_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GISignalInfo +{ + GIBaseInfo parent; +}; + +void gi_signal_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIVFuncInfo +{ + GIBaseInfo parent; +}; + +void gi_vfunc_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIPropertyInfo +{ + GIBaseInfo parent; +}; + +void gi_property_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIFieldInfo +{ + GIBaseInfo parent; +}; + +void gi_field_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GIArgInfo +{ + GIBaseInfo parent; +}; + +void gi_arg_info_class_init (gpointer g_class, + gpointer class_data); + +struct _GITypeInfo +{ + GIBaseInfo parent; +}; + +void gi_type_info_class_init (gpointer g_class, + gpointer class_data); + struct _GIUnresolvedInfo { - /* Keep this part in sync with GIBaseInfo above */ - gint32 type; - volatile gint ref_count; - GIRepository *repository; - GIBaseInfo *container; - - /* Unresolved specific */ + GIBaseInfo parent; const gchar *name; const gchar *namespace; }; +void gi_unresolved_info_class_init (gpointer g_class, + gpointer class_data); + void gi_info_init (GIRealInfo *info, GIInfoType type, GIRepository *repository, diff --git a/girepository/girepository.h b/girepository/girepository.h index 7cf9a6768..96ac7194b 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include #include +#include #include G_BEGIN_DECLS diff --git a/girepository/gisignalinfo.c b/girepository/gisignalinfo.c index 9424c16f9..b4fc61c56 100644 --- a/girepository/gisignalinfo.c +++ b/girepository/gisignalinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gisignalinfo.h" @@ -141,3 +142,11 @@ gi_signal_info_true_stops_emit (GISignalInfo *info) return blob->true_stops_emit; } +void +gi_signal_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_SIGNAL; +} diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index 4b36cbb9a..eda380f2e 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -29,6 +29,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gistructinfo.h" @@ -338,3 +339,12 @@ gi_struct_info_get_free_function (GIStructInfo *info) return NULL; } + +void +gi_struct_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_STRUCT; +} diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 4c4a37c14..cf64ae78e 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "gitypeinfo.h" @@ -569,3 +570,12 @@ gi_type_info_hash_pointer_from_argument (GITypeInfo *info, GITypeTag storage_type = gi_type_info_get_storage_type (info); return gi_type_tag_hash_pointer_from_argument (storage_type, arg); } + +void +gi_type_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_TYPE; +} diff --git a/girepository/gitypes.h b/girepository/gitypes.h index cd432c762..b555a959d 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -29,155 +29,87 @@ #endif #include +#include + +#include "gi-visibility.h" G_BEGIN_DECLS -typedef struct _GIBaseInfoStub { - /*< private >*/ - gint32 dummy1; - gint32 dummy2; - gpointer dummy3; - gpointer dummy4; - gpointer dummy5; - guint32 dummy6; - guint32 dummy7; - gpointer padding[4]; -} GIBaseInfo; +/* Documented in gibaseinfo.c */ +typedef struct _GIBaseInfo GIBaseInfo; +typedef struct _GIBaseInfoClass GIBaseInfoClass; -/** - * GICallableInfo: - * - * Represents a callable, either #GIFunctionInfo, #GICallbackInfo or - * #GIVFuncInfo. - */ -typedef GIBaseInfo GICallableInfo; +/* Documented in gicallableinfo.c */ +typedef struct _GICallableInfo GICallableInfo; +GI_AVAILABLE_IN_ALL GType gi_callable_info_get_type (void); -/** - * GIFunctionInfo: - * - * Represents a function, eg arguments and return value. - */ -typedef GIBaseInfo GIFunctionInfo; +/* Documented in gifunctioninfo.c */ +typedef struct _GIFunctionInfo GIFunctionInfo; +GI_AVAILABLE_IN_ALL GType gi_function_info_get_type (void); -/** - * SECTION:gicallbackinfo - * @title: GICallbackInfo - * @short_description: Struct representing a callback - * - * GICallbackInfo represents a callback. - */ +/* Documented in gicallbackinfo.c */ +typedef struct _GICallbackInfo GICallbackInfo; +GI_AVAILABLE_IN_ALL GType gi_callback_info_get_type (void); -/** - * GICallbackInfo: - * - * Represents a callback, eg arguments and return value. - */ -typedef GIBaseInfo GICallbackInfo; +/* Documented in giregisteredtypeinfo.c */ +typedef struct _GIRegisteredTypeInfo GIRegisteredTypeInfo; +GI_AVAILABLE_IN_ALL GType gi_registered_type_info_get_type (void); -/** - * GIRegisteredTypeInfo: - * - * Represent a registered type. - */ -typedef GIBaseInfo GIRegisteredTypeInfo; - -/** - * GIStructInfo: - * - * Represents a struct. - */ -typedef GIBaseInfo GIStructInfo; +/* Documented in gistructinfo.c */ +typedef struct _GIStructInfo GIStructInfo; +GI_AVAILABLE_IN_ALL GType gi_struct_info_get_type (void); /* Documented in giunioninfo.c */ -typedef GIBaseInfo GIUnionInfo; +typedef struct _GIUnionInfo GIUnionInfo; +GI_AVAILABLE_IN_ALL GType gi_union_info_get_type (void); -/** - * GIEnumInfo: - * - * Represents an enum or a flag. - */ -typedef GIBaseInfo GIEnumInfo; +/* Documented in gienuminfo.c */ +typedef struct _GIEnumInfo GIEnumInfo; +GI_AVAILABLE_IN_ALL GType gi_enum_info_get_type (void); -/** - * GIObjectInfo: - * - * Represents an object. - */ -typedef GIBaseInfo GIObjectInfo; +/* Documented in giobjectinfo.c */ +typedef struct _GIObjectInfo GIObjectInfo; +GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void); -/** - * GIInterfaceInfo: - * - * Represents an interface. - */ -typedef GIBaseInfo GIInterfaceInfo; +/* Documented in giinterfaceinfo.c */ +typedef struct _GIInterfaceInfo GIInterfaceInfo; +GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void); -/** - * GIConstantInfo: - * - * Represents a constant. - */ -typedef GIBaseInfo GIConstantInfo; +/* Documented in giconstantinfo.c */ +typedef struct _GIConstantInfo GIConstantInfo; +GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void); -/** - * SECTION:givalueinfo - * @title: GIValueInfo - * @short_description: Struct representing a value - * - * GIValueInfo represents a value. - */ +/* Documented in givalueinfo.c */ +typedef struct _GIValueInfo GIValueInfo; +GI_AVAILABLE_IN_ALL GType gi_value_info_get_type (void); -/** - * GIValueInfo: - * - * Represents a enum value of a #GIEnumInfo. - */ -typedef GIBaseInfo GIValueInfo; - -/** - * GISignalInfo: - * - * Represents a signal. - */ -typedef GIBaseInfo GISignalInfo; +/* Documented in gisignalinfo.c */ +typedef struct _GISignalInfo GISignalInfo; +GI_AVAILABLE_IN_ALL GType gi_signal_info_get_type (void); /* Documented in givfuncinfo.c */ -typedef GIBaseInfo GIVFuncInfo; +typedef struct _GIVFuncInfo GIVFuncInfo; +GI_AVAILABLE_IN_ALL GType gi_vfunc_info_get_type (void); -/** - * GIPropertyInfo: - * - * Represents a property of a #GIObjectInfo or a #GIInterfaceInfo. - */ -typedef GIBaseInfo GIPropertyInfo; +/* Documented in gipropertyinfo.c */ +typedef struct _GIPropertyInfo GIPropertyInfo; +GI_AVAILABLE_IN_ALL GType gi_property_info_get_type (void); -/** - * GIFieldInfo: - * - * Represents a field of a #GIStructInfo or a #GIUnionInfo. - */ -typedef GIBaseInfo GIFieldInfo; +/* Documented in gifieldinfo.c */ +typedef struct _GIFieldInfo GIFieldInfo; +GI_AVAILABLE_IN_ALL GType gi_field_info_get_type (void); -/** - * GIArgInfo: - * - * Represents an argument. - */ -typedef GIBaseInfo GIArgInfo; +/* Documented in giarginfo.c */ +typedef struct _GIArgInfo GIArgInfo; +GI_AVAILABLE_IN_ALL GType gi_arg_info_get_type (void); -/** - * GITypeInfo: - * - * Represents type information, direction, transfer etc. - */ -typedef GIBaseInfo GITypeInfo; +/* Documented in gitypeinfo.c */ +typedef struct _GITypeInfo GITypeInfo; +GI_AVAILABLE_IN_ALL GType gi_type_info_get_type (void); -/** - * GIUnresolvedInfo: - * - * Represents a unresolved type in a typelib. - */ +/* Documented in giunresolvedinfo.c */ typedef struct _GIUnresolvedInfo GIUnresolvedInfo; +GI_AVAILABLE_IN_ALL GType gi_unresolved_info_get_type (void); union _GIArgument { @@ -255,6 +187,10 @@ typedef union _GIArgument GIArgument; * @GI_INFO_TYPE_TYPE: type information, see #GITypeInfo * @GI_INFO_TYPE_UNRESOLVED: unresolved type, a type which is not present in * the typelib, or any of its dependencies. + * @GI_INFO_TYPE_CALLABLE: an abstract type representing any callable (function, + * callback, vfunc) (Since: 2.80) + * @GI_INFO_TYPE_REGISTERED_TYPE: an abstract type representing any registered + * type (enum, interface, object, struct, union) (Since: 2.80) * * The type of a GIBaseInfo struct. */ @@ -279,7 +215,10 @@ typedef enum GI_INFO_TYPE_FIELD, GI_INFO_TYPE_ARG, GI_INFO_TYPE_TYPE, - GI_INFO_TYPE_UNRESOLVED + GI_INFO_TYPE_UNRESOLVED, + GI_INFO_TYPE_CALLABLE, /* 20 */ + GI_INFO_TYPE_REGISTERED_TYPE, + /* keep GI_INFO_TYPE_N_TYPES in sync with this */ } GIInfoType; /** diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index d80f50c0f..d1133554d 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -27,6 +27,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "giunioninfo.h" @@ -68,8 +69,8 @@ gi_union_info_get_n_fields (GIUnionInfo *info) * * Obtain the type information for the field with the specified index. * - * Returns: (transfer full): the [alias@GIRepository.FieldInfo], free it with - * gi_base_info_unref() when done. + * Returns: (transfer full): the [type@GIRepository.FieldInfo], free it with + * [method@GIRepository.BaseInfo.unref] when done. * Since: 2.80 */ GIFieldInfo * @@ -109,8 +110,8 @@ gi_union_info_get_n_methods (GIUnionInfo *info) * * Obtain the type information for the method with the specified index. * - * Returns: (transfer full): the [alias@GIRepository.FunctionInfo], free it - * with gi_base_info_unref() when done. + * Returns: (transfer full): the [type@GIRepository.FunctionInfo], free it + * with [method@GIRepository.BaseInfo.unref] when done. * Since: 2.80 */ GIFunctionInfo * @@ -171,8 +172,8 @@ gi_union_info_get_discriminator_offset (GIUnionInfo *info) * * Obtain the type information of the union discriminator. * - * Returns: (transfer full): the [alias@GIRepository.TypeInfo], free it with - * gi_base_info_unref() when done. + * Returns: (transfer full): the [type@GIRepository.TypeInfo], free it with + * [method@GIRepository.BaseInfo.unref] when done. * Since: 2.80 */ GITypeInfo * @@ -194,8 +195,8 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info) * * If the union is not discriminated, `NULL` is returned. * - * Returns: (transfer full) (nullable): the [alias@GIRepository.ConstantInfo], - * free it with gi_base_info_unref() when done. + * Returns: (transfer full) (nullable): the [type@GIRepository.ConstantInfo], + * free it with [method@GIRepository.BaseInfo.unref] when done. * Since: 2.80 */ GIConstantInfo * @@ -229,8 +230,8 @@ gi_union_info_get_discriminator (GIUnionInfo *info, * * Obtain the type information for the method named @name. * - * Returns: (transfer full): the [alias@GIRepository.FunctionInfo], free it - * with gi_base_info_unref() when done. + * Returns: (transfer full): the [type@GIRepository.FunctionInfo], free it + * with [method@GIRepository.BaseInfo.unref] when done. * Since: 2.80 */ GIFunctionInfo * @@ -337,3 +338,12 @@ gi_union_info_get_free_function (GIUnionInfo *info) return NULL; } + +void +gi_union_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_UNION; +} diff --git a/girepository/giunresolvedinfo.c b/girepository/giunresolvedinfo.c new file mode 100644 index 000000000..c1b4584ee --- /dev/null +++ b/girepository/giunresolvedinfo.c @@ -0,0 +1,52 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable implementation + * + * Copyright (C) 2005 Matthias Clasen + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#include +#include "gibaseinfo-private.h" +#include "girepository-private.h" +#include "gitypelib-internal.h" +#include "giunresolvedinfo.h" + +/** + * SECTION:giunresolved + * @title: GIUnresolvedInfo + * @short_description: Struct representing an unresolved symbol + * + * GIUnresolvedInfo represents an unresolved symbol. + */ + +void +gi_unresolved_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_UNRESOLVED; +} diff --git a/girepository/giunresolvedinfo.h b/girepository/giunresolvedinfo.h new file mode 100644 index 000000000..b69c85e5b --- /dev/null +++ b/girepository/giunresolvedinfo.h @@ -0,0 +1,43 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * GObject introspection: Callable + * + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#pragma once + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/** + * GI_IS_UNRESOLVED_INFO + * @info: an info structure + * + * Checks if @info is a #GIUnresolvedInfo or derived from it. + */ +#define GI_IS_UNRESOLVED_INFO(info) \ + (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNRESOLVED) + +G_END_DECLS diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index b979ebb33..45587ab53 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -29,6 +29,7 @@ #include #include +#include "gibaseinfo-private.h" #include "girepository-private.h" #include "gitypelib-internal.h" #include "givfuncinfo.h" @@ -39,7 +40,7 @@ * `GIVfuncInfo` represents a virtual function. * * A virtual function is a callable object that belongs to either a - * [alias@GIRepository.ObjectInfo] or a [alias@GIRepository.InterfaceInfo]. + * [type@GIRepository.ObjectInfo] or a [type@GIRepository.InterfaceInfo]. * * Since: 2.80 */ @@ -172,7 +173,7 @@ gi_vfunc_info_get_signal (GIVFuncInfo *info) * * Not all virtuals will have invokers. * - * Returns: (transfer full) (nullable): the [alias@GIRepository.FunctionInfo] or + * Returns: (transfer full) (nullable): the [type@GIRepository.FunctionInfo] or * `NULL`. Free it with gi_base_info_unref() when done. * Since: 2.80 */ @@ -369,3 +370,12 @@ gi_vfunc_info_invoke (GIVFuncInfo *info, FALSE, error); } + +void +gi_vfunc_info_class_init (gpointer g_class, + gpointer class_data) +{ + GIBaseInfoClass *info_class = g_class; + + info_class->info_type = GI_INFO_TYPE_VFUNC; +} diff --git a/girepository/meson.build b/girepository/meson.build index f8ab670b3..e24183bd2 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -45,6 +45,7 @@ girepo_headers = files( 'giarginfo.h', 'gibaseinfo.h', 'gicallableinfo.h', + 'gicallbackinfo.h', 'giconstantinfo.h', 'gienuminfo.h', 'gifieldinfo.h', @@ -60,6 +61,7 @@ girepo_headers = files( 'gitypelib.h', 'gitypes.h', 'giunioninfo.h', + 'giunresolvedinfo.h', 'givfuncinfo.h', ) @@ -142,6 +144,7 @@ girepo_sources = files( 'giarginfo.c', 'gibaseinfo.c', 'gicallableinfo.c', + 'gicallbackinfo.c', 'giconstantinfo.c', 'gienuminfo.c', 'gifieldinfo.c', @@ -158,6 +161,7 @@ girepo_sources = files( 'gitypeinfo.c', 'gitypelib.c', 'giunioninfo.c', + 'giunresolvedinfo.c', 'givfuncinfo.c', ) From f5d13c9cf82a0cba0d5a7ce7e32227e6b833f43a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 17:27:34 +0000 Subject: [PATCH 23/31] gifieldinfo: Port from gtk-doc to gi-docgen Signed-off-by: Philip Withnall --- girepository/gifieldinfo.c | 76 ++++++++++++++++++++++---------------- girepository/gifieldinfo.h | 5 ++- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index a204ddd16..649fb426d 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -34,29 +34,33 @@ #include "gifieldinfo.h" /** - * SECTION:gifieldinfo - * @title: GIFieldInfo - * @short_description: Struct representing a struct or union field + * GIFieldInfo: * - * A GIFieldInfo struct represents a field of a struct, union, or object. + * A `GIFieldInfo` struct represents a field of a struct, union, or object. * - * The GIFieldInfo is fetched by calling gi_struct_info_get_field(), - * gi_union_info_get_field() or gi_object_info_get_field(). + * The `GIFieldInfo` is fetched by calling + * [method@GIRepository.StructInfo.get_field], + * [method@GIRepository.UnionInfo.get_field] or + * [method@GIRepository.ObjectInfo.get_field]. * - * A field has a size, type and a struct offset asssociated and a set of flags, - * which are currently #GI_FIELD_IS_READABLE or #GI_FIELD_IS_WRITABLE. + * A field has a size, type and a struct offset associated and a set of flags, + * which are currently `GI_FIELD_IS_READABLE` or `GI_FIELD_IS_WRITABLE`. * - * See also: #GIStructInfo, #GIUnionInfo, #GIObjectInfo + * See also: [type@GIRepository.StructInfo], [type@GIRepository.UnionInfo], + * [type@GIRepository.ObjectInfo] + * + * Since: 2.80 */ /** * gi_field_info_get_flags: * @info: a #GIFieldInfo * - * Obtain the flags for this #GIFieldInfo. See #GIFieldInfoFlags for possible - * flag values. + * Obtain the flags for this `GIFieldInfo`. See + * [flags@GIRepository.FieldInfoFlags] for possible flag values. * * Returns: the flags + * Since: 2.80 */ GIFieldInfoFlags gi_field_info_get_flags (GIFieldInfo *info) @@ -85,10 +89,11 @@ gi_field_info_get_flags (GIFieldInfo *info) * gi_field_info_get_size: * @info: a #GIFieldInfo * - * Obtain the size in bits of the field member, this is how + * Obtain the size of the field member, in bits. This is how * much space you need to allocate to store the field. * - * Returns: the field size + * Returns: the field size, in bits + * Since: 2.80 */ gint gi_field_info_get_size (GIFieldInfo *info) @@ -108,10 +113,11 @@ gi_field_info_get_size (GIFieldInfo *info) * gi_field_info_get_offset: * @info: a #GIFieldInfo * - * Obtain the offset in bytes of the field member, this is relative + * Obtain the offset of the field member, in bytes. This is relative * to the beginning of the struct or union. * - * Returns: the field offset + * Returns: the field offset, in bytes + * Since: 2.80 */ gint gi_field_info_get_offset (GIFieldInfo *info) @@ -131,10 +137,10 @@ gi_field_info_get_offset (GIFieldInfo *info) * gi_field_info_get_type_info: * @info: a #GIFieldInfo * - * Obtain the type of a field as a #GITypeInfo. + * Obtain the type of a field as a [type@GIRepository.TypeInfo]. * - * Returns: (transfer full): the #GITypeInfo. Free the struct by calling - * gi_base_info_unref() when done. + * Returns: (transfer full): the [type@GIRepository.TypeInfo]. Free the struct + * by calling [method@GIRepository.BaseInfo.unref] when done. */ GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info) @@ -166,14 +172,17 @@ gi_field_info_get_type_info (GIFieldInfo *info) * gi_field_info_get_field: (skip) * @field_info: a #GIFieldInfo * @mem: pointer to a block of memory representing a C structure or union - * @value: a #GIArgument into which to store the value retrieved + * @value: a [type@GIRepository.Argument] into which to store the value retrieved * - * Reads a field identified by a #GIFieldInfo from a C structure or - * union. This only handles fields of simple C types. It will fail - * for a field of a composite type like a nested structure or union - * even if that is actually readable. + * Reads a field identified by a `GIFieldInfo` from a C structure or + * union. * - * Returns: %TRUE if reading the field succeeded, otherwise %FALSE + * This only handles fields of simple C types. It will fail for a field of a + * composite type like a nested structure or union even if that is actually + * readable. + * + * Returns: true if reading the field succeeded, false otherwise + * Since: 2.80 */ gboolean gi_field_info_get_field (GIFieldInfo *field_info, @@ -358,16 +367,19 @@ gi_field_info_get_field (GIFieldInfo *field_info, * gi_field_info_set_field: (skip) * @field_info: a #GIFieldInfo * @mem: pointer to a block of memory representing a C structure or union - * @value: a #GIArgument holding the value to store + * @value: a [type@GIRepository.Argument] holding the value to store * - * Writes a field identified by a #GIFieldInfo to a C structure or - * union. This only handles fields of simple C types. It will fail - * for a field of a composite type like a nested structure or union - * even if that is actually writable. Note also that that it will refuse - * to write fields where memory management would by required. A field - * with a type such as 'char *' must be set with a setter function. + * Writes a field identified by a `GIFieldInfo` to a C structure or + * union. * - * Returns: %TRUE if writing the field succeeded, otherwise %FALSE + * This only handles fields of simple C types. It will fail for a field of a + * composite type like a nested structure or union even if that is actually + * writable. Note also that that it will refuse to write fields where memory + * management would by required. A field with a type such as `char *` must be + * set with a setter function. + * + * Returns: true if writing the field succeeded, false otherwise + * Since: 2.80 */ gboolean gi_field_info_set_field (GIFieldInfo *field_info, diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index 6c5b7e06a..1b807460b 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -33,11 +33,12 @@ G_BEGIN_DECLS /** - * GI_IS_FIELD_INFO + * GI_IS_FIELD_INFO: * @info: an info structure * - * Checks if @info is a #GIFieldInfo. + * Checks if @info is a [class@GIRepository.FieldInfo]. * + * Since: 2.80 */ #define GI_IS_FIELD_INFO(info) \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FIELD) From 0d9b67478468aac7aa48e367a9268b201e210113 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 23 Nov 2023 23:22:55 +0000 Subject: [PATCH 24/31] girepository: Add a gi_repository_new() function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not intended that most people will use this, but it’s going to be quite useful for adding unit tests — we don’t really want the unit tests to share global state (a singleton `GIRepository`) between tests. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/girepository.c | 19 ++++++++++++++++++- girepository/girepository.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index 76ed9ebfa..b0ecaea42 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -184,7 +184,7 @@ init_globals (void) return; if (default_repository == NULL) - default_repository = g_object_new (GI_TYPE_REPOSITORY, NULL); + default_repository = gi_repository_new (); if (typelib_search_path == NULL) { @@ -688,6 +688,23 @@ gi_repository_get_default (void) return get_repository (NULL); } +/** + * gi_repository_new: + * + * Create a new (non-singleton) #GIRepository. + * + * Most callers should use gi_repository_get_default() instead, as a singleton + * repository is more useful in most situations. + * + * Returns: (transfer full): a new #GIRepository + * Since: 2.80 + */ +GIRepository * +gi_repository_new (void) +{ + return g_object_new (GI_TYPE_REPOSITORY, NULL); +} + /** * gi_repository_get_n_infos: * @repository: (allow-none): A #GIRepository or %NULL for the singleton diff --git a/girepository/girepository.h b/girepository/girepository.h index 96ac7194b..21f9d0030 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -103,6 +103,9 @@ GType gi_repository_get_type (void) G_GNUC_CONST; GI_AVAILABLE_IN_ALL GIRepository *gi_repository_get_default (void); +GI_AVAILABLE_IN_ALL +GIRepository *gi_repository_new (void); + GI_AVAILABLE_IN_ALL void gi_repository_prepend_search_path (const char *directory); From 76a70381d4521c2b3222343bb0f0be650f0c743c Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 23 Nov 2023 23:24:53 +0000 Subject: [PATCH 25/31] girepository: Rename meson variables for consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If they’re all named after the actual library name, rather than a contraction of it, that’s easier to remember so they can be easily referenced elsewhere in the build system (such as when adding unit tests). This introduces no functional changes. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/meson.build | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/girepository/meson.build b/girepository/meson.build index e24183bd2..5699ce1a5 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -119,7 +119,7 @@ if cc.get_id() != 'msvc' ]) endif -libgirepo_internals = static_library('girepository-internals', +libgirepository_internals = static_library('girepository-internals', sources: [ 'girmodule.c', 'girnode.c', @@ -133,8 +133,8 @@ libgirepo_internals = static_library('girepository-internals', dependencies: [girepo_gthash_dep, libffi_dep], ) -libgirepo_internals_dep = declare_dependency( - link_with: libgirepo_internals, +libgirepository_internals_dep = declare_dependency( + link_with: libgirepository_internals, dependencies: libffi_dep, include_directories: [girepoinc], ) @@ -175,7 +175,7 @@ if cc.get_id() != 'msvc' ]) endif -libgirepo = shared_library('girepository-2.0', +libgirepository = shared_library('girepository-2.0', sources: girepo_sources + girepo_ffi_sources + [gi_visibility_h], include_directories: [configinc, girepoinc], c_args: gir_c_args, @@ -189,13 +189,13 @@ libgirepo = shared_library('girepository-2.0', libgobject_dep, libgmodule_dep, libgio_dep, - libgirepo_internals_dep, + libgirepository_internals_dep, ], install: true, ) -libgirepo_dep = declare_dependency( - link_with: libgirepo, +libgirepository_dep = declare_dependency( + link_with: libgirepository, dependencies: [libglib_dep, libgobject_dep, libgio_dep, libgmodule_dep], include_directories: [girepoinc], ) @@ -203,7 +203,7 @@ libgirepo_dep = declare_dependency( executable('gi-dump-types', sources: 'gi-dump-types.c', dependencies: [ - libgirepo_dep, + libgirepository_dep, libgiounix_dep, libgiowin32_dep ], @@ -215,7 +215,7 @@ pkgconfig_variables = [ 'typelibdir=${libdir}/girepository-1.0', ] -pkg.generate(libgirepo, +pkg.generate(libgirepository, name: 'girepository', version: glib_version, filebase: 'girepository-2.0', @@ -226,29 +226,29 @@ pkg.generate(libgirepo, ) if enable_gir - libgirepo_gir_sources = [ + libgirepository_gir_sources = [ gi_visibility_h, girepo_headers, girepo_sources, ] - libgirepo_gir_packages = [ 'girepository-2.0' ] - libgirepo_gir_args = [ + libgirepository_gir_packages = [ 'girepository-2.0' ] + libgirepository_gir_args = [ '-DGI_COMPILATION', '--symbol-prefix=gi', '--identifier-prefix=GI', ] - girepository_gir = gnome.generate_gir(libgirepo, - sources: libgirepo_gir_sources, + girepository_gir = gnome.generate_gir(libgirepository, + sources: libgirepository_gir_sources, namespace: 'GIRepository', nsversion: '2.0', identifier_prefix: 'GI', symbol_prefix: 'gi', - export_packages: libgirepo_gir_packages, + export_packages: libgirepository_gir_packages, header: 'girepository/girepository.h', includes: [ glib_gir[0], gmodule_gir[0], gobject_gir[0], gio_gir[0] ], install: true, dependencies: [ libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep ], - extra_args: gir_args + libgirepo_gir_args, + extra_args: gir_args + libgirepository_gir_args, ) endif From 78c94d81ed506bc59e747f5eb98cb8312f2ac2f0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 28 Nov 2023 18:00:35 +0000 Subject: [PATCH 26/31] ci: Build with introspection enabled In most CI builds. (Not all of them, though, so we can also test the build works with it disabled.) This is needed for the upcoming libgirepository tests, as they need some GIR files to test against. Signed-off-by: Philip Withnall Helps: #3155 --- .gitlab-ci.yml | 11 ++++++++--- .gitlab-ci/debian-stable.Dockerfile | 2 ++ .gitlab-ci/fedora.Dockerfile | 2 ++ .gitlab-ci/mingw.Dockerfile | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ad5ee8254..6101ffb48 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,11 +11,11 @@ cache: - _ccache/ variables: - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v24" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v25" COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v7" - DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v18" + DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v19" ALPINE_IMAGE: "registry.gitlab.gnome.org/gnome/glib/alpine:v3" - MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v14" + MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v15" MESON_TEST_TIMEOUT_MULTIPLIER: 4 G_MESSAGES_DEBUG: all MESON_COMMON_OPTIONS: "--buildtype debug --wrap-mode=nodownload --fatal-meson-warnings" @@ -120,6 +120,7 @@ fedora-x86_64: -Ddtrace=true -Dinstalled_tests=true -Ddocumentation=true + -Dintrospection=enabled _build - meson compile -C _build - mkdir -p _coverage @@ -294,6 +295,7 @@ G_DISABLE_ASSERT: -Ddtrace=true -Dinstalled_tests=true -Dglib_assert=false + -Dintrospection=enabled _build - meson compile -C _build - bash -x ./.gitlab-ci/run-tests.sh @@ -325,6 +327,7 @@ valgrind: -Dsystemtap=true -Ddtrace=true -Dinstalled_tests=true + -Dintrospection=enabled _build - meson compile -C _build # Valgrind doesn’t work when the soft FD limit is set too high @@ -672,6 +675,7 @@ scan-build: -Dsystemtap=true -Ddtrace=true -Dinstalled_tests=true + -Dintrospection=enabled _scan_build - ninja -C _scan_build scan-build artifacts: @@ -701,6 +705,7 @@ scan-build: -Dsystemtap=true -Ddtrace=true -Dinstalled_tests=true + -Dintrospection=enabled _coverity_build - $HOME/cov-analysis-linux64-*/bin/cov-build --dir cov-int meson compile -C _coverity_build - tar cfz cov-int.tar.gz cov-int diff --git a/.gitlab-ci/debian-stable.Dockerfile b/.gitlab-ci/debian-stable.Dockerfile index a3b695073..4bcee4e2c 100644 --- a/.gitlab-ci/debian-stable.Dockerfile +++ b/.gitlab-ci/debian-stable.Dockerfile @@ -19,6 +19,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \ gi-docgen \ git \ libc6-dev \ + gobject-introspection \ gtk-doc-tools \ itstool \ lcov \ @@ -26,6 +27,7 @@ RUN apt-get update -qq && apt-get install --no-install-recommends -qq -y \ libdbus-1-dev \ libelf-dev \ libffi-dev \ + libgirepository1.0-dev \ libmount-dev \ libpcre2-dev \ libselinux1-dev \ diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index 9ca80f2d5..e73964064 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -35,6 +35,8 @@ RUN dnf -y update \ glibc-langpack-th \ glibc-langpack-tr \ "gnome-desktop-testing >= 2018.1" \ + gobject-introspection \ + gobject-introspection-devel \ gtk-doc \ itstool \ lcov \ diff --git a/.gitlab-ci/mingw.Dockerfile b/.gitlab-ci/mingw.Dockerfile index 712b23abe..d688a35a1 100644 --- a/.gitlab-ci/mingw.Dockerfile +++ b/.gitlab-ci/mingw.Dockerfile @@ -1,4 +1,4 @@ -FROM registry.gitlab.gnome.org/gnome/glib/fedora:v24 +FROM registry.gitlab.gnome.org/gnome/glib/fedora:v25 USER root From e699037fef5fbd9ddbb22446f16f07154b706163 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 23 Nov 2023 23:20:21 +0000 Subject: [PATCH 27/31] girepository: Add a couple of very simple unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the moment, this is enough to roughly verify that the port to `GTypeInstance` has not massively broken things. It’s not anywhere near sufficient to qualify as a proper test suite though. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/meson.build | 4 ++ girepository/tests/meson.build | 85 +++++++++++++++++++++++ girepository/tests/repository.c | 117 ++++++++++++++++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 girepository/tests/meson.build create mode 100644 girepository/tests/repository.c diff --git a/girepository/meson.build b/girepository/meson.build index 5699ce1a5..42eddf6df 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -252,3 +252,7 @@ if enable_gir extra_args: gir_args + libgirepository_gir_args, ) endif + +if build_tests + subdir('tests') +endif \ No newline at end of file diff --git a/girepository/tests/meson.build b/girepository/tests/meson.build new file mode 100644 index 000000000..d9c25380e --- /dev/null +++ b/girepository/tests/meson.build @@ -0,0 +1,85 @@ +girepository_tests = {} + +# Some GIR files are needed to test against +if enable_gir + girepository_tests += { + 'repository' : { + 'depends': [glib_gir, gobject_gir], + }, + } +endif + +test_env = environment() +test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) +test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) + +test_deps = [libm, thread_dep, libgirepository_dep] +test_cargs = ['-DG_LOG_DOMAIN="GIRepository"', '-UG_DISABLE_ASSERT'] +test_cpp_args = test_cargs + +foreach test_name, extra_args : girepository_tests + source = extra_args.get('source', test_name + '.c') + install = installed_tests_enabled and extra_args.get('install', true) + installed_tests_env = extra_args.get('installed_tests_env', {}) + + if install + test_conf = configuration_data() + test_conf.set('installed_tests_dir', installed_tests_execdir) + test_conf.set('program', test_name) + test_env_override = '' + if installed_tests_env != {} + envs = [] + foreach var, value : installed_tests_env + envs += '@0@=@1@'.format(var, value) + endforeach + test_env_override = '@0@ @1@ '.format(env_program.full_path(), ' '.join(envs)) + endif + test_conf.set('env', test_env_override) + configure_file( + input: installed_tests_template_tap, + output: test_name + '.test', + install_dir: installed_tests_metadir, + install_tag: 'tests', + configuration: test_conf + ) + endif + + exe = executable(test_name, source, + c_args: test_cargs + extra_args.get('c_args', []), + cpp_args: test_cpp_args + extra_args.get('cpp_args', []), + link_args: extra_args.get('link_args', []), + override_options: extra_args.get('override_options', []), + dependencies: test_deps + extra_args.get('dependencies', []), + link_with: extra_args.get('link_with', []), + install_dir: installed_tests_execdir, + install_tag: 'tests', + install: install, + ) + + depends = [extra_args.get('depends', [])] + suite = ['girepository', 'core'] + extra_args.get('suite', []) + timeout = suite.contains('slow') ? test_timeout_slow : test_timeout + + if extra_args.get('can_fail', false) + suite += 'failing' + endif + + foreach program : extra_args.get('extra_programs', []) + depends += test_extra_programs_targets[program] + endforeach + + local_test_env = test_env + foreach var, value : extra_args.get('env', {}) + local_test_env.append(var, value) + endforeach + + test(test_name, exe, + args: extra_args.get('args', []), + protocol: extra_args.get('protocol', test_protocol), + depends: depends, + env: local_test_env, + timeout: timeout, + suite: suite, + should_fail: extra_args.get('should_fail', false), + ) +endforeach \ No newline at end of file diff --git a/girepository/tests/repository.c b/girepository/tests/repository.c new file mode 100644 index 000000000..90b850a22 --- /dev/null +++ b/girepository/tests/repository.c @@ -0,0 +1,117 @@ +/* + * Copyright 2023 GNOME Foundation, Inc. + * + * SPDX-License-Identifier: LGPL-2.1-or-later + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Philip Withnall + */ + +#include "glib.h" +#include "girepository.h" + +static void +test_repository_basic (void) +{ + GIRepository *repository; + char *gobject_typelib_dir = NULL; + GSList *search_path; + GITypelib *typelib = NULL; + char **namespaces = NULL; + const char *expected_namespaces[] = { "GLib", NULL }; + GError *local_error = NULL; + + g_test_summary ("Test basic opening of a repository and requiring a typelib"); + + gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL); + g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir); + gi_repository_prepend_search_path (gobject_typelib_dir); + + repository = gi_repository_new (); + g_assert_nonnull (repository); + + search_path = gi_repository_get_search_path (); + g_assert_nonnull (search_path); + g_assert_cmpstr (search_path->data, ==, gobject_typelib_dir); + + typelib = gi_repository_require (repository, "GLib", "2.0", 0, &local_error); + g_assert_no_error (local_error); + g_assert_nonnull (typelib); + + namespaces = gi_repository_get_loaded_namespaces (repository); + g_assert_cmpstrv (namespaces, expected_namespaces); + g_strfreev (namespaces); + + g_free (gobject_typelib_dir); + g_clear_object (&repository); +} + +static void +test_repository_info (void) +{ + GIRepository *repository; + char *gobject_typelib_dir = NULL; + GITypelib *typelib = NULL; + GIObjectInfo *object_info = NULL; + GISignalInfo *signal_info = NULL; + GError *local_error = NULL; + + g_test_summary ("Test retrieving some basic info blobs from a typelib"); + + gobject_typelib_dir = g_test_build_filename (G_TEST_BUILT, "..", "..", "gobject", NULL); + g_test_message ("Using GI_TYPELIB_DIR = %s", gobject_typelib_dir); + gi_repository_prepend_search_path (gobject_typelib_dir); + g_free (gobject_typelib_dir); + + repository = gi_repository_new (); + g_assert_nonnull (repository); + + typelib = gi_repository_require (repository, "GObject", "2.0", 0, &local_error); + g_assert_no_error (local_error); + g_assert_nonnull (typelib); + + object_info = (GIObjectInfo *) gi_repository_find_by_name (repository, "GObject", "Object"); + g_assert_nonnull (object_info); + + g_assert_cmpint (gi_base_info_get_info_type ((GIBaseInfo *) object_info), ==, GI_INFO_TYPE_OBJECT); + g_assert_cmpstr (gi_base_info_get_name ((GIBaseInfo *) object_info), ==, "Object"); + g_assert_cmpstr (gi_base_info_get_namespace ((GIBaseInfo *) object_info), ==, "GObject"); + + signal_info = gi_object_info_find_signal (object_info, "notify"); + g_assert_nonnull (signal_info); + + g_assert_cmpint (gi_signal_info_get_flags (signal_info), ==, + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS | G_SIGNAL_ACTION); + + gi_base_info_unref ((GIBaseInfo *) signal_info); + gi_base_info_unref ((GIBaseInfo *) object_info); + g_clear_object (&repository); +} + +int +main (int argc, + char *argv[]) +{ + /* Isolate from the system typelibs and GIRs. */ + g_setenv ("GI_TYPELIB_PATH", "/dev/null", TRUE); + g_setenv ("GI_GIR_PATH", "/dev/null", TRUE); + + g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL); + + g_test_add_func ("/repository/basic", test_repository_basic); + g_test_add_func ("/repository/info", test_repository_info); + + return g_test_run (); +} From 95693f78fc992ec7f995b8b36fc3721cd85c2f3e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 23 Nov 2023 23:22:01 +0000 Subject: [PATCH 28/31] girepository: Fix a minor string leak Caught by the new unit tests. Signed-off-by: Philip Withnall --- girepository/girepository.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index b0ecaea42..1acfff26d 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -129,7 +129,7 @@ gi_repository_init (GIRepository *repository) repository->priv = gi_repository_get_instance_private (repository); repository->priv->typelibs = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) NULL, + (GDestroyNotify) g_free, (GDestroyNotify) gi_typelib_free); repository->priv->lazy_typelibs = g_hash_table_new_full (g_str_hash, g_str_equal, @@ -441,7 +441,9 @@ register_internal (GIRepository *repository, else key = build_typelib_key (namespace, source); - g_hash_table_insert (repository->priv->typelibs, key, (void *)typelib); + g_hash_table_insert (repository->priv->typelibs, + g_steal_pointer (&key), + (void *)typelib); } /* These types might be resolved now, clear the cache */ From 6876f21aee6190f3208d9f070bb1dcec49af498f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 9 Nov 2023 00:35:21 +0000 Subject: [PATCH 29/31] girepository: Update docs for GITypeInfo for gi-docgen Move the SECTION into the struct docs, update the documentation comment syntax, and add `Since: 2.80` everywhere. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gitypeinfo.c | 143 ++++++++++++++++++++++---------------- girepository/gitypeinfo.h | 10 +-- 2 files changed, 88 insertions(+), 65 deletions(-) diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index cf64ae78e..71605ca65 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -33,21 +33,25 @@ #include "gitypeinfo.h" /** - * SECTION:gitypeinfo - * @title: GITypeInfo - * @short_description: Struct representing a type + * GITypeInfo: * - * GITypeInfo represents a type. + * `GITypeInfo` represents a type, including information about direction and + * transfer. * - * You can retrieve a type info from an argument (see #GIArgInfo), a - * functions return value (see #GIFunctionInfo), a field (see - * #GIFieldInfo), a property (see #GIPropertyInfo), a constant - * (see #GIConstantInfo) or for a union discriminator (see #GIUnionInfo). + * You can retrieve a type info from an argument (see + * [class@GIRepository.ArgInfo]), a function’s return value (see + * [class@GIRepository.FunctionInfo]), a field (see + * [class@GIRepository.FieldInfo]), a property (see + * [class@GIRepository.PropertyInfo]), a constant (see + * [class@GIRepository.ConstantInfo]) or for a union discriminator (see + * [class@GIRepository.UnionInfo]). * * A type can either be a of a basic type which is a standard C primitive * type or an interface type. For interface types you need to call - * gi_type_info_get_interface() to get a reference to the base info for that - * interface. + * [method@GIRepository.TypeInfo.get_interface] to get a reference to the base + * info for that interface. + * + * Since: 2.80 */ /** @@ -56,12 +60,13 @@ * * Obtain if the type is passed as a reference. * - * Note that the types of %GI_DIRECTION_OUT and %GI_DIRECTION_INOUT parameters + * Note that the types of `GI_DIRECTION_OUT` and `GI_DIRECTION_INOUT` parameters * will only be pointers if the underlying type being transferred is a pointer * (i.e. only if the type of the C function’s formal parameter is a pointer to a * pointer). * - * Returns: %TRUE if it is a pointer + * Returns: true if it is a pointer + * Since: 2.80 */ gboolean gi_type_info_is_pointer (GITypeInfo *info) @@ -88,10 +93,12 @@ gi_type_info_is_pointer (GITypeInfo *info) * gi_type_info_get_tag: * @info: a #GITypeInfo * - * Obtain the type tag for the type. See #GITypeTag for a list - * of type tags. + * Obtain the type tag for the type. + * + * See [type@GIRepository.TypeTag] for a list of type tags. * * Returns: the type tag + * Since: 2.80 */ GITypeTag gi_type_info_get_tag (GITypeInfo *info) @@ -124,6 +131,7 @@ gi_type_info_get_tag (GITypeInfo *info) * Obtain the parameter type @n, or `-1` if the type is not an array. * * Returns: (transfer full) (nullable): the param type info + * Since: 2.80 */ GITypeInfo * gi_type_info_get_param_type (GITypeInfo *info, @@ -163,13 +171,15 @@ gi_type_info_get_param_type (GITypeInfo *info, * gi_type_info_get_interface: * @info: a #GITypeInfo * - * For types which have #GI_TYPE_TAG_INTERFACE such as GObjects and boxed values, - * this function returns full information about the referenced type. You can then - * inspect the type of the returned #GIBaseInfo to further query whether it is - * a concrete GObject, a GInterface, a structure, etc. using gi_base_info_get_type(). + * For types which have `GI_TYPE_TAG_INTERFACE` such as [class@GObject.Object]s + * and boxed values, this function returns full information about the referenced + * type. You can then inspect the type of the returned + * [class@GIRepository.BaseInfo] to further query whether it is a concrete + * [class@GObject.Object], an interface, a structure, etc., using + * [method@GIRepository.BaseInfo.get_info_type]. * - * Returns: (transfer full) (nullable): the #GIBaseInfo, or %NULL. Free it with - * gi_base_info_unref() when done. + * Returns: (transfer full) (nullable): the [class@GIRepository.BaseInfo], or + * `NULL`. Free it with gi_base_info_unref() when done. */ GIBaseInfo * gi_type_info_get_interface (GITypeInfo *info) @@ -220,9 +230,10 @@ gi_type_info_get_interface (GITypeInfo *info) * @info: a #GITypeInfo * * Obtain the position of the argument which gives the array length of the type. - * The type tag must be a #GI_TYPE_TAG_ARRAY or -1 will be returned. + * The type tag must be a `GI_TYPE_TAG_ARRAY` or `-1` will be returned. * - * Returns: the array length, or -1 if the type is not an array + * Returns: the array length, or `-1` if the type is not an array + * Since: 2.80 */ gint gi_type_info_get_array_length (GITypeInfo *info) @@ -254,9 +265,10 @@ gi_type_info_get_array_length (GITypeInfo *info) * @info: a #GITypeInfo * * Obtain the fixed array size of the type. The type tag must be a - * #GI_TYPE_TAG_ARRAY or -1 will be returned. + * `GI_TYPE_TAG_ARRAY` or `-1` will be returned. * - * Returns: the size or -1 if it's not an array + * Returns: the size or `-1` if the type is not an array + * Since: 2.80 */ gint gi_type_info_get_array_fixed_size (GITypeInfo *info) @@ -287,10 +299,11 @@ gi_type_info_get_array_fixed_size (GITypeInfo *info) * gi_type_info_is_zero_terminated: * @info: a #GITypeInfo * - * Obtain if the last element of the array is %NULL. The type tag must be a - * #GI_TYPE_TAG_ARRAY or %FALSE will be returned. + * Obtain if the last element of the array is `NULL`. The type tag must be a + * `GI_TYPE_TAG_ARRAY` or false will be returned. * - * Returns: %TRUE if zero terminated + * Returns: true if zero terminated + * Since: 2.80 */ gboolean gi_type_info_is_zero_terminated (GITypeInfo *info) @@ -318,11 +331,13 @@ gi_type_info_is_zero_terminated (GITypeInfo *info) * gi_type_info_get_array_type: * @info: a #GITypeInfo * - * Obtain the array type for this type. See #GIArrayType for a list of - * possible values. If the type tag of this type is not array, -1 will be - * returned. + * Obtain the array type for this type. * - * Returns: the array type or -1 + * See [enum@GIRepository.ArrayType] for a list of possible values. If the type + * tag of this type is not array, `-1` will be returned. + * + * Returns: the array type or `-1` + * Since: 2.80 */ GIArrayType gi_type_info_get_array_type (GITypeInfo *info) @@ -352,10 +367,10 @@ gi_type_info_get_array_type (GITypeInfo *info) * * Obtain the type tag corresponding to the underlying storage type in C for * the type. - * See #GITypeTag for a list of type tags. + * + * See [type@GIRepository.TypeTag] for a list of type tags. * * Returns: the type tag - * * Since: 2.80 */ GITypeTag @@ -377,18 +392,20 @@ gi_type_info_get_storage_type (GITypeInfo *info) /** * gi_type_tag_argument_from_hash_pointer: - * @storage_type: a #GITypeTag obtained from gi_type_info_get_storage_type() - * @hash_pointer: A pointer, such as a #GHashTable data pointer - * @arg: A #GIArgument to fill in + * @storage_type: a [type@GIRepository.TypeTag] obtained from + * [method@GIRepository.TypeInfo.get_storage_type] + * @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer + * @arg: a [type@GIRepository.Argument] to fill in + * + * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and + * [type@GLib.HashTable], all store data pointers. * - * GLib data structures, such as #GList, #GSList, and #GHashTable, all store - * data pointers. * In the case where the list or hash table is storing single types rather than * structs, these data pointers may have values stuffed into them via macros - * such as %GPOINTER_TO_INT. + * such as `GPOINTER_TO_INT`. * * Use this function to ensure that all values are correctly extracted from - * stuffed pointers, regardless of the machine's architecture or endianness. + * stuffed pointers, regardless of the machine’s architecture or endianness. * * This function fills in the appropriate field of @arg with the value extracted * from @hash_pointer, depending on @storage_type. @@ -451,17 +468,18 @@ gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, /** * gi_type_info_argument_from_hash_pointer: * @info: a #GITypeInfo - * @hash_pointer: A pointer, such as a #GHashTable data pointer - * @arg: A #GIArgument to fill in + * @hash_pointer: a pointer, such as a [struct@GLib.HashTable] data pointer + * @arg: a [type@GIRepository.Argument] to fill in + * + * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and + * [type@GLib.HashTable], all store data pointers. * - * GLib data structures, such as #GList, #GSList, and #GHashTable, all store - * data pointers. * In the case where the list or hash table is storing single types rather than * structs, these data pointers may have values stuffed into them via macros - * such as %GPOINTER_TO_INT. + * such as `GPOINTER_TO_INT`. * * Use this function to ensure that all values are correctly extracted from - * stuffed pointers, regardless of the machine's architecture or endianness. + * stuffed pointers, regardless of the machine’s architecture or endianness. * * This function fills in the appropriate field of @arg with the value extracted * from @hash_pointer, depending on the storage type of @info. @@ -480,23 +498,25 @@ gi_type_info_argument_from_hash_pointer (GITypeInfo *info, /** * gi_type_tag_hash_pointer_from_argument: - * @storage_type: a #GITypeTag obtained from gi_get_storage_type() - * @arg: A #GIArgument with the value to stuff into a pointer + * @storage_type: a [type@GIRepository.TypeTag] obtained from + * [method@GIRepository.TypeInfo.get_storage_type] + * @arg: A [type@GIRepository.Argument] with the value to stuff into a pointer + * + * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and + * [type@GLib.HashTable], all store data pointers. * - * GLib data structures, such as #GList, #GSList, and #GHashTable, all store - * data pointers. * In the case where the list or hash table is storing single types rather than * structs, these data pointers may have values stuffed into them via macros - * such as %GPOINTER_TO_INT. + * such as `GPOINTER_TO_INT`. * * Use this function to ensure that all values are correctly stuffed into - * pointers, regardless of the machine's architecture or endianness. + * pointers, regardless of the machine’s architecture or endianness. * * This function returns a pointer stuffed with the appropriate field of @arg, * depending on @storage_type. * - * Returns: A stuffed pointer, that can be stored in a #GHashTable, for example - * + * Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable], + * for example * Since: 2.80 */ gpointer @@ -545,22 +565,23 @@ gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, /** * gi_type_info_hash_pointer_from_argument: * @info: a #GITypeInfo - * @arg: A #GIArgument with the value to stuff into a pointer + * @arg: A [struct@GIRepository.Argument] with the value to stuff into a pointer + * + * GLib data structures, such as [type@GLib.List], [type@GLib.SList], and + * [type@GLib.HashTable], all store data pointers. * - * GLib data structures, such as #GList, #GSList, and #GHashTable, all store - * data pointers. * In the case where the list or hash table is storing single types rather than * structs, these data pointers may have values stuffed into them via macros - * such as %GPOINTER_TO_INT. + * such as `GPOINTER_TO_INT`. * * Use this function to ensure that all values are correctly stuffed into - * pointers, regardless of the machine's architecture or endianness. + * pointers, regardless of the machine’s architecture or endianness. * * This function returns a pointer stuffed with the appropriate field of @arg, * depending on the storage type of @info. * - * Returns: A stuffed pointer, that can be stored in a #GHashTable, for example - * + * Returns: A stuffed pointer, that can be stored in a [struct@GLib.HashTable], + * for example * Since: 2.80 */ gpointer diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 54cd177f4..e92e82837 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -33,16 +33,18 @@ G_BEGIN_DECLS /** - * GI_IS_TYPE_INFO + * GI_IS_TYPE_INFO: * @info: an info structure * - * Checks if @info is a #GITypeInfo. + * Checks if @info is a [alias@GIRepository.TypeInfo]. + * + * Since: 2.80 */ #define GI_IS_TYPE_INFO(info) \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_TYPE) /** - * GI_TYPE_TAG_IS_BASIC + * GI_TYPE_TAG_IS_BASIC: * @tag: a type tag * * Checks if @tag is a basic type. @@ -66,7 +68,7 @@ G_BEGIN_DECLS * @tag: a type tag * * Checks if @tag is a container type. That is, a type which may have a nonnull - * return from gi_type_info_get_param_type(). + * return from [method@GIRepository.TypeInfo.get_param_type]. * * Since: 2.80 */ From 4ccbc1b9d796b347c9e7b671fc82126d12f4728e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 12 Dec 2023 16:23:03 +0000 Subject: [PATCH 30/31] girepository: Rename gi_base_info_gtype_get_type() to just get_type() This makes it more conventional for how `GType` code is normally written. This introduces no functional changes, but it is an API break. Signed-off-by: Philip Withnall Helps: #3155 --- girepository/gibaseinfo.c | 2 +- girepository/gibaseinfo.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 1ed1ae162..f89b4d15e 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -145,7 +145,7 @@ gi_base_info_init (GIBaseInfo *self) } GType -gi_base_info_gtype_get_type (void) +gi_base_info_get_type (void) { static GType base_info_type = 0; diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index 182c6bc08..96f6fa694 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -48,11 +48,11 @@ typedef struct { gpointer data4; } GIAttributeIter; -#define GI_TYPE_BASE_INFO (gi_base_info_gtype_get_type ()) +#define GI_TYPE_BASE_INFO (gi_base_info_get_type ()) GI_AVAILABLE_IN_ALL -GType gi_base_info_gtype_get_type (void) G_GNUC_CONST; +GType gi_base_info_get_type (void) G_GNUC_CONST; GI_AVAILABLE_IN_ALL GIBaseInfo * gi_base_info_ref (GIBaseInfo *info); From 35ec6b6387819b8efc64fb882440f5ee8ad84a05 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 12 Dec 2023 16:39:51 +0000 Subject: [PATCH 31/31] ci: Temporarily only run the FreeBSD 13 CI on a schedule Rather than on every commit, because the CI runner is currently broken: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3740#note_1935427. Signed-off-by: Philip Withnall --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6101ffb48..707d02b25 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -550,7 +550,10 @@ freebsd-12-x86_64: - "_build/meson-logs" freebsd-13-x86_64: - extends: .only-origin + # FIXME: Temporarily only run the FreeBSD 13 CI on a schedule, rather than on + # every commit to origin, because it’s broken: + # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3740#note_1935427 + extends: .only-schedules stage: build tags: - freebsd-13