summaryrefslogtreecommitdiff
path: root/src/arch/register.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/register.c')
-rw-r--r--src/arch/register.c116
1 files changed, 68 insertions, 48 deletions
diff --git a/src/arch/register.c b/src/arch/register.c
index 740a06b..112492c 100644
--- a/src/arch/register.c
+++ b/src/arch/register.c
@@ -25,7 +25,7 @@
#include "register-int.h"
-#include "storage.h"
+#include "../analysis/storage/serialize-int.h"
@@ -38,6 +38,9 @@ static void g_arch_register_class_init(GArchRegisterClass *);
/* Initialise une instance de registre. */
static void g_arch_register_init(GArchRegister *);
+/* Procède à l'initialisation de l'interface de sérialisation. */
+static void g_arch_register_serializable_init(GSerializableObjectInterface *);
+
/* Supprime toutes les références externes. */
static void g_arch_register_dispose(GArchRegister *);
@@ -46,14 +49,20 @@ static void g_arch_register_finalize(GArchRegister *);
-/* --------------------- TRANSPOSITIONS VIA CACHE DES REGISTRES --------------------- */
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+/* Charge un contenu depuis une mémoire tampon. */
+static bool _g_arch_register_load(GArchRegister *, GObjectStorage *, packed_buffer_t *);
-/* Charge un registre depuis une mémoire tampon. */
-static GArchRegister *g_arch_register_unserialize(GArchRegister *, GAsmStorage *, packed_buffer_t *);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_arch_register_load(GArchRegister *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un registre dans une mémoire tampon. */
-static bool g_arch_register_serialize(const GArchRegister *, GAsmStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool _g_arch_register_store(GArchRegister *, GObjectStorage *, packed_buffer_t *);
+
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_arch_register_store(GArchRegister *, GObjectStorage *, packed_buffer_t *);
@@ -63,7 +72,8 @@ static bool g_arch_register_serialize(const GArchRegister *, GAsmStorage *, pack
/* Indique le type défini pour une représentation d'un registre. */
-G_DEFINE_TYPE(GArchRegister, g_arch_register, G_TYPE_OBJECT);
+G_DEFINE_TYPE_WITH_CODE(GArchRegister, g_arch_register, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_arch_register_serializable_init));
/******************************************************************************
@@ -87,8 +97,8 @@ static void g_arch_register_class_init(GArchRegisterClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_arch_register_dispose;
object->finalize = (GObjectFinalizeFunc)g_arch_register_finalize;
- klass->unserialize = (reg_unserialize_fc)g_arch_register_unserialize;
- klass->serialize = (reg_serialize_fc)g_arch_register_serialize;
+ klass->load = (load_register_fc)_g_arch_register_load;
+ klass->store = (store_register_fc)_g_arch_register_store;
}
@@ -113,6 +123,26 @@ static void g_arch_register_init(GArchRegister *reg)
/******************************************************************************
* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de sérialisation. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arch_register_serializable_init(GSerializableObjectInterface *iface)
+{
+ iface->load = (load_serializable_object_cb)g_arch_register_load;
+ iface->store = (store_serializable_object_cb)g_arch_register_store;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : reg = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -262,17 +292,17 @@ bool g_arch_register_is_stack_pointer(const GArchRegister *reg)
/* ---------------------------------------------------------------------------------- */
-/* TRANSPOSITIONS VIA CACHE DES REGISTRES */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
/* ---------------------------------------------------------------------------------- */
/******************************************************************************
* *
-* Paramètres : reg = registre d'architecture à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : reg = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Charge un registre depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -280,11 +310,11 @@ bool g_arch_register_is_stack_pointer(const GArchRegister *reg)
* *
******************************************************************************/
-static GArchRegister *g_arch_register_unserialize(GArchRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool _g_arch_register_load(GArchRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GArchRegister *result; /* Instance à retourner */
+ bool result; /* Bilan à retourner */
- result = reg;
+ result = true;
return result;
@@ -293,36 +323,26 @@ static GArchRegister *g_arch_register_unserialize(GArchRegister *reg, GAsmStorag
/******************************************************************************
* *
-* Paramètres : storage = mécanisme de sauvegarde à manipuler. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : reg = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Charge un registre depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
-* Retour : Registre d'architecture constitué ou NULL en cas d'échec. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchRegister *g_arch_register_load(GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_arch_register_load(GArchRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GArchRegister *result; /* Instance à retourner */
- GArchRegister *dummy; /* Patron du type de registre */
-
- dummy = G_ARCH_REGISTER(g_asm_storage_create_object(storage, pbuf));
-
- if (dummy != NULL)
- {
- result = G_ARCH_REGISTER_GET_CLASS(dummy)->unserialize(dummy, storage, pbuf);
-
- /* Si personne ne l'a fait avant... */
- if (result != NULL)
- g_object_unref(G_OBJECT(dummy));
+ bool result; /* Bilan à retourner */
+ GArchRegisterClass *class; /* Classe à activer */
- }
+ class = G_ARCH_REGISTER_GET_CLASS(reg);
- else
- result = NULL;
+ result = class->load(reg, storage, pbuf);
return result;
@@ -331,11 +351,11 @@ GArchRegister *g_arch_register_load(GAsmStorage *storage, packed_buffer_t *pbuf)
/******************************************************************************
* *
-* Paramètres : reg = registre d'architecture à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : reg = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un registre dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -343,7 +363,7 @@ GArchRegister *g_arch_register_load(GAsmStorage *storage, packed_buffer_t *pbuf)
* *
******************************************************************************/
-static bool g_arch_register_serialize(const GArchRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool _g_arch_register_store(GArchRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
@@ -356,11 +376,11 @@ static bool g_arch_register_serialize(const GArchRegister *reg, GAsmStorage *sto
/******************************************************************************
* *
-* Paramètres : reg = registre d'architecture à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : reg = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un registre dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -368,14 +388,14 @@ static bool g_arch_register_serialize(const GArchRegister *reg, GAsmStorage *sto
* *
******************************************************************************/
-bool g_arch_register_store(const GArchRegister *reg, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_arch_register_store(GArchRegister *reg, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
+ GArchRegisterClass *class; /* Classe à activer */
- result = g_asm_storage_store_object_gtype(storage, G_OBJECT(reg), pbuf);
+ class = G_ARCH_REGISTER_GET_CLASS(reg);
- if (result)
- result = G_ARCH_REGISTER_GET_CLASS(reg)->serialize(reg, storage, pbuf);
+ result = class->store(reg, storage, pbuf);
return result;