diff options
Diffstat (limited to 'src/analysis/types/expr.c')
-rw-r--r-- | src/analysis/types/expr.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/analysis/types/expr.c b/src/analysis/types/expr.c index 1119ab6..a98e039 100644 --- a/src/analysis/types/expr.c +++ b/src/analysis/types/expr.c @@ -61,6 +61,12 @@ static void g_expr_type_dispose(GExprType *); /* Procède à la libération totale de la mémoire. */ static void g_expr_type_finalize(GExprType *); +/* Charge un objet depuis une mémoire tampon. */ +static bool g_expr_type_load(GExprType *, GObjectStorage *, packed_buffer *); + +/* Sauvegarde un objet dans une mémoire tampon. */ +static bool g_expr_type_store(const GExprType *, GObjectStorage *, packed_buffer *); + /* Calcule une empreinte pour un type de données. */ static guint g_expr_type_hash(const GExprType *); @@ -100,6 +106,9 @@ static void g_expr_type_class_init(GExprTypeClass *klass) type = G_DATA_TYPE_CLASS(klass); + type->load = (type_load_fc)g_expr_type_load; + type->store = (type_store_fc)g_expr_type_store; + type->hash = (type_hash_fc)g_expr_type_hash; type->dup = (type_dup_fc)g_expr_type_dup; type->to_string = (type_to_string_fc)g_expr_type_to_string; @@ -194,6 +203,78 @@ GDataType *g_expr_type_new(const char *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_expr_type_load(GExprType *type, GObjectStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + uleb128_t value; /* Valeur ULEB128 à charger */ + + result = G_DATA_TYPE_CLASS(g_expr_type_parent_class)->load(G_DATA_TYPE(type), storage, pbuf); + if (!result) goto exit; + + result = unpack_uleb128(&value, pbuf); + if (!result) goto exit; + + type->value = calloc(value, sizeof(char)); + result = extract_packed_buffer(pbuf, type->value, value, false); + + 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_expr_type_store(const GExprType *type, GObjectStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + size_t len; /* Taille d'une chaîne */ + + result = G_DATA_TYPE_CLASS(g_expr_type_parent_class)->store(G_DATA_TYPE(type), storage, pbuf); + if (!result) goto exit; + + len = strlen(type->value); + + result = pack_uleb128((uleb128_t []){ len }, pbuf); + if (!result) goto exit; + + result = extend_packed_buffer(pbuf, type->value, len, false); + if (!result) goto exit; + + exit: + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : type = type à consulter. * * * * Description : Calcule une empreinte pour un type de données. * |