diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-08-30 10:55:45 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-08-30 10:55:45 (GMT) |
commit | ac447bc36e65b91f97434cf2613ccb1e768267e0 (patch) | |
tree | 471f3b49629269d7ea44a6ea8b9177fe7e437817 /src/arch/instruction.c | |
parent | 184249f07fb32fb2449723f5f94ce221015231b7 (diff) |
Rendered using the GTK buffer (crappy version).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@107 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/arch/instruction.c')
-rw-r--r-- | src/arch/instruction.c | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/src/arch/instruction.c b/src/arch/instruction.c index 338f496..8bc317b 100644 --- a/src/arch/instruction.c +++ b/src/arch/instruction.c @@ -38,10 +38,13 @@ static void g_arch_instruction_class_init(GArchInstructionClass *); /* Initialise une instance d'opérande d'architecture. */ static void g_arch_instruction_init(GArchInstruction *); +/* Ajoute à un texte GTK le contenu d'une instruction. */ +static void g_arch_instruction_add_to_gtk_buffer(const GArchInstruction *, const GExeFormat *, AsmSyntax, GtkTextBuffer *, GtkTextIter *); + /* Indique le type défini pour une instruction d'architecture. */ -G_DEFINE_TYPE(GArchInstruction, g_arch_instruction, G_TYPE_OBJECT); +G_DEFINE_TYPE(GArchInstruction, g_arch_instruction, G_TYPE_CONTENT_EXPORTER); /****************************************************************************** @@ -76,6 +79,65 @@ static void g_arch_instruction_class_init(GArchInstructionClass *klass) static void g_arch_instruction_init(GArchInstruction *instr) { + GContentExporter *parent; /* Instance parente */ + + parent = G_CONTENT_EXPORTER(instr); + + parent->add_arch_to_gtk_buffer = (add_arch_to_gtk_buffer_fc)g_arch_instruction_add_to_gtk_buffer; + +} + + +/****************************************************************************** +* * +* Paramètres : instr = instruction à transcrire. * +* format = format du binaire manipulé. * +* syntax = type de représentation demandée. * +* buffer = zone de texte à venir compléter. * +* iter = point d'insertion du nouveau texte. * +* * +* Description : Ajoute à un texte GTK le contenu d'une instruction. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_arch_instruction_add_to_gtk_buffer(const GArchInstruction *instr, const GExeFormat *format, AsmSyntax syntax, GtkTextBuffer *buffer, GtkTextIter *iter) +{ + const char *key; /* Mot clef principal */ + size_t klen; /* Taille de ce mot clef */ + size_t i; /* Boucle de parcours */ + + key = instr->get_text(instr, format, syntax); + klen = strlen(key); + + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(instr), buffer, iter, + key, klen, RTT_INSTRUCTION); + + if (instr->operands_count > 0) + { + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(instr), buffer, iter, + "\t", 1, RTT_NONE); + + g_content_exporter_add_arch_to_gtk_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[0]), + format, syntax, buffer, iter); + + for (i = 1; i < instr->operands_count; i++) + { + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(instr), buffer, iter, + ",", 1, RTT_NONE/* FIXME */); + + g_content_exporter_insert_with_gtk_tag(G_CONTENT_EXPORTER(instr), buffer, iter, + " ", 1, RTT_NONE); + + g_content_exporter_add_arch_to_gtk_buffer(G_CONTENT_EXPORTER(G_ARCH_INSTRUCTION(instr)->operands[i]), + format, syntax, buffer, iter); + + } + + } } @@ -322,7 +384,7 @@ char *g_arch_instruction_get_text(const GArchInstruction *instr, const GExeForma char *result; /* Chaîne à retourner */ size_t i; /* Boucle de parcours */ char *opstr; /* Chaîne d'opérande */ - + return strdup(""); if (instr->operands_count == 0) result = strdup(instr->get_text(instr, format, syntax)); |