gitypelib: Replace multiple constructors with gi_typelib_new_from_bytes()

`GBytes` provides a way of handling const memory blobs, stolen memory
blobs, and mapped files. Rather than having `GITypelib` implement all of
those itself, just take a `GBytes` as input.

This is an API break, but libgirepository hasn’t been in a stable
release yet.

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

Helps: #3155
This commit is contained in:
Philip Withnall
2024-01-26 09:49:56 +00:00
parent 7262f5ab14
commit 1eec66c898
5 changed files with 30 additions and 95 deletions

View File

@@ -1752,7 +1752,12 @@ require_internal (GIRepository *repository,
{
GError *temp_error = NULL;
typelib = gi_typelib_new_from_mapped_file (mfile, &temp_error);
GBytes *bytes = NULL;
bytes = g_mapped_file_get_bytes (mfile);
typelib = gi_typelib_new_from_bytes (bytes, &temp_error);
g_bytes_unref (bytes);
if (!typelib)
{
g_set_error (error, GI_REPOSITORY_ERROR,