From 71a19a6f65a0281779a9dad58d95982c773b750a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 17 Jan 2024 14:21:07 +0000 Subject: [PATCH] gibaseinfo: Allow type flags to be specified for derived types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn’t change any of the flags for now (i.e. it introduces no functional changes), but it will allow us to make some of the types abstract in an upcoming commit. Signed-off-by: Philip Withnall Helps: #3216 --- girepository/gibaseinfo-private.h | 3 +- girepository/gibaseinfo.c | 46 +++++++++++++++++-------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/girepository/gibaseinfo-private.h b/girepository/gibaseinfo-private.h index a756f7072..ae82b43a4 100644 --- a/girepository/gibaseinfo-private.h +++ b/girepository/gibaseinfo-private.h @@ -46,6 +46,7 @@ void gi_base_info_init_types (void); GType gi_base_info_type_register_static (const char *type_name, size_t instance_size, - GClassInitFunc class_init); + GClassInitFunc class_init, + GTypeFlags type_flags); G_END_DECLS diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 031635c3a..6691936fc 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -204,6 +204,7 @@ gi_base_info_get_type (void) * @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 + * @type_flags: flags for the type * * Registers a new [type@GIRepository.BaseInfo] type for the given @type_name * using the type information provided. @@ -214,7 +215,8 @@ gi_base_info_get_type (void) GType gi_base_info_type_register_static (const char *type_name, size_t instance_size, - GClassInitFunc class_init) + GClassInitFunc class_init, + GTypeFlags type_flags) { GTypeInfo info; @@ -228,7 +230,7 @@ gi_base_info_type_register_static (const char *type_name, info.instance_init = NULL; info.value_table = NULL; - return g_type_register_static (GI_TYPE_BASE_INFO, type_name, &info, 0); + return g_type_register_static (GI_TYPE_BASE_INFO, type_name, &info, type_flags); } static GType gi_base_info_types[GI_INFO_TYPE_N_TYPES]; @@ -274,34 +276,36 @@ gi_base_info_init_types (void) const char *type_name; size_t instance_size; GClassInitFunc class_init; + GTypeFlags type_flags; } 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 }, + { GI_INFO_TYPE_CALLABLE, "GICallableInfo", sizeof (GICallableInfo), gi_callable_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_FUNCTION, "GIFunctionInfo", sizeof (GIFunctionInfo), gi_function_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_CALLBACK, "GICallbackInfo", sizeof (GICallbackInfo), gi_callback_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_REGISTERED_TYPE, "GIRegisteredTypeInfo", sizeof (GIRegisteredTypeInfo), gi_registered_type_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_STRUCT, "GIStructInfo", sizeof (GIStructInfo), gi_struct_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_UNION, "GIUnionInfo", sizeof (GIUnionInfo), gi_union_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_ENUM, "GIEnumInfo", sizeof (GIEnumInfo), gi_enum_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_OBJECT, "GIObjectInfo", sizeof (GIObjectInfo), gi_object_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_INTERFACE, "GIInterfaceInfo", sizeof (GIInterfaceInfo), gi_interface_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_CONSTANT, "GIConstantInfo", sizeof (GIConstantInfo), gi_constant_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_VALUE, "GIValueInfo", sizeof (GIValueInfo), gi_value_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_SIGNAL, "GISignalInfo", sizeof (GISignalInfo), gi_signal_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_VFUNC, "GIVFuncInfo", sizeof (GIVFuncInfo), gi_vfunc_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_PROPERTY, "GIPropertyInfo", sizeof (GIPropertyInfo), gi_property_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_FIELD, "GIFieldInfo", sizeof (GIFieldInfo), gi_field_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_ARG, "GIArgInfo", sizeof (GIArgInfo), gi_arg_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_TYPE, "GITypeInfo", sizeof (GITypeInfo), gi_type_info_class_init, G_TYPE_FLAG_NONE }, + { GI_INFO_TYPE_UNRESOLVED, "GIUnresolvedInfo", sizeof (GIUnresolvedInfo), gi_unresolved_info_class_init, G_TYPE_FLAG_NONE }, }; for (size_t 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); + types[i].class_init, + types[i].type_flags); gi_base_info_types[types[i].info_type] = registered_type; }