diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2014-11-24 21:12:48 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2014-11-24 21:12:48 (GMT) |
commit | 16f9d3b943e272112e01f5bc51e922e2ea2ddfb8 (patch) | |
tree | 293ed29545a7e097d3b70d3d95d513fc25866fd1 /src/arch/register.c | |
parent | 532fc81565104f64b33b3ac94dfcf0762209f751 (diff) |
Cleaned operands, using class functions and destructors.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@426 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/register.c')
-rw-r--r-- | src/arch/register.c | 110 |
1 files changed, 105 insertions, 5 deletions
diff --git a/src/arch/register.c b/src/arch/register.c index 706fcd4..3094e0f 100644 --- a/src/arch/register.c +++ b/src/arch/register.c @@ -37,6 +37,12 @@ static void g_arch_register_class_init(GArchRegisterClass *); /* Initialise une instance de registre. */ static void g_arch_register_init(GArchRegister *); +/* Supprime toutes les références externes. */ +static void g_arch_register_dispose(GArchRegister *); + +/* Procède à la libération totale de la mémoire. */ +static void g_arch_register_finalize(GArchRegister *); + /* ------------------------- REGISTRE SOUS FORME D'OPERANDE ------------------------- */ @@ -48,6 +54,12 @@ static void g_register_operand_class_init(GRegisterOperandClass *); /* Initialise une instance d'opérande de registre. */ static void g_register_operand_init(GRegisterOperand *); +/* Supprime toutes les références externes. */ +static void g_register_operand_dispose(GRegisterOperand *); + +/* Procède à la libération totale de la mémoire. */ +static void g_register_operand_finalize(GRegisterOperand *); + /* Compare un opérande avec un autre. */ static bool g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *); @@ -79,6 +91,12 @@ G_DEFINE_TYPE(GArchRegister, g_arch_register, G_TYPE_OBJECT); static void g_arch_register_class_init(GArchRegisterClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_arch_register_dispose; + object->finalize = (GObjectFinalizeFunc)g_arch_register_finalize; } @@ -103,6 +121,44 @@ static void g_arch_register_init(GArchRegister *reg) /****************************************************************************** * * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_register_dispose(GArchRegister *reg) +{ + G_OBJECT_CLASS(g_arch_register_parent_class)->dispose(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_register_finalize(GArchRegister *reg) +{ + G_OBJECT_CLASS(g_arch_register_parent_class)->finalize(G_OBJECT(reg)); + +} + + +/****************************************************************************** +* * * Paramètres : reg = opérande à consulter pour le calcul. * * * * Description : Produit une empreinte à partir d'un registre. * @@ -261,6 +317,17 @@ G_DEFINE_TYPE(GRegisterOperand, g_register_operand, G_TYPE_ARCH_OPERAND); static void g_register_operand_class_init(GRegisterOperandClass *klass) { + GObjectClass *object; /* Autre version de la classe */ + GArchOperandClass *operand; /* Version de classe parente */ + + object = G_OBJECT_CLASS(klass); + operand = G_ARCH_OPERAND_CLASS(klass); + + object->dispose = (GObjectFinalizeFunc/* ! */)g_register_operand_dispose; + object->finalize = (GObjectFinalizeFunc)g_register_operand_finalize; + + operand->compare = (operand_compare_fc)g_register_operand_compare; + operand->print = (operand_print_fc)g_register_operand_print; } @@ -279,14 +346,47 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass) static void g_register_operand_init(GRegisterOperand *operand) { - GArchOperand *parent; /* Instance parente */ + operand->is_written = false; - parent = G_ARCH_OPERAND(operand); +} - parent->compare = (operand_compare_fc)g_register_operand_compare; - parent->print = (operand_print_fc)g_register_operand_print; - operand->is_written = false; +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_register_operand_dispose(GRegisterOperand *operand) +{ + g_object_unref(G_OBJECT(operand->reg)); + + G_OBJECT_CLASS(g_register_operand_parent_class)->dispose(G_OBJECT(operand)); + +} + + +/****************************************************************************** +* * +* Paramètres : binary = instance d'objet GLib à traiter. * +* * +* Description : Procède à la libération totale de la mémoire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_register_operand_finalize(GRegisterOperand *operand) +{ + G_OBJECT_CLASS(g_register_operand_parent_class)->finalize(G_OBJECT(operand)); } |