summaryrefslogtreecommitdiff
path: root/src/analysis/type.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-02-20 00:26:09 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-02-20 00:26:09 (GMT)
commit66b8d57f0c054065894ab3dd0f1640594013e441 (patch)
treea31cb44088c67d6fe9ee7aa36c67261a6cbd14b4 /src/analysis/type.c
parent9ac491cba6aa35959fa1ffdb9ce979060f5f6b26 (diff)
Compute a hash value for data types.
Diffstat (limited to 'src/analysis/type.c')
-rw-r--r--src/analysis/type.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/analysis/type.c b/src/analysis/type.c
index 9a8e85b..350b4e2 100644
--- a/src/analysis/type.c
+++ b/src/analysis/type.c
@@ -138,6 +138,37 @@ static void g_data_type_finalize(GDataType *type)
/******************************************************************************
* *
+* 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 : - *
+* *
+******************************************************************************/
+
+guint g_data_type_hash(const GDataType *type)
+{
+ guint result; /* Empreinte à renvoyer */
+ GDataTypeClass *class; /* Classe du type */
+
+ class = G_DATA_TYPE_GET_CLASS(type);
+
+ result = class->hash(type);
+
+ result ^= g_int_hash((gint []){ g_data_type_get_qualifiers(type) });
+
+ if (type->namespace != NULL)
+ result ^= g_data_type_hash(type->namespace);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type à dupliquer. *
* *
* Description : Crée un copie d'un type existant. *