mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
gitypelib: Explicitly convert from GITypelibBlobType to GIInfoType
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 <pwithnall@gnome.org> Helps: #3245
This commit is contained in:
parent
dbc38b28aa
commit
54f156bd63
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <gmodule.h>
|
||||
#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)
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user