From c0c06b9e1cbb760b661a7adf4163cc6ba19828b3 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 16 Mar 2025 15:13:17 +0100
Subject: Update a GObject storage prototype to make its usage more convinient.

---
 plugins/pychrysalide/glibext/storage.c | 18 ++++++++++--------
 src/glibext/storage.c                  | 10 +++++-----
 src/glibext/storage.h                  |  2 +-
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/plugins/pychrysalide/glibext/storage.c b/plugins/pychrysalide/glibext/storage.c
index 4764700..f2962bf 100644
--- a/plugins/pychrysalide/glibext/storage.c
+++ b/plugins/pychrysalide/glibext/storage.c
@@ -309,32 +309,34 @@ static PyObject *py_object_storage_load_object(PyObject *self, PyObject *args)
 static PyObject *py_object_storage_unpack_object(PyObject *self, PyObject *args)
 {
     PyObject *result;                       /* Bilan à retourner           */
-    const char *name;                       /* Désignation de groupe #0    */
-    const char *target_name;                /* Désignation de groupe #1    */
+    int fd;                                 /* Flux de fonnées courant     */
+    const char *name;                       /* Désignation de groupe       */
     int ret;                                /* Bilan de lecture des args.  */
     GObjectStorage *storage;                /* Mécanismes natifs           */
     GSerializableObject *object;            /* Objet reconstruit ou NULL   */
 
 #define OBJECT_STORAGE_UNPACK_OBJECT_METHOD PYTHON_METHOD_DEF           \
 (                                                                       \
-    unpack_object, "$self, name, target_name, /",                       \
+    unpack_object, "$self, fd, name, /",                                \
     METH_VARARGS, py_object_storage,                                    \
     "Load an object from a reference to serialized data.\n"             \
     "\n"                                                                \
-    "The *name* is a string label for the group containing a position"  \
-    " pointing to a target object to load. The *target_name* is a"      \
-    " string label for the group of this target object.\n"              \
+    "The *fd* argument is a file descriptor pointing to the data"       \
+    " stream for a current object being restored. A reference to"       \
+    " another object belonging to a group pointed by the string *name*" \
+    " should be available at the current read position for this data"   \
+    " stream.\n"                                                        \
     "\n"                                                                \
     "The result is a pychrysalide.analysis.storage.SerializableObject"  \
     " instancet in case of success, or *None* in case of failure."      \
 )
 
-    ret = PyArg_ParseTuple(args, "sO&", &name, &target_name);
+    ret = PyArg_ParseTuple(args, "is", &fd, &name);
     if (!ret) return NULL;
 
     storage = G_OBJECT_STORAGE(pygobject_get(self));
 
-    object = g_object_storage_unpack_object(storage, name, target_name);
+    object = g_object_storage_unpack_object(storage, fd, name);
 
     if (object != NULL)
         result = pygobject_new(G_OBJECT(object));
diff --git a/src/glibext/storage.c b/src/glibext/storage.c
index 0e6620b..0a3c4e7 100644
--- a/src/glibext/storage.c
+++ b/src/glibext/storage.c
@@ -1023,9 +1023,9 @@ GSerializableObject *g_object_storage_load_object(GObjectStorage *storage, const
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : storage     = gestionnaire à manipuler.                      *
-*                name        = désignation d'un groupe d'objets à consulter.  *
-*                target_name = désignation d'un second groupe d'objets ciblé. *
+*  Paramètres  : storage = gestionnaire à manipuler.                          *
+*                fd      = flux de données de l'objet courant.                *
+*                name    = désignation du groupe de l'objets à extraire.      *
 *                                                                             *
 *  Description : Charge un objet interne à partir d'une référence embarquée.  *
 *                                                                             *
@@ -1035,7 +1035,7 @@ GSerializableObject *g_object_storage_load_object(GObjectStorage *storage, const
 *                                                                             *
 ******************************************************************************/
 
-GSerializableObject *g_object_storage_unpack_object(GObjectStorage *storage, const char *name, const char *target_name)
+GSerializableObject *g_object_storage_unpack_object(GObjectStorage *storage, int fd, const char *name)
 {
     GSerializableObject *result;            /* Instance à retourner        */
     storage_backend_t *backend;             /* Informations à consulter    */
@@ -1065,7 +1065,7 @@ GSerializableObject *g_object_storage_unpack_object(GObjectStorage *storage, con
 
     /* Chargement */
 
-    result = g_object_storage_load_object_unlocked(storage, target_name, pos);
+    result = g_object_storage_load_object_unlocked(storage, name, pos);
 
     if (result == NULL) goto exit;
 
diff --git a/src/glibext/storage.h b/src/glibext/storage.h
index 8231a31..ea06ed4 100644
--- a/src/glibext/storage.h
+++ b/src/glibext/storage.h
@@ -51,7 +51,7 @@ bool g_object_storage_store(GObjectStorage *, const char *);
 GSerializableObject *g_object_storage_load_object(GObjectStorage *, const char *, off64_t);
 
 /* Charge un objet interne à partir d'une référence embarquée. */
-GSerializableObject *g_object_storage_unpack_object(GObjectStorage *, const char *, const char *);
+GSerializableObject *g_object_storage_unpack_object(GObjectStorage *, int, const char *);
 
 /* Sauvegarde un object sous forme de données rassemblées. */
 bool g_object_storage_store_object(GObjectStorage *, const char *, const GSerializableObject *, off64_t *);
-- 
cgit v0.11.2-87-g4458