diff options
Diffstat (limited to 'src/analysis/types/basic.c')
-rw-r--r-- | src/analysis/types/basic.c | 118 |
1 files changed, 69 insertions, 49 deletions
diff --git a/src/analysis/types/basic.c b/src/analysis/types/basic.c index 9e0239a..4ac7f2a 100644 --- a/src/analysis/types/basic.c +++ b/src/analysis/types/basic.c @@ -24,7 +24,7 @@ #include "basic.h" -#include <malloc.h> +#include <assert.h> #include <string.h> @@ -55,14 +55,17 @@ static void g_basic_type_class_init(GBasicTypeClass *); /* Initialise l'instance d'un type basique. */ static void g_basic_type_init(GBasicType *); +/* Supprime toutes les références externes. */ +static void g_basic_type_dispose(GBasicType *); + +/* Procède à la libération totale de la mémoire. */ +static void g_basic_type_finalize(GBasicType *); + /* Crée un copie d'un type existant. */ static GDataType *g_basic_type_dup(const GBasicType *); /* Décrit le type fourni sous forme de caractères. */ -static char *g_basic_type_to_string(const GBasicType *); - -/* Procède à l'impression de la description d'un type. */ -//static void g_basic_type_output(const GBasicType *, GLangOutput *, GBufferLine *, bool, bool); +static char *g_basic_type_to_string(const GBasicType *, bool); @@ -84,6 +87,18 @@ G_DEFINE_TYPE(GBasicType, g_basic_type, G_TYPE_DATA_TYPE); static void g_basic_type_class_init(GBasicTypeClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GDataTypeClass *type; /* Version parente et basique */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_basic_type_dispose; + object->finalize = (GObjectFinalizeFunc)g_basic_type_finalize; + + type = G_DATA_TYPE_CLASS(klass); + + type->dup = (type_dup_fc)g_basic_type_dup; + type->to_string = (type_to_string_fc)g_basic_type_to_string; } @@ -102,13 +117,45 @@ static void g_basic_type_class_init(GBasicTypeClass *klass) static void g_basic_type_init(GBasicType *type) { - GDataType *data_type; /* Version basique */ + type->type = BTP_INVALID; - data_type = G_DATA_TYPE(type); +} + + +/****************************************************************************** +* * +* Paramètres : type = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_basic_type_dispose(GBasicType *type) +{ + G_OBJECT_CLASS(g_basic_type_parent_class)->dispose(G_OBJECT(type)); + +} + + +/****************************************************************************** +* * +* Paramètres : type = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ - data_type->dup = (type_dup_fc)g_basic_type_dup; - data_type->to_string = (type_to_string_fc)g_basic_type_to_string; - //data_type->output = (output_type_fc)g_basic_type_output; +static void g_basic_type_finalize(GBasicType *type) +{ + G_OBJECT_CLASS(g_basic_type_parent_class)->finalize(G_OBJECT(type)); } @@ -152,14 +199,19 @@ GDataType *g_basic_type_new(BaseType type) static GDataType *g_basic_type_dup(const GBasicType *type) { - return g_basic_type_new(type->type); + GDataType *result; /* Copie à retourner */ + + result = g_basic_type_new(type->type); + + return result; } /****************************************************************************** * * -* Paramètres : type = type à convertir. * +* Paramètres : type = type à convertir. * +* include = doit-on inclure les espaces de noms ? * * * * Description : Décrit le type fourni sous forme de caractères. * * * @@ -169,7 +221,7 @@ static GDataType *g_basic_type_dup(const GBasicType *type) * * ******************************************************************************/ -static char *g_basic_type_to_string(const GBasicType *type) +static char *g_basic_type_to_string(const GBasicType *type, bool include) { const char *desc; /* Représentation à copier */ @@ -284,47 +336,15 @@ static char *g_basic_type_to_string(const GBasicType *type) break; default: - case BTP_OTHER: - desc = "user"; + assert(false); + desc = NULL; break; } - return strdup(desc); - -} - - -/****************************************************************************** -* * -* Paramètres : type = type à afficher. * -* lang = langage à utiliser pour la sortie humaine. * -* buffer = tampon mis à disposition pour la sortie. * -* info = nature du cadre de destination. * -* full = besoin de descriptions étendues ? * -* * -* Description : Procède à l'impression de la description d'un type. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ -#if 0 -static void g_basic_type_output(const GBasicType *type, GLangOutput *lang, GBufferLine *line, bool info, bool full) -{ - char *text; /* Version humaine à imprimer */ - size_t len; /* Taille de cette version */ - - text = g_basic_type_to_string(type); - len = strlen(text); - - g_buffer_line_append_text(line, BLC_LAST_USED, text, len, info ? RTT_COMMENT : RTT_RAW, NULL); - - free(text); + return (desc != NULL ? strdup(desc) : NULL); } -#endif /****************************************************************************** @@ -339,7 +359,7 @@ static void g_basic_type_output(const GBasicType *type, GLangOutput *lang, GBuff * * ******************************************************************************/ -BaseType g_basic_type_get_btype(const GBasicType *type) +BaseType g_basic_type_get_base_type(const GBasicType *type) { return type->type; |