diff options
Diffstat (limited to 'src/analysis/types/array.c')
-rw-r--r-- | src/analysis/types/array.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/analysis/types/array.c b/src/analysis/types/array.c index 5aea07b..5ea4179 100644 --- a/src/analysis/types/array.c +++ b/src/analysis/types/array.c @@ -72,6 +72,9 @@ static void g_array_type_dispose(GArrayType *); /* Procède à la libération totale de la mémoire. */ static void g_array_type_finalize(GArrayType *); +/* Calcule une empreinte pour un type de données. */ +static guint g_array_type_hash(const GArrayType *); + /* Crée un copie d'un type existant. */ static GDataType *g_array_type_dup(const GArrayType *); @@ -108,6 +111,7 @@ static void g_array_type_class_init(GArrayTypeClass *klass) type = G_DATA_TYPE_CLASS(klass); + type->hash = (type_hash_fc)g_array_type_hash; type->dup = (type_dup_fc)g_array_type_dup; type->to_string = (type_to_string_fc)g_array_type_to_string; @@ -206,6 +210,34 @@ GDataType *g_array_type_new(GDataType *members) /****************************************************************************** * * +* 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_array_type_hash(const GArrayType *type) +{ + guint result; /* Empreinte à renvoyer */ + + if (type->numbered) + result = g_int_hash((gint []){ type->dim_number }); + else + result = g_str_hash(type->dim_expr); + + result ^= g_data_type_hash(type->members); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : type = type à dupliquer. * * * * Description : Crée un copie d'un type existant. * |