girepository: Port GIBaseInfo to GTypeInstance

This adds more type safety to libgirepository, and allows
differentiating the `GIBaseInfo` derived types using the type system.

Two new derived types had to be added (previously they were just a
collection of helper methods which worked directly on a `GIBaseInfo` and
didn’t check types): `GICallbackInfo` and `GIUnresolvedInfo`.

Further cleanups and refactoring might be needed on this, but the core
of libgirepository now uses `GTypeInstance` and appears to still work
(it’s difficult to be entirely sure because there are no unit tests
yet).

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

Helps: #3155
This commit is contained in:
Philip Withnall
2023-11-28 17:24:20 +00:00
parent cdb5ab0cd2
commit 52ac467426
25 changed files with 921 additions and 192 deletions

View File

@@ -28,6 +28,7 @@
#include <string.h> // memcpy
#include <girepository/girepository.h>
#include "gibaseinfo-private.h"
#include "girepository-private.h"
#include "gitypelib-internal.h"
#include "giconstantinfo.h"
@@ -176,3 +177,11 @@ gi_constant_info_get_value (GIConstantInfo *info,
return blob->size;
}
void
gi_constant_info_class_init (gpointer g_class,
gpointer class_data)
{
GIBaseInfoClass *info_class = g_class;
info_class->info_type = GI_INFO_TYPE_CONSTANT;
}