girwriter: Stop using gi_base_info_get_info_type()

While it’s an internal API which `girwriter.c` has access to, it’s not
available inside `libgirepository-internals.so`. This wasn’t spotted
before commit 343027d5d landed because none of the existing users of
`libgirepository-internals.so` use the relevant code in `girwriter.c`,
so it got compiled out (`libgirepository-internals.so` is statically
linked and can be optimised like this).

Now that `gi-decompile-repository` uses the relevant code from
`girwriter.c`, the problem is obvious and `gi-decompile-repository`
fails to link.

Fix that by no longer using `gi_base_info_get_info_type()` in
`girwriter.c`. These are changes which would have eventually been made
anyway in issue #3253.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3253
This commit is contained in:
Philip Withnall 2024-02-08 23:38:05 +00:00
parent 8248382d8b
commit d03727c07d

View File

@ -167,7 +167,7 @@ xml_free (Xml *xml)
static void static void
check_unresolved (GIBaseInfo *info) check_unresolved (GIBaseInfo *info)
{ {
if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED) if (!GI_IS_UNRESOLVED_INFO (info))
return; return;
g_critical ("Found unresolved type '%s' '%s'", g_critical ("Found unresolved type '%s' '%s'",
@ -442,7 +442,7 @@ write_field_info (const char *ns,
} }
interface = gi_type_info_get_interface (type); interface = gi_type_info_get_interface (type);
if (interface && gi_base_info_get_info_type (interface) == GI_INFO_TYPE_CALLBACK) if (interface != NULL && GI_IS_CALLBACK_INFO (interface))
write_callback_info (ns, (GICallbackInfo *)interface, file); write_callback_info (ns, (GICallbackInfo *)interface, file);
else else
write_type_info (ns, type, file); write_type_info (ns, type, file);
@ -660,7 +660,7 @@ write_struct_info (const char *ns,
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info); type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_BOXED) if (GI_IS_BOXED_INFO (info))
{ {
xml_start_element (file, "glib:boxed"); xml_start_element (file, "glib:boxed");
xml_printf (file, " glib:name=\"%s\"", name); xml_printf (file, " glib:name=\"%s\"", name);
@ -847,7 +847,7 @@ write_enum_info (const char *ns,
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info); type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
error_domain = gi_enum_info_get_error_domain (info); error_domain = gi_enum_info_get_error_domain (info);
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_ENUM) if (GI_IS_ENUM_INFO (info))
xml_start_element (file, "enumeration"); xml_start_element (file, "enumeration");
else else
xml_start_element (file, "bitfield"); xml_start_element (file, "bitfield");
@ -1415,45 +1415,27 @@ gi_ir_writer_write (const char *filename,
for (j = 0; j < n_infos; j++) for (j = 0; j < n_infos; j++)
{ {
GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j); GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j);
switch (gi_base_info_get_info_type (info))
{
case GI_INFO_TYPE_FUNCTION:
write_function_info (ns, (GIFunctionInfo *)info, xml);
break;
case GI_INFO_TYPE_CALLBACK: if (GI_IS_FUNCTION_INFO (info))
write_callback_info (ns, (GICallbackInfo *)info, xml); write_function_info (ns, (GIFunctionInfo *)info, xml);
break; else if (GI_IS_CALLBACK_INFO (info))
write_callback_info (ns, (GICallbackInfo *)info, xml);
case GI_INFO_TYPE_STRUCT: else if (GI_IS_STRUCT_INFO (info) ||
case GI_INFO_TYPE_BOXED: GI_IS_BOXED_INFO (info))
write_struct_info (ns, (GIStructInfo *)info, xml); write_struct_info (ns, (GIStructInfo *)info, xml);
break; else if (GI_IS_UNION_INFO (info))
write_union_info (ns, (GIUnionInfo *)info, xml);
case GI_INFO_TYPE_UNION: else if (GI_IS_ENUM_INFO (info) ||
write_union_info (ns, (GIUnionInfo *)info, xml); GI_IS_FLAGS_INFO (info))
break; write_enum_info (ns, (GIEnumInfo *)info, xml);
else if (GI_IS_CONSTANT_INFO (info))
case GI_INFO_TYPE_ENUM: write_constant_info (ns, (GIConstantInfo *)info, xml);
case GI_INFO_TYPE_FLAGS: else if (GI_IS_OBJECT_INFO (info))
write_enum_info (ns, (GIEnumInfo *)info, xml); write_object_info (ns, (GIObjectInfo *)info, xml);
break; else if (GI_IS_INTERFACE_INFO (info))
write_interface_info (ns, (GIInterfaceInfo *)info, xml);
case GI_INFO_TYPE_CONSTANT: else
write_constant_info (ns, (GIConstantInfo *)info, xml); g_error ("unknown info type %s", g_type_name (G_TYPE_FROM_INSTANCE (info)));
break;
case GI_INFO_TYPE_OBJECT:
write_object_info (ns, (GIObjectInfo *)info, xml);
break;
case GI_INFO_TYPE_INTERFACE:
write_interface_info (ns, (GIInterfaceInfo *)info, xml);
break;
default:
g_error ("unknown info type %d", gi_base_info_get_info_type (info));
}
gi_base_info_unref (info); gi_base_info_unref (info);
} }