diff options
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/strsym.c | 172 | 
1 files changed, 167 insertions, 5 deletions
| diff --git a/src/format/strsym.c b/src/format/strsym.c index 073e77f..d09995d 100644 --- a/src/format/strsym.c +++ b/src/format/strsym.c @@ -31,6 +31,7 @@  #include "symbol-int.h" +#include "../arch/feeder-int.h"  #include "../common/alloc.h" @@ -70,6 +71,9 @@ static void g_string_symbol_class_init(GStrSymbolClass *);  /* Initialise une instance de chaîne de caractères. */  static void g_string_symbol_init(GStrSymbol *); +/* Procède à l'initialisation de l'interface de fourniture. */ +static void g_string_symbol_feeder_interface_init(GProxyFeederInterface *); +  /* Supprime toutes les références externes. */  static void g_string_symbol_dispose(GStrSymbol *); @@ -81,17 +85,31 @@ static void g_string_symbol_check_encoding(GStrSymbol *); +/* ------------------------- FONCTIONNALITES DE FOURNITURES ------------------------- */ + + +/* Compare un fournisseur avec un autre. */ +int g_string_symbol_compare(const GStrSymbol *, const GStrSymbol *); + +/* Traduit un fournisseur en version humainement lisible. */ +void g_string_symbol_print(const GStrSymbol *, GBufferLine *); + +/* Charge un fournisseur depuis une mémoire tampon. */ +bool g_string_symbol_unserialize(GStrSymbol *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un fournisseur dans une mémoire tampon. */ +bool g_string_symbol_serialize(const GStrSymbol *, packed_buffer *); + + +  /* ---------------------------------------------------------------------------------- */  /*                         VITRINE POUR CHAINES DE CARACTERES                         */  /* ---------------------------------------------------------------------------------- */  /* Indique le type défini pour un symbole d'exécutable. */ -/* -G_DEFINE_TYPE_WITH_CODE(GStrSymbol, g_string_symbol, G_TYPE_OBJECT, -                        G_IMPLEMENT_INTERFACE(G_TYPE_LINE_GENERATOR, g_string_symbol_interface_init)); -*/ -G_DEFINE_TYPE(GStrSymbol, g_string_symbol, G_TYPE_BIN_SYMBOL); +G_DEFINE_TYPE_WITH_CODE(GStrSymbol, g_string_symbol, G_TYPE_BIN_SYMBOL, +                        G_IMPLEMENT_INTERFACE(G_TYPE_PROXY_FEEDER, g_string_symbol_feeder_interface_init));  /****************************************************************************** @@ -138,6 +156,30 @@ static void g_string_symbol_init(GStrSymbol *symbol)  /******************************************************************************  *                                                                             * +*  Paramètres  : iface = interface GLib à initialiser.                        * +*                                                                             * +*  Description : Procède à l'initialisation de l'interface de fourniture.     * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +static void g_string_symbol_feeder_interface_init(GProxyFeederInterface *iface) +{ +    iface->compare = (compare_proxy_operand_fc)g_string_symbol_compare; + +    iface->print = (print_proxy_feeder_fc)g_string_symbol_print; + +    iface->unserialize = (unserialize_proxy_feeder_fc)g_string_symbol_unserialize; +    iface->serialize = (serialize_proxy_feeder_fc)g_string_symbol_serialize; + +} + + +/****************************************************************************** +*                                                                             *  *  Paramètres  : symbol = instance d'objet GLib à traiter.                    *  *                                                                             *  *  Description : Supprime toutes les références externes.                     * @@ -555,3 +597,123 @@ bool g_string_symbol_build_label(GStrSymbol *symbol, GBinFormat *format)      return true;  } + + + +/* ---------------------------------------------------------------------------------- */ +/*                           FONCTIONNALITES DE FOURNITURES                           */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : a = premier fournisseur à consulter.                         * +*                b = second fournisseur à consulter.                          * +*                                                                             * +*  Description : Compare un fournisseur avec un autre.                        * +*                                                                             * +*  Retour      : Bilan de la comparaison.                                     * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +int g_string_symbol_compare(const GStrSymbol *a, const GStrSymbol *b) +{ +    int result;                             /* Bilan à retourner           */ +    GBinSymbol *sa;                         /* Version parente pour A      */ +    GBinSymbol *sb;                         /* Version parente pour B      */ + +    sa = G_BIN_SYMBOL(a); +    sb = G_BIN_SYMBOL(b); + +    result = g_binary_symbol_cmp((const GBinSymbol * const *)&sa, (const GBinSymbol * const *)&sb); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol = fournisseur à traiter.                              * +*                line   = ligne tampon où imprimer l'élément donné.           * +*                                                                             * +*  Description : Traduit un fournisseur en version humainement lisible.       * +*                                                                             * +*  Retour      : -                                                            * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +void g_string_symbol_print(const GStrSymbol *symbol, GBufferLine *line) +{ +    const char *string;                     /* Chaîne de caractères        */ +    size_t len;                             /* Taille du texte à créer     */ + +    string = g_string_symbol_get_utf8(symbol); + +    g_buffer_line_append_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING, NULL); + +    len = strlen(string); + +    if (len > 0) +        g_buffer_line_append_text(line, BLC_ASSEMBLY, string, len, RTT_STRING, NULL); + +    g_buffer_line_append_text(line, BLC_ASSEMBLY, "\"", 1, RTT_STRING, NULL); + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol = fournisseur à constituer.                           * +*                format = format binaire chargé associé à l'architecture.     * +*                pbuf   = zone tampon à remplir.                              * +*                                                                             * +*  Description : Charge un fournisseur depuis une mémoire tampon.             * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_string_symbol_unserialize(GStrSymbol *symbol, GBinFormat *format, packed_buffer *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    vmpa2t addr;                            /* Adresse à cibler            */ + +    result = unpack_vmpa(&addr, pbuf); + +    return result; + +} + + +/****************************************************************************** +*                                                                             * +*  Paramètres  : symbol = fournisseur à consulter.                            * +*                pbuf   = zone tampon à remplir.                              * +*                                                                             * +*  Description : Sauvegarde un fournisseur dans une mémoire tampon.           * +*                                                                             * +*  Retour      : Bilan de l'opération.                                        * +*                                                                             * +*  Remarques   : -                                                            * +*                                                                             * +******************************************************************************/ + +bool g_string_symbol_serialize(const GStrSymbol *symbol, packed_buffer *pbuf) +{ +    bool result;                            /* Bilan à retourner           */ +    const mrange_t *range;                  /* Emplacement du symbole      */ + +    range = g_binary_symbol_get_range(G_BIN_SYMBOL(symbol)); + +    result = pack_vmpa(get_mrange_addr(range), pbuf); + +    return result; + +} | 
