From 54f156bd63484582a07236c7a803dec658fd189b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 8 Feb 2024 11:40:10 +0000 Subject: [PATCH 1/4] gitypelib: Explicitly convert from GITypelibBlobType to GIInfoType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When creating `GIBaseInfo` instances from binary blobs, so far the code has used an undocumented implicit conversion from one enum type to the other. That’s a bit nasty, as it means the two enum types need to be kept in sync (without that need being documented). Introduce an explicit conversion function to make things more explicit. Currently it does nothing, but in an upcoming commit it will be used to deprecate a blob type. Signed-off-by: Philip Withnall Helps: #3245 --- girepository/gibaseinfo.c | 3 ++- girepository/girepository.c | 8 ++++---- girepository/gitypelib-internal.h | 3 +++ girepository/gitypelib.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 79f6a16e4..0ba672474 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -475,7 +475,8 @@ gi_info_from_entry (GIRepository *repository, DirEntry *entry = gi_typelib_get_dir_entry (typelib, index); if (entry->local) - result = gi_info_new_full (entry->blob_type, repository, NULL, typelib, entry->offset); + result = gi_info_new_full (gi_typelib_blob_type_to_info_type (entry->blob_type), + repository, NULL, typelib, entry->offset); else { const char *namespace = gi_typelib_get_string (typelib, entry->offset); diff --git a/girepository/girepository.c b/girepository/girepository.c index 0365be812..26f802812 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -865,7 +865,7 @@ gi_repository_get_info (GIRepository *repository, entry = gi_typelib_get_dir_entry (typelib, idx + 1); g_return_val_if_fail (entry != NULL, NULL); - return gi_info_new_full (entry->blob_type, + return gi_info_new_full (gi_typelib_blob_type_to_info_type (entry->blob_type), repository, NULL, typelib, entry->offset); } @@ -966,7 +966,7 @@ gi_repository_find_by_gtype (GIRepository *repository, if (entry != NULL) { - cached = gi_info_new_full (entry->blob_type, + cached = gi_info_new_full (gi_typelib_blob_type_to_info_type (entry->blob_type), repository, NULL, data.result_typelib, entry->offset); @@ -1015,7 +1015,7 @@ gi_repository_find_by_name (GIRepository *repository, entry = gi_typelib_get_dir_entry_by_name (typelib, name); if (entry == NULL) return NULL; - return gi_info_new_full (entry->blob_type, + return gi_info_new_full (gi_typelib_blob_type_to_info_type (entry->blob_type), repository, NULL, typelib, entry->offset); } @@ -1086,7 +1086,7 @@ gi_repository_find_by_error_domain (GIRepository *repository, if (data.result != NULL) { - cached = (GIEnumInfo *) gi_info_new_full (data.result->blob_type, + cached = (GIEnumInfo *) gi_info_new_full (gi_typelib_blob_type_to_info_type (data.result->blob_type), repository, NULL, data.result_typelib, data.result->offset); diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index f7b928fe3..8df65fb5b 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -27,6 +27,7 @@ #include #include "girepository.h" +#include "girepository-private.h" G_BEGIN_DECLS @@ -194,6 +195,8 @@ typedef enum { BLOB_TYPE_UNION } GITypelibBlobType; +GIInfoType gi_typelib_blob_type_to_info_type (GITypelibBlobType blob_type); + #if defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 3c88a79e6..f4a9c2b21 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -43,6 +43,16 @@ G_DEFINE_BOXED_TYPE (GITypelib, gi_typelib, gi_typelib_ref, gi_typelib_unref) +GIInfoType +gi_typelib_blob_type_to_info_type (GITypelibBlobType blob_type) +{ + switch (blob_type) + { + default: + return (GIInfoType) blob_type; + } +} + typedef struct { GITypelib *typelib; GSList *context_stack; From 0fd99a9f161245c6e12d3feb87cdfe5bb4c1fce5 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 8 Feb 2024 11:44:17 +0000 Subject: [PATCH 2/4] gibaseinfo: Stop building GIBoxedInfo instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead, add a method on `GIRegisteredTypeInfo` which indicates whether the registered type is a boxed type. This will return true for `GIStructInfo` and `GIUnionInfo` instances which are boxed (not all structs and unions are). This makes `GIBoxedInfo` redundant, and it’ll be dropped in a following commit. --- There are several different things which typelibs need to be able to represent: 1. Plain old datatype (POD) structs 2. POD unions 3. Structs with a copy func and/or free func 4. Unions with a copy func and/or free func 5. Structs which are the ‘GType struct’ for an object or interface (i.e. the class or instance or interface struct) 6. Structs with a copy func and free func *and* boxed GType 7. Unions with a copy func and free func *and* boxed GType 8. Boxed GTypes which represent something other than a struct or union So there’s a lot going on here. In commit e28078c70cbf4a57c7dbd39626f43f9bd2674145, a lot of this was reworked, and support was added for boxed unions and boxed ‘others’ (the last item on the list above). Since then, support for boxed types other than structs seems to have atrophied a bit, and the whole lot has got a bit confusing. It was perhaps less confusing when all the `GIBaseInfo` subclasses were actually aliases of each other, but now they have subtype relationships, the position of `GIBoxedInfo` in that type hierarchy has become unclear. How is it related to `GIStructInfo`, `GIUnionInfo` and `GIRegisteredTypeInfo`? Since a boxed type is necessarily a `GIRegisteredTypeInfo`, and the methods of `GIRegisteredTypeInfo` are all written to allow a `GType` to be optional, so that `GIStructInfo` and `GIUnionInfo` can safely derive from it and still be used to represent plain old datatypes without `GType`s, it makes sense to add a method to `GIRegisteredTypeInfo` to indicate that the registered type is derived from `G_TYPE_BOXED`. Accordingly, the things above are now represented in libgirepository’s type system as: 1. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no `GType` info 2. `GIUnionInfo` instance similarly 3. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no `GType` info, `gi_struct_info_get_{copy,free}_function_name()` return non-`NULL` values 4. `GIUnionInfo` instance similarly 5. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return no `GType` info, `gi_struct_info_is_gtype_struct()` returns true 6. `GIStructInfo` instance, `GIRegisteredTypeInfo` methods return valid `GType` information, `gi_registered_type_info_is_boxed()` returns true, `gi_struct_info_get_{copy,free}_function_name()` return `NULL` values (because the copy/free functions are hidden inside the boxed type registration at runtime) 7. `GIUnionInfo` instance similarly 8. Not representable, but could be represented in future by re-adding a `GIBoxedInfo` type which derives from `GIRegisteredTypeInfo` and is used solely for boxed ‘other’ types, *not* boxed structs or unions Signed-off-by: Philip Withnall Fixes: #3245 --- girepository/giregisteredtypeinfo.c | 64 ++++++++++ girepository/giregisteredtypeinfo.h | 3 + girepository/girwriter.c | 3 +- girepository/gitypelib.c | 8 ++ girepository/tests/meson.build | 3 + girepository/tests/registered-type-info.c | 137 ++++++++++++++++++++++ girepository/tests/repository.c | 16 --- girepository/tests/struct-info.c | 16 +++ 8 files changed, 233 insertions(+), 17 deletions(-) create mode 100644 girepository/tests/registered-type-info.c diff --git a/girepository/giregisteredtypeinfo.c b/girepository/giregisteredtypeinfo.c index cb20a31b0..4312cbac2 100644 --- a/girepository/giregisteredtypeinfo.c +++ b/girepository/giregisteredtypeinfo.c @@ -50,6 +50,13 @@ * Most users want to call [method@GIRepository.RegisteredTypeInfo.get_g_type] * and don’t worry about the rest of the details. * + * If the registered type is a subtype of `G_TYPE_BOXED`, + * [method@GIRepository.RegisteredTypeInfo.is_boxed] will return true, and + * [method@GIRepository.RegisteredTypeInfo.get_type_name] is guaranteed to + * return a non-`NULL` value. This is relevant for the + * [class@GIRepository.StructInfo] and [class@GIRepository.UnionInfo] + * subclasses. + * * Since: 2.80 */ @@ -155,6 +162,63 @@ gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info) return (* get_type_func) (); } +/** + * gi_registered_type_info_is_boxed: + * @info: a #GIRegisteredTypeInfo + * + * Get whether the registered type is a boxed type. + * + * A boxed type is a subtype of the fundamental `G_TYPE_BOXED` type. + * It’s a type which has registered a [type@GObject.Type], and which has + * associated copy and free functions. + * + * Most boxed types are `struct`s; some are `union`s; and it’s possible for a + * boxed type to be neither, but that is currently unsupported by + * libgirepository. It’s also possible for a `struct` or `union` to have + * associated copy and/or free functions *without* being a boxed type, by virtue + * of not having registered a [type@GObject.Type]. + * + * This function will return false for [type@GObject.Type]s which are not boxed, + * such as classes or interfaces. It will also return false for the `struct`s + * associated with a class or interface, which return true from + * [method@GIRepository.StructInfo.is_gtype_struct]. + * + * Returns: true if @info is a boxed type + * Since: 2.80 + */ +gboolean +gi_registered_type_info_is_boxed (GIRegisteredTypeInfo *info) +{ + GIBaseInfo *base_info = GI_BASE_INFO (info); + const RegisteredTypeBlob *blob; + + g_return_val_if_fail (GI_IS_REGISTERED_TYPE_INFO (info), G_TYPE_INVALID); + + blob = (const RegisteredTypeBlob *) &base_info->typelib->data[base_info->offset]; + + if (blob->blob_type == BLOB_TYPE_BOXED) + { + return TRUE; + } + else if (blob->blob_type == BLOB_TYPE_STRUCT) + { + const StructBlob *struct_blob = (const StructBlob *) &base_info->typelib->data[base_info->offset]; + + return !struct_blob->unregistered; + } + else if (blob->blob_type == BLOB_TYPE_UNION) + { + const UnionBlob *union_blob = (const UnionBlob *) &base_info->typelib->data[base_info->offset]; + + return !union_blob->unregistered; + } + + /* We don’t currently support boxed ‘other’ types (boxed types which aren’t + * a struct or union. */ + + return FALSE; +} + void gi_registered_type_info_class_init (gpointer g_class, gpointer class_data) diff --git a/girepository/giregisteredtypeinfo.h b/girepository/giregisteredtypeinfo.h index 2745fef79..a6fe2ddb2 100644 --- a/girepository/giregisteredtypeinfo.h +++ b/girepository/giregisteredtypeinfo.h @@ -69,4 +69,7 @@ const char * gi_registered_type_info_get_type_init_function_name (GIRe GI_AVAILABLE_IN_ALL GType gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info); +GI_AVAILABLE_IN_ALL +gboolean gi_registered_type_info_is_boxed (GIRegisteredTypeInfo *info); + G_END_DECLS diff --git a/girepository/girwriter.c b/girepository/girwriter.c index b00b106b5..990d57a67 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -660,7 +660,7 @@ write_struct_info (const char *ns, type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info); - if (GI_IS_BOXED_INFO (info)) + if (gi_registered_type_info_is_boxed (GI_REGISTERED_TYPE_INFO (info))) { xml_start_element (file, "glib:boxed"); xml_printf (file, " glib:name=\"%s\"", name); @@ -1257,6 +1257,7 @@ write_union_info (const char *ns, type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info); + /* FIXME: Add support for boxed unions */ xml_start_element (file, "union"); xml_printf (file, " name=\"%s\"", name); diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index f4a9c2b21..fecfbb18d 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -48,6 +48,14 @@ gi_typelib_blob_type_to_info_type (GITypelibBlobType blob_type) { switch (blob_type) { + case BLOB_TYPE_BOXED: + /* `BLOB_TYPE_BOXED` now always refers to a `StructBlob`, and + * `GIRegisteredTypeInfo` (the parent type of `GIStructInfo`) has a method + * for distinguishing whether the struct is a boxed type. So presenting + * `BLOB_TYPE_BOXED` as its own `GIBaseInfo` subclass is not helpful. + * See commit e28078c70cbf4a57c7dbd39626f43f9bd2674145 and + * https://gitlab.gnome.org/GNOME/glib/-/issues/3245. */ + return GI_INFO_TYPE_STRUCT; default: return (GIInfoType) blob_type; } diff --git a/girepository/tests/meson.build b/girepository/tests/meson.build index 85febc1a3..7814ca0c5 100644 --- a/girepository/tests/meson.build +++ b/girepository/tests/meson.build @@ -20,6 +20,9 @@ if enable_gir 'object-info' : { 'depends': [gio_gir], }, + 'registered-type-info' : { + 'depends': [gobject_gir], + }, 'repository' : { 'depends': [glib_gir, gio_gir, gobject_gir], }, diff --git a/girepository/tests/registered-type-info.c b/girepository/tests/registered-type-info.c new file mode 100644 index 000000000..16dbf82af --- /dev/null +++ b/girepository/tests/registered-type-info.c @@ -0,0 +1,137 @@ +/* + * Copyright 2024 GNOME Foundation + * + * 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 . + */ + +#include "config.h" + +#include "girepository.h" +#include "test-common.h" + +static void +test_boxed (RepositoryFixture *fx, + const void *unused) +{ + const struct + { + const char *name; + GType expect_info_type; + gboolean expect_nonnull_gtype_info; + gboolean expect_is_gtype_struct; + gboolean expect_boxed; + } + types[] = + { + { + /* POD struct */ + .name = "CClosure", + .expect_info_type = GI_TYPE_STRUCT_INFO, + .expect_nonnull_gtype_info = FALSE, + .expect_is_gtype_struct = FALSE, + .expect_boxed = FALSE, + }, + { + /* POD union */ + .name = "TypeCValue", + .expect_info_type = GI_TYPE_UNION_INFO, + .expect_nonnull_gtype_info = FALSE, + .expect_is_gtype_struct = FALSE, + .expect_boxed = FALSE, + }, + { + /* struct for a different non-boxed GType */ + .name = "InitiallyUnownedClass", + .expect_info_type = GI_TYPE_STRUCT_INFO, + .expect_nonnull_gtype_info = FALSE, + .expect_is_gtype_struct = TRUE, + .expect_boxed = FALSE, + }, + { + /* boxed struct */ + .name = "BookmarkFile", + .expect_info_type = GI_TYPE_STRUCT_INFO, + .expect_nonnull_gtype_info = TRUE, + .expect_is_gtype_struct = FALSE, + .expect_boxed = TRUE, + }, + { + /* boxed struct */ + .name = "Closure", + .expect_info_type = GI_TYPE_STRUCT_INFO, + .expect_nonnull_gtype_info = TRUE, + .expect_is_gtype_struct = FALSE, + .expect_boxed = TRUE, + }, + { + /* non-boxed GType */ + .name = "Object", + .expect_info_type = GI_TYPE_OBJECT_INFO, + .expect_nonnull_gtype_info = TRUE, + .expect_is_gtype_struct = FALSE, + .expect_boxed = FALSE, + }, + }; + + g_test_summary ("Test various boxed and non-boxed types for GIRegisteredTypeInfo"); + + for (size_t i = 0; i < G_N_ELEMENTS (types); i++) + { + GIRegisteredTypeInfo *type_info = GI_REGISTERED_TYPE_INFO (gi_repository_find_by_name (fx->repository, "GObject", types[i].name)); + g_assert_nonnull (type_info); + + g_test_message ("Expecting %s to %s", types[i].name, types[i].expect_boxed ? "be boxed" : "not be boxed"); + + g_assert_cmpuint (G_TYPE_FROM_INSTANCE (type_info), ==, types[i].expect_info_type); + + if (types[i].expect_nonnull_gtype_info) + { + g_assert_nonnull (gi_registered_type_info_get_type_name (type_info)); + g_assert_nonnull (gi_registered_type_info_get_type_init_function_name (type_info)); + } + else + { + g_assert_null (gi_registered_type_info_get_type_name (type_info)); + g_assert_null (gi_registered_type_info_get_type_init_function_name (type_info)); + } + + if (GI_IS_STRUCT_INFO (type_info)) + { + if (types[i].expect_is_gtype_struct) + g_assert_true (gi_struct_info_is_gtype_struct (GI_STRUCT_INFO (type_info))); + else + g_assert_false (gi_struct_info_is_gtype_struct (GI_STRUCT_INFO (type_info))); + } + + if (types[i].expect_boxed) + g_assert_true (gi_registered_type_info_is_boxed (type_info)); + else + g_assert_false (gi_registered_type_info_is_boxed (type_info)); + + g_clear_pointer (&type_info, gi_base_info_unref); + } +} + +int +main (int argc, + char *argv[]) +{ + repository_init (&argc, &argv); + + ADD_REPOSITORY_TEST ("/registered-type-info/boxed", test_boxed, &typelib_load_spec_gobject); + + return g_test_run (); +} diff --git a/girepository/tests/repository.c b/girepository/tests/repository.c index 2b5d96a53..506726375 100644 --- a/girepository/tests/repository.c +++ b/girepository/tests/repository.c @@ -234,21 +234,6 @@ test_repository_arg_info (RepositoryFixture *fx, g_clear_pointer (&struct_info, gi_base_info_unref); } -static void -test_repository_boxed_info (RepositoryFixture *fx, - const void *unused) -{ - GIBoxedInfo *boxed_info = NULL; - - g_test_summary ("Test retrieving GIBoxedInfos from a typelib"); - - /* Test all the methods of GIBoxedInfo. This is simple, because there are none. */ - boxed_info = GI_BOXED_INFO (gi_repository_find_by_name (fx->repository, "GObject", "BookmarkFile")); - g_assert_nonnull (boxed_info); - - g_clear_pointer (&boxed_info, gi_base_info_unref); -} - static void test_repository_callable_info (RepositoryFixture *fx, const void *unused) @@ -766,7 +751,6 @@ main (int argc, ADD_REPOSITORY_TEST ("/repository/info", test_repository_info, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/repository/dependencies", test_repository_dependencies, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/repository/arg-info", test_repository_arg_info, &typelib_load_spec_gobject); - ADD_REPOSITORY_TEST ("/repository/boxed-info", test_repository_boxed_info, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/repository/callable-info", test_repository_callable_info, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/repository/callback-info", test_repository_callback_info, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/repository/char-types", test_repository_char_types, &typelib_load_spec_gobject); diff --git a/girepository/tests/struct-info.c b/girepository/tests/struct-info.c index 5a06fc060..7ed18c8d2 100644 --- a/girepository/tests/struct-info.c +++ b/girepository/tests/struct-info.c @@ -106,6 +106,21 @@ test_is_pointer_for_struct_method_arg (RepositoryFixture *fx, g_clear_pointer (&variant_info, gi_base_info_unref); } +static void +test_boxed (RepositoryFixture *fx, + const void *unused) +{ + GIStructInfo *struct_info = NULL; + + g_test_summary ("Test that a boxed struct is recognised as such"); + + struct_info = GI_STRUCT_INFO (gi_repository_find_by_name (fx->repository, "GObject", "BookmarkFile")); + g_assert_nonnull (struct_info); + g_assert_true (gi_registered_type_info_is_boxed (GI_REGISTERED_TYPE_INFO (struct_info))); + + g_clear_pointer (&struct_info, gi_base_info_unref); +} + int main (int argc, char *argv[]) @@ -115,6 +130,7 @@ main (int argc, ADD_REPOSITORY_TEST ("/struct-info/field-iterators", test_field_iterators, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/struct-info/sizeof-gvalue", test_size_of_gvalue, &typelib_load_spec_gobject); ADD_REPOSITORY_TEST ("/struct-info/is-pointer-for-struct-method-arg", test_is_pointer_for_struct_method_arg, &typelib_load_spec_glib); + ADD_REPOSITORY_TEST ("/struct-info/boxed", test_boxed, &typelib_load_spec_gobject); return g_test_run (); } From f51398af917cf16987b9a34390d49beb19b7bae5 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 8 Feb 2024 11:47:03 +0000 Subject: [PATCH 3/4] girepository: Drop GIBoxedInfo See the previous commit for details. Signed-off-by: Philip Withnall Helps: #3245 --- docs/reference/girepository/migrating-gi.md | 1 + girepository/gibaseinfo.c | 4 -- girepository/giboxedinfo.c | 52 ------------------ girepository/giboxedinfo.h | 60 --------------------- girepository/gifieldinfo.c | 2 - girepository/girepository-private.h | 23 +++----- girepository/girepository.c | 2 - girepository/girepository.h | 1 - girepository/girwriter.c | 3 +- girepository/gitypes.h | 4 -- girepository/meson.build | 2 - 11 files changed, 9 insertions(+), 145 deletions(-) delete mode 100644 girepository/giboxedinfo.c delete mode 100644 girepository/giboxedinfo.h diff --git a/docs/reference/girepository/migrating-gi.md b/docs/reference/girepository/migrating-gi.md index 4f8eb1d00..8e8175517 100644 --- a/docs/reference/girepository/migrating-gi.md +++ b/docs/reference/girepository/migrating-gi.md @@ -81,6 +81,7 @@ your code if integer type warnings are enabled. | `g_union_info_get_copy_function` | [method@GIRepository.UnionInfo.get_copy_function_name] | | `g_union_info_get_free_function` | [method@GIRepository.UnionInfo.get_free_function_name] | | `GIInfoType` | Use [type@GObject.Type] directly | +| `GI_INFO_TYPE_BOXED` | Dropped in favour of [method@GIRepository.RegisteredTypeInfo.is_boxed] | ## Utility program renames from version 1.0 to 2.0 diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 0ba672474..d24cd4aa8 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -257,7 +257,6 @@ GI_DEFINE_BASE_INFO_TYPE (gi_enum_info, GI_INFO_TYPE_ENUM) GI_DEFINE_BASE_INFO_TYPE (gi_flags_info, GI_INFO_TYPE_FLAGS) 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_boxed_info, GI_INFO_TYPE_BOXED) 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) @@ -296,7 +295,6 @@ gi_base_info_init_types (void) { GI_INFO_TYPE_FLAGS, "GIFlagsInfo", sizeof (GIFlagsInfo), gi_flags_info_class_init, GI_INFO_TYPE_ENUM, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init, GI_INFO_TYPE_REGISTERED_TYPE, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init, GI_INFO_TYPE_REGISTERED_TYPE, G_TYPE_FLAG_NONE }, - { GI_INFO_TYPE_BOXED, "GIBoxedInfo", sizeof (GIBoxedInfo), gi_boxed_info_class_init, GI_INFO_TYPE_REGISTERED_TYPE, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init, 0, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init, 0, G_TYPE_FLAG_NONE }, { GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init, GI_INFO_TYPE_CALLABLE, G_TYPE_FLAG_NONE }, @@ -668,7 +666,6 @@ gi_base_info_get_name (GIBaseInfo *info) case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: case GI_INFO_TYPE_STRUCT: - case GI_INFO_TYPE_BOXED: case GI_INFO_TYPE_ENUM: case GI_INFO_TYPE_FLAGS: case GI_INFO_TYPE_OBJECT: @@ -792,7 +789,6 @@ gi_base_info_is_deprecated (GIBaseInfo *info) case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: case GI_INFO_TYPE_STRUCT: - case GI_INFO_TYPE_BOXED: case GI_INFO_TYPE_ENUM: case GI_INFO_TYPE_FLAGS: case GI_INFO_TYPE_OBJECT: diff --git a/girepository/giboxedinfo.c b/girepository/giboxedinfo.c deleted file mode 100644 index 36921e31a..000000000 --- a/girepository/giboxedinfo.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * GObject introspection: Boxed type implementation - * - * Copyright 2024 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 "gibaseinfo-private.h" -#include "girepository-private.h" -#include "gitypelib-internal.h" -#include "giboxedinfo.h" - -/** - * GIBoxedInfo: - * - * A `GIBoxedInfo` represents a boxed type. - * - * There isn’t much you can do with a boxed type; `GIBoxedInfo` exists mainly to - * tag the type. - * - * Since: 2.80 - */ - -void -gi_boxed_info_class_init (gpointer g_class, - gpointer class_data) -{ - GIBaseInfoClass *info_class = g_class; - - info_class->info_type = GI_INFO_TYPE_BOXED; -} diff --git a/girepository/giboxedinfo.h b/girepository/giboxedinfo.h deleted file mode 100644 index f94987e13..000000000 --- a/girepository/giboxedinfo.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * GObject introspection: Boxed types - * - * Copyright 2024 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 - -#define GI_TYPE_BOXED_INFO (gi_boxed_info_get_type ()) - -/** - * GI_BOXED_INFO: - * @info: Info object which is subject to casting. - * - * Casts a [type@GIRepository.BoxedInfo] or derived pointer into a - * `(GIBoxedInfo*)` pointer. - * - * Depending on the current debugging level, this function may invoke - * certain runtime checks to identify invalid casts. - * - * Since: 2.80 - */ -#define GI_BOXED_INFO(info) (G_TYPE_CHECK_INSTANCE_CAST ((info), GI_TYPE_BOXED_INFO, GIBoxedInfo)) - -/** - * GI_IS_BOXED_INFO: - * @info: an info structure - * - * Checks if @info is a [class@GIRepository.BoxedInfo] (or a derived type). - * - * Since: 2.80 - */ -#define GI_IS_BOXED_INFO(info) (G_TYPE_CHECK_INSTANCE_TYPE ((info), GI_TYPE_BOXED_INFO)) - -G_END_DECLS diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index a326608a4..819ccf72b 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -278,7 +278,6 @@ gi_field_info_get_field (GIFieldInfo *field_info, { case GI_INFO_TYPE_STRUCT: case GI_INFO_TYPE_UNION: - case GI_INFO_TYPE_BOXED: /* Needs to be handled by the language binding directly */ break; case GI_INFO_TYPE_OBJECT: @@ -464,7 +463,6 @@ gi_field_info_set_field (GIFieldInfo *field_info, { case GI_INFO_TYPE_STRUCT: case GI_INFO_TYPE_UNION: - case GI_INFO_TYPE_BOXED: /* Needs to be handled by the language binding directly */ break; case GI_INFO_TYPE_OBJECT: diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index 8245e566c..e21485881 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -72,8 +72,6 @@ G_STATIC_ASSERT (G_ALIGNOF (GIBaseInfo) == G_ALIGNOF (GIBaseInfoStack)); * @GI_INFO_TYPE_FUNCTION: function, see [class@GIRepository.FunctionInfo] * @GI_INFO_TYPE_CALLBACK: callback, see [class@GIRepository.FunctionInfo] * @GI_INFO_TYPE_STRUCT: struct, see [class@GIRepository.StructInfo] - * @GI_INFO_TYPE_BOXED: boxed, see [class@GIRepository.StructInfo] or - * [class@GIRepository.UnionInfo] * @GI_INFO_TYPE_ENUM: enum, see [class@GIRepository.EnumInfo] * @GI_INFO_TYPE_FLAGS: flags, see [class@GIRepository.EnumInfo] * @GI_INFO_TYPE_OBJECT: object, see [class@GIRepository.ObjectInfo] @@ -113,12 +111,13 @@ typedef enum GI_INFO_TYPE_FUNCTION, GI_INFO_TYPE_CALLBACK, GI_INFO_TYPE_STRUCT, - GI_INFO_TYPE_BOXED, - GI_INFO_TYPE_ENUM, /* 5 */ - GI_INFO_TYPE_FLAGS, - GI_INFO_TYPE_OBJECT, - GI_INFO_TYPE_INTERFACE, - GI_INFO_TYPE_CONSTANT, + /* 4 is skipped, it used to be BOXED, but was removed in girepository 2.80. + * It is still part of the binary format in GITypelibBlobType. */ + GI_INFO_TYPE_ENUM = 5, /* 5 */ + GI_INFO_TYPE_FLAGS = 6, + GI_INFO_TYPE_OBJECT = 7, + GI_INFO_TYPE_INTERFACE = 8, + GI_INFO_TYPE_CONSTANT = 9, /* 10 is skipped, it used to be used, but was removed before girepository-2.0 * It is, however, part of the binary format in GITypelibBlobType */ GI_INFO_TYPE_UNION = 11, @@ -227,14 +226,6 @@ struct _GIInterfaceInfo void gi_interface_info_class_init (gpointer g_class, gpointer class_data); -struct _GIBoxedInfo -{ - GIRegisteredTypeInfo parent; -}; - -void gi_boxed_info_class_init (gpointer g_class, - gpointer class_data); - struct _GIConstantInfo { GIBaseInfo parent; diff --git a/girepository/girepository.c b/girepository/girepository.c index 26f802812..4da671bcf 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -2065,8 +2065,6 @@ gi_info_type_to_string (GIInfoType type) return "callback"; case GI_INFO_TYPE_STRUCT: return "struct"; - case GI_INFO_TYPE_BOXED: - return "boxed"; case GI_INFO_TYPE_ENUM: return "enum"; case GI_INFO_TYPE_FLAGS: diff --git a/girepository/girepository.h b/girepository/girepository.h index ffe091928..fa0b93e30 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 990d57a67..4b771bd0b 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1421,8 +1421,7 @@ gi_ir_writer_write (const char *filename, write_function_info (ns, (GIFunctionInfo *)info, xml); else if (GI_IS_CALLBACK_INFO (info)) write_callback_info (ns, (GICallbackInfo *)info, xml); - else if (GI_IS_STRUCT_INFO (info) || - GI_IS_BOXED_INFO (info)) + else if (GI_IS_STRUCT_INFO (info)) write_struct_info (ns, (GIStructInfo *)info, xml); else if (GI_IS_UNION_INFO (info)) write_union_info (ns, (GIUnionInfo *)info, xml); diff --git a/girepository/gitypes.h b/girepository/gitypes.h index c3e9fd673..21c873b2e 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -92,10 +92,6 @@ GI_AVAILABLE_IN_ALL GType gi_object_info_get_type (void); typedef struct _GIInterfaceInfo GIInterfaceInfo; GI_AVAILABLE_IN_ALL GType gi_interface_info_get_type (void); -/* Documented in giboxedinfo.c */ -typedef struct _GIBoxedInfo GIBoxedInfo; -GI_AVAILABLE_IN_ALL GType gi_boxed_info_get_type (void); - /* Documented in giconstantinfo.c */ typedef struct _GIConstantInfo GIConstantInfo; GI_AVAILABLE_IN_ALL GType gi_constant_info_get_type (void); diff --git a/girepository/meson.build b/girepository/meson.build index 3292f6672..4ff924685 100644 --- a/girepository/meson.build +++ b/girepository/meson.build @@ -44,7 +44,6 @@ gi_visibility_h = custom_target( girepo_headers = files( 'giarginfo.h', 'gibaseinfo.h', - 'giboxedinfo.h', 'gicallableinfo.h', 'gicallbackinfo.h', 'giconstantinfo.h', @@ -148,7 +147,6 @@ girepo_sources = files( 'gdump.c', 'giarginfo.c', 'gibaseinfo.c', - 'giboxedinfo.c', 'gicallableinfo.c', 'gicallbackinfo.c', 'giconstantinfo.c', From 5ddd4b91b84d2e03140a8aa837f3635c10f7e8ee Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 12 Feb 2024 13:30:17 +0000 Subject: [PATCH 4/4] girepository: Drop unneeded include from girepository-private.h It was causing a build failure on some platforms: ``` In file included from ../girepository/gthash.c:29: In file included from ../girepository/gitypelib-internal.h:30: ../girepository/girepository-private.h:26:10: fatal error: 'ffi.h' file not found #include ^~~~~~~ ``` Signed-off-by: Philip Withnall --- girepository/girepository-private.h | 1 - 1 file changed, 1 deletion(-) diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index e21485881..0433bac30 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -23,7 +23,6 @@ #pragma once -#include #include #define __GIREPOSITORY_H_INSIDE__