diff options
Diffstat (limited to 'src/analysis/types/literal.c')
-rw-r--r-- | src/analysis/types/literal.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/analysis/types/literal.c b/src/analysis/types/literal.c index addab5a..2a4aa45 100644 --- a/src/analysis/types/literal.c +++ b/src/analysis/types/literal.c @@ -64,6 +64,12 @@ static void g_literal_type_dispose(GLiteralType *); /* Procède à la libération totale de la mémoire. */ static void g_literal_type_finalize(GLiteralType *); +/* Charge un objet depuis une mémoire tampon. */ +static bool g_literal_type_load(GLiteralType *, GObjectStorage *, packed_buffer *); + +/* Sauvegarde un objet dans une mémoire tampon. */ +static bool g_literal_type_store(const GLiteralType *, GObjectStorage *, packed_buffer *); + /* Calcule une empreinte pour un type de données. */ static guint g_literal_type_hash(const GLiteralType *); @@ -103,6 +109,9 @@ static void g_literal_type_class_init(GLiteralTypeClass *klass) type = G_DATA_TYPE_CLASS(klass); + type->load = (type_load_fc)g_literal_type_load; + type->store = (type_store_fc)g_literal_type_store; + type->hash = (type_hash_fc)g_literal_type_hash; type->dup = (type_dup_fc)g_literal_type_dup; type->to_string = (type_to_string_fc)g_literal_type_to_string; @@ -206,6 +215,78 @@ GDataType *g_literal_type_new(GDataType *orig, const literal_value *value) /****************************************************************************** * * +* Paramètres : type = type de données à constuire. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* * +* Description : Charge un objet depuis une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_literal_type_load(GLiteralType *type, GObjectStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + + 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); + if (!result) goto exit; + + if (g_basic_type_get_base(G_BASIC_TYPE(type->orig)) == BTP_FLOAT) + result = extract_packed_buffer(pbuf, (uint64_t *)&type->value.float_val, sizeof(uint64_t), true); + else + result = extract_packed_buffer(pbuf, (uint32_t *)&type->value.int_val, sizeof(uint32_t), true); + + exit: + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : type = type de données à consulter. * +* storage = conservateur de données à manipuler ou NULL. * +* pbuf = zone tampon à remplir. * +* * +* Description : Sauvegarde un objet dans une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_literal_type_store(const GLiteralType *type, GObjectStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + + 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); + if (!result) goto exit; + + if (g_basic_type_get_base(G_BASIC_TYPE(type->orig)) == BTP_FLOAT) + result = extend_packed_buffer(pbuf, (uint64_t []){ type->value.float_val }, sizeof(uint64_t), true); + else + result = extend_packed_buffer(pbuf, (uint32_t []){ type->value.int_val }, sizeof(uint32_t), true); + + exit: + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : type = type à consulter. * * * * Description : Calcule une empreinte pour un type de données. * |