girepository: Move internal gi_typelib_blob_type_to_info_type() function

`GITypeInfo` isn’t defined in `libgirepository-internals`, and that was
forcing us to do some header includes which violated the layering
between `libigrepository-internals` and `libgirepository`. Fix that by
moving the helper function to the header/source where `GITypeInfo` is
defined.

This fixes commit 54f156bd63.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-02-14 11:52:33 +00:00
parent 75820a6941
commit f4f38c233f
4 changed files with 22 additions and 21 deletions

View File

@ -31,6 +31,8 @@
#include <girepository/girepository.h> #include <girepository/girepository.h>
#include <girepository/gitypelib.h> #include <girepository/gitypelib.h>
#include "gitypelib-internal.h"
/* FIXME: For now, GIRealInfo is a compatibility define. This will eventually /* FIXME: For now, GIRealInfo is a compatibility define. This will eventually
* be removed. */ * be removed. */
typedef struct _GIBaseInfo GIRealInfo; typedef struct _GIBaseInfo GIRealInfo;
@ -133,6 +135,8 @@ typedef enum
/* keep GI_INFO_TYPE_N_TYPES in sync with this */ /* keep GI_INFO_TYPE_N_TYPES in sync with this */
} GIInfoType; } GIInfoType;
GIInfoType gi_typelib_blob_type_to_info_type (GITypelibBlobType blob_type);
/** /**
* GI_INFO_TYPE_N_TYPES: * GI_INFO_TYPE_N_TYPES:
* *

View File

@ -2097,3 +2097,21 @@ gi_info_type_to_string (GIInfoType type)
return "unknown"; return "unknown";
} }
} }
GIInfoType
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;
}
}

View File

@ -27,7 +27,6 @@
#include <gmodule.h> #include <gmodule.h>
#include "girepository.h" #include "girepository.h"
#include "girepository-private.h"
G_BEGIN_DECLS G_BEGIN_DECLS
@ -195,8 +194,6 @@ typedef enum {
BLOB_TYPE_UNION BLOB_TYPE_UNION
} GITypelibBlobType; } GITypelibBlobType;
GIInfoType gi_typelib_blob_type_to_info_type (GITypelibBlobType blob_type);
#if defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE) #if defined (G_CAN_INLINE) && defined (G_ALWAYS_INLINE)

View File

@ -43,24 +43,6 @@
G_DEFINE_BOXED_TYPE (GITypelib, gi_typelib, gi_typelib_ref, gi_typelib_unref) 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)
{
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;
}
}
typedef struct { typedef struct {
GITypelib *typelib; GITypelib *typelib;
GSList *context_stack; GSList *context_stack;