summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analysis/storage/storage.c65
-rw-r--r--src/analysis/storage/storage.h6
-rw-r--r--src/analysis/type.c5
-rw-r--r--src/analysis/types/array.c8
-rw-r--r--src/analysis/types/encaps.c8
-rw-r--r--src/analysis/types/literal.c8
-rw-r--r--src/analysis/types/override.c8
-rw-r--r--src/analysis/types/proto.c21
-rw-r--r--src/analysis/types/template.c13
9 files changed, 107 insertions, 35 deletions
diff --git a/src/analysis/storage/storage.c b/src/analysis/storage/storage.c
index c63f7d0..bd40353 100644
--- a/src/analysis/storage/storage.c
+++ b/src/analysis/storage/storage.c
@@ -380,8 +380,40 @@ GSerializableObject *g_object_storage_load_object(GObjectStorage *storage, const
* *
* Paramètres : storage = gestionnaire à manipuler. *
* name = désignation d'un nouveau groupe d'objets. *
-* pbuf = zone tampon à lire. *
-* pos = tête de lecture avant écriture, ou NULL. [OUT] *
+* pbuf = zone tampon à parcourir. *
+* *
+* Description : Charge un objet interne à partir de données rassemblées. *
+* *
+* Retour : Objet restauré en mémoire ou NULL en cas d'échec. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GSerializableObject *g_object_storage_unpack_object(GObjectStorage *storage, const char *name, packed_buffer *pbuf)
+{
+ GSerializableObject *result; /* Instance à retourner */
+ uint64_t pos; /* Localisation des données */
+ bool status; /* Bilan d'une opération */
+
+ result = NULL;
+
+ status = extract_packed_buffer(pbuf, &pos, sizeof(uint64_t), true);
+
+ if (status)
+ result = g_object_storage_load_object(storage, name, pos);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : storage = gestionnaire à manipuler. *
+* name = désignation d'un nouveau groupe d'objets. *
+* object = objet sérialisable à traiter. *
+* pos = tête de lecture avant écriture. [OUT] *
* *
* Description : Sauvegarde un object sous forme de données rassemblées. *
* *
@@ -439,3 +471,32 @@ bool g_object_storage_store_object(GObjectStorage *storage, const char *name, co
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : storage = gestionnaire à manipuler. *
+* name = désignation d'un nouveau groupe d'objets. *
+* pbuf = zone tampon à remplir. *
+* *
+* Description : Sauvegarde un object interne sous forme de données. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_object_storage_pack_object(GObjectStorage *storage, const char *name, const GSerializableObject *object, packed_buffer *pbuf)
+{
+ bool result; /* Bilan à retourner */
+ off64_t pos; /* Localisation des données */
+
+ result = g_object_storage_store_object(storage, name, object, &pos);
+
+ if (result)
+ result = extend_packed_buffer(pbuf, (uint64_t []){ pos }, sizeof(uint64_t), true);
+
+ return result;
+
+}
diff --git a/src/analysis/storage/storage.h b/src/analysis/storage/storage.h
index 611e49e..c568267 100644
--- a/src/analysis/storage/storage.h
+++ b/src/analysis/storage/storage.h
@@ -62,9 +62,15 @@ bool g_object_storage_add_backend(GObjectStorage *, const char *, const char *);
/* Charge un objet à partir de données rassemblées. */
GSerializableObject *g_object_storage_load_object(GObjectStorage *, const char *, off64_t);
+/* Charge un objet interne à partir de données rassemblées. */
+GSerializableObject *g_object_storage_unpack_object(GObjectStorage *, const char *, packed_buffer *);
+
/* Sauvegarde un object sous forme de données rassemblées. */
bool g_object_storage_store_object(GObjectStorage *, const char *, const GSerializableObject *, off64_t *);
+/* Sauvegarde un object interne sous forme de données. */
+bool g_object_storage_pack_object(GObjectStorage *, const char *, const GSerializableObject *, packed_buffer *);
+
#endif /* _ANALYSIS_STORAGE_STORAGE_H */
diff --git a/src/analysis/type.c b/src/analysis/type.c
index 4a0b7d8..e2547bd 100644
--- a/src/analysis/type.c
+++ b/src/analysis/type.c
@@ -215,8 +215,7 @@ static bool _g_data_type_load(GDataType *type, GObjectStorage *storage, packed_b
if (ns_sep[0] != '\0')
{
- //result = g_data_type_load(type->namespace, storage, pbuf); // TODO
- namespace = NULL;
+ namespace = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
result = (namespace != NULL);
if (!result) goto exit;
@@ -299,7 +298,7 @@ static bool _g_data_type_store(const GDataType *type, GObjectStorage *storage, p
{
assert(type->namespace != NULL);
- result = g_data_type_store(type->namespace, storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->namespace), pbuf);
if (!result) goto unlocking_exit;
}
diff --git a/src/analysis/types/array.c b/src/analysis/types/array.c
index b8321a2..5b51d62 100644
--- a/src/analysis/types/array.c
+++ b/src/analysis/types/array.c
@@ -162,8 +162,7 @@ static void g_array_type_init(GArrayType *type)
static void g_array_type_dispose(GArrayType *type)
{
- if (type->members != NULL)
- g_object_unref(G_OBJECT(type->members));
+ g_clear_object(&type->members);
G_OBJECT_CLASS(g_array_type_parent_class)->dispose(G_OBJECT(type));
@@ -265,7 +264,8 @@ static bool g_array_type_load(GArrayType *type, GObjectStorage *storage, packed_
}
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->members), storage, pbuf);
+ type->members = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+ result = (type->members != NULL);
exit:
@@ -317,7 +317,7 @@ static bool g_array_type_store(const GArrayType *type, GObjectStorage *storage,
}
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->members), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->members), pbuf);
exit:
diff --git a/src/analysis/types/encaps.c b/src/analysis/types/encaps.c
index bfb4e57..8d0d7eb 100644
--- a/src/analysis/types/encaps.c
+++ b/src/analysis/types/encaps.c
@@ -165,8 +165,7 @@ static void g_encapsulated_type_init(GEncapsulatedType *type)
static void g_encapsulated_type_dispose(GEncapsulatedType *type)
{
- if (type->child != NULL)
- g_object_unref(G_OBJECT(type->child));
+ g_clear_object(&type->child);
G_OBJECT_CLASS(g_encapsulated_type_parent_class)->dispose(G_OBJECT(type));
@@ -246,7 +245,8 @@ static bool g_encapsulated_type_load(GEncapsulatedType *type, GObjectStorage *st
type->type = value;
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->child), storage, pbuf);
+ type->child = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+ result = (type->child != NULL);
if (!result) goto exit;
result = unpack_uleb128(&value, pbuf);
@@ -285,7 +285,7 @@ static bool g_encapsulated_type_store(const GEncapsulatedType *type, GObjectStor
result = pack_uleb128((uleb128_t []){ g_encapsulated_type_get_etype(type) }, pbuf);
if (!result) goto exit;
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->child), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->child), pbuf);
if (!result) goto exit;
result = pack_uleb128((uleb128_t []){ type->dimension }, pbuf);
diff --git a/src/analysis/types/literal.c b/src/analysis/types/literal.c
index 2a4aa45..4529411 100644
--- a/src/analysis/types/literal.c
+++ b/src/analysis/types/literal.c
@@ -152,8 +152,7 @@ static void g_literal_type_init(GLiteralType *type)
static void g_literal_type_dispose(GLiteralType *type)
{
- if (type->orig != NULL)
- g_object_unref(G_OBJECT(type->orig));
+ g_clear_object(&type->orig);
G_OBJECT_CLASS(g_literal_type_parent_class)->dispose(G_OBJECT(type));
@@ -234,7 +233,8 @@ static bool g_literal_type_load(GLiteralType *type, GObjectStorage *storage, pac
result = G_DATA_TYPE_CLASS(g_literal_type_parent_class)->load(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->orig), storage, pbuf);
+ type->orig = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+ result = (type->orig != NULL);
if (!result) goto exit;
if (g_basic_type_get_base(G_BASIC_TYPE(type->orig)) == BTP_FLOAT)
@@ -270,7 +270,7 @@ static bool g_literal_type_store(const GLiteralType *type, GObjectStorage *stora
result = G_DATA_TYPE_CLASS(g_literal_type_parent_class)->store(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->orig), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->orig), pbuf);
if (!result) goto exit;
if (g_basic_type_get_base(G_BASIC_TYPE(type->orig)) == BTP_FLOAT)
diff --git a/src/analysis/types/override.c b/src/analysis/types/override.c
index 2beb934..6e48af4 100644
--- a/src/analysis/types/override.c
+++ b/src/analysis/types/override.c
@@ -155,8 +155,7 @@ static void g_override_type_init(GOverrideType *type)
static void g_override_type_dispose(GOverrideType *type)
{
- if (type->base != NULL)
- g_object_unref(G_OBJECT(type->base));
+ g_clear_object(&type->base);
G_OBJECT_CLASS(g_override_type_parent_class)->dispose(G_OBJECT(type));
@@ -265,7 +264,8 @@ static bool g_override_type_load(GOverrideType *type, GObjectStorage *storage, p
result = G_DATA_TYPE_CLASS(g_override_type_parent_class)->load(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->base), storage, pbuf);
+ type->base = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+ result = (type->base != NULL);
if (!result) goto exit;
for (i = 0; i < 2; i++)
@@ -324,7 +324,7 @@ static bool g_override_type_store(const GOverrideType *type, GObjectStorage *sto
result = G_DATA_TYPE_CLASS(g_override_type_parent_class)->store(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->base), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->base), pbuf);
if (!result) goto exit;
for (i = 0; i < 2; i++)
diff --git a/src/analysis/types/proto.c b/src/analysis/types/proto.c
index 4df0552..e851000 100644
--- a/src/analysis/types/proto.c
+++ b/src/analysis/types/proto.c
@@ -164,11 +164,10 @@ static void g_proto_type_dispose(GProtoType *type)
{
size_t i; /* Boucle de parcours */
- if (type->ret_type != NULL)
- g_object_unref(G_OBJECT(type->ret_type));
+ g_clear_object(&type->ret_type);
for (i = 0; i < type->count; i++)
- g_object_unref(G_OBJECT(type->args[i]));
+ g_clear_object(&type->args[i]);
G_OBJECT_CLASS(g_proto_type_parent_class)->dispose(G_OBJECT(type));
@@ -243,7 +242,8 @@ static bool g_proto_type_load(GProtoType *type, GObjectStorage *storage, packed_
result = G_DATA_TYPE_CLASS(g_proto_type_parent_class)->load(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->ret_type), storage, pbuf);
+ type->ret_type = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+ result = (type->ret_type != NULL);
if (!result) goto exit;
result = unpack_uleb128(&value, pbuf);
@@ -255,11 +255,15 @@ static bool g_proto_type_load(GProtoType *type, GObjectStorage *storage, packed_
for (i = 0; i < type->count; i++)
{
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->args[i]), storage, pbuf);
- if (!result) goto exit;
+ type->args[i] = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+
+ if (type->args[i] == NULL)
+ break;
}
+ result = (i == type->count);
+
exit:
return result;
@@ -289,7 +293,7 @@ static bool g_proto_type_store(const GProtoType *type, GObjectStorage *storage,
result = G_DATA_TYPE_CLASS(g_proto_type_parent_class)->store(G_DATA_TYPE(type), storage, pbuf);
if (!result) goto exit;
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->ret_type), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->ret_type), pbuf);
if (!result) goto exit;
result = pack_uleb128((uleb128_t []){ type->count }, pbuf);
@@ -297,9 +301,8 @@ static bool g_proto_type_store(const GProtoType *type, GObjectStorage *storage,
for (i = 0; i < type->count; i++)
{
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->args[i]), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->args[i]), pbuf);
if (!result) goto exit;
-
}
exit:
diff --git a/src/analysis/types/template.c b/src/analysis/types/template.c
index 05f7a2f..98c1471 100644
--- a/src/analysis/types/template.c
+++ b/src/analysis/types/template.c
@@ -160,7 +160,7 @@ static void g_template_type_dispose(GTemplateType *type)
size_t i; /* Boucle de parcours */
for (i = 0; i < type->count; i++)
- g_object_unref(G_OBJECT(type->params[i]));
+ g_clear_object(&type->params[i]);
G_OBJECT_CLASS(g_template_type_parent_class)->dispose(G_OBJECT(type));
@@ -253,11 +253,15 @@ static bool g_template_type_load(GTemplateType *type, GObjectStorage *storage, p
for (i = 0; i < type->count; i++)
{
- result = g_serializable_object_load(G_SERIALIZABLE_OBJECT(type->params[i]), storage, pbuf);
- if (!result) goto exit;
+ type->params[i] = G_DATA_TYPE(g_object_storage_unpack_object(storage, "types", pbuf));
+
+ if (type->params[i] == NULL)
+ break;
}
+ result = (i == type->count);
+
exit:
return result;
@@ -301,9 +305,8 @@ static bool g_template_type_store(const GTemplateType *type, GObjectStorage *sto
for (i = 0; i < type->count; i++)
{
- result = g_serializable_object_store(G_SERIALIZABLE_OBJECT(type->params[i]), storage, pbuf);
+ result = g_object_storage_pack_object(storage, "types", G_SERIALIZABLE_OBJECT(type->params[i]), pbuf);
if (!result) goto exit;
-
}
exit: