diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-02-20 00:26:09 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-02-20 00:26:09 (GMT) |
commit | 66b8d57f0c054065894ab3dd0f1640594013e441 (patch) | |
tree | a31cb44088c67d6fe9ee7aa36c67261a6cbd14b4 /src/analysis/types/encaps.c | |
parent | 9ac491cba6aa35959fa1ffdb9ce979060f5f6b26 (diff) |
Compute a hash value for data types.
Diffstat (limited to 'src/analysis/types/encaps.c')
-rw-r--r-- | src/analysis/types/encaps.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/analysis/types/encaps.c b/src/analysis/types/encaps.c index d59516d..8e2641f 100644 --- a/src/analysis/types/encaps.c +++ b/src/analysis/types/encaps.c @@ -65,6 +65,9 @@ static void g_encapsulated_type_dispose(GEncapsulatedType *); /* Procède à la libération totale de la mémoire. */ static void g_encapsulated_type_finalize(GEncapsulatedType *); +/* Calcule une empreinte pour un type de données. */ +static guint g_encapsulated_type_hash(const GEncapsulatedType *); + /* Crée un copie d'un type existant. */ static GDataType *g_encapsulated_type_dup(const GEncapsulatedType *); @@ -107,6 +110,7 @@ static void g_encapsulated_type_class_init(GEncapsulatedTypeClass *klass) type = G_DATA_TYPE_CLASS(klass); + type->hash = (type_hash_fc)g_encapsulated_type_hash; type->dup = (type_dup_fc)g_encapsulated_type_dup; type->to_string = (type_to_string_fc)g_encapsulated_type_to_string; @@ -208,6 +212,33 @@ GDataType *g_encapsulated_type_new(EncapsulationType type, GDataType *child) /****************************************************************************** * * +* Paramètres : type = type à consulter. * +* * +* Description : Calcule une empreinte pour un type de données. * +* * +* Retour : Valeur arbitraire sur 32 bits, idéalement unique par type. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static guint g_encapsulated_type_hash(const GEncapsulatedType *type) +{ + guint result; /* Empreinte à renvoyer */ + + result = g_int_hash((gint []){ g_encapsulated_type_get_etype(type) }); + + result ^= g_data_type_hash(type->child); + + result ^= g_int_hash((gint []){ g_encapsulated_type_get_dimension(type) }); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : type = type à dupliquer. * * * * Description : Crée un copie d'un type existant. * |