summaryrefslogtreecommitdiff
path: root/src/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-04-09 22:23:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-04-09 22:23:49 (GMT)
commit5de93a90f20b9ce35d4799d521029f2fde5c6441 (patch)
treebf6cfdafe6d6cef07b561821b5b35d69bff3c60e /src/format
parentee138199fe0d7bcc114cfb7001e968c4738a8ce5 (diff)
Created extra flags for binary symbols.
Diffstat (limited to 'src/format')
-rw-r--r--src/format/symbol-int.h1
-rw-r--r--src/format/symbol.c133
-rw-r--r--src/format/symbol.h23
3 files changed, 153 insertions, 4 deletions
diff --git a/src/format/symbol-int.h b/src/format/symbol-int.h
index e2c3292..77ffd39 100644
--- a/src/format/symbol-int.h
+++ b/src/format/symbol-int.h
@@ -41,6 +41,7 @@ typedef union _sym_obj_extra
{
SymbolType stype; /* Type du symbole */
SymbolStatus status; /* Visibilité du symbole */
+ SymbolFlag flags; /* Informations complémentaires*/
};
diff --git a/src/format/symbol.c b/src/format/symbol.c
index c10c46d..7d272ce 100644
--- a/src/format/symbol.c
+++ b/src/format/symbol.c
@@ -68,7 +68,7 @@ static void g_binary_symbol_compute_cursor(const GBinSymbol *, gint, size_t, siz
static int g_binary_symbol_contains_cursor(const GBinSymbol *, size_t, size_t, const GLineCursor *);
/* Renseigne sur les propriétés liées à un générateur. */
-static BufferLineFlags g_binary_symbol_get_flags(const GBinSymbol *, size_t, size_t);
+static BufferLineFlags g_binary_symbol_get_line_flags(const GBinSymbol *, size_t, size_t);
/* Imprime dans une ligne de rendu le contenu représenté. */
static void g_binary_symbol_print(GBinSymbol *, GBufferLine *, size_t, size_t, const GBinContent *);
@@ -149,7 +149,7 @@ static void g_binary_symbol_interface_init(GLineGeneratorInterface *iface)
iface->count = (linegen_count_lines_fc)g_binary_symbol_count_lines;
iface->compute = (linegen_compute_fc)g_binary_symbol_compute_cursor;
iface->contains = (linegen_contains_fc)g_binary_symbol_contains_cursor;
- iface->get_flags = (linegen_get_flags_fc)g_binary_symbol_get_flags;
+ iface->get_flags = (linegen_get_flags_fc)g_binary_symbol_get_line_flags;
iface->print = (linegen_print_fc)g_binary_symbol_print;
}
@@ -433,6 +433,133 @@ SymbolStatus g_binary_symbol_get_status(const GBinSymbol *symbol)
/******************************************************************************
* *
+* Paramètres : symbol = symbole à venir modifier. *
+* flag = drapeau d'information complémentaire à planter. *
+* *
+* Description : Ajoute une information complémentaire à un symbole. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_binary_symbol_set_flag(GBinSymbol *symbol, SymbolFlag flag)
+{
+ bool result; /* Bilan à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = !(extra->flags & flag);
+
+ extra->flags |= flag;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : symbol = symbole à venir modifier. *
+* flag = drapeau d'information complémentaire à planter. *
+* *
+* Description : Retire une information complémentaire à un symbole. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_binary_symbol_unset_flag(GBinSymbol *symbol, SymbolFlag flag)
+{
+ bool result; /* Bilan à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = (extra->flags & flag);
+
+ extra->flags &= ~flag;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : symbol = symbole à venir consulter. *
+* flag = drapeau d'information à rechercher. *
+* *
+* Description : Détermine si un symbole possède un fanion particulier. *
+* *
+* Retour : Bilan de la détection. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_binary_symbol_has_flag(const GBinSymbol *symbol, SymbolFlag flag)
+{
+ bool result; /* Bilan à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = (extra->flags & flag);
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : symbol = symbole à venir consulter. *
+* *
+* Description : Fournit les particularités du symbole. *
+* *
+* Retour : Somme de tous les fanions associés au symbole. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+SymbolFlag g_binary_symbol_get_flags(const GBinSymbol *symbol)
+{
+ SymbolFlag result; /* Fanions à retourner */
+ sym_obj_extra *extra; /* Données insérées à modifier */
+
+ extra = GET_BIN_SYMBOL_EXTRA(symbol);
+
+ g_bit_lock(&extra->lock, HOLE_LOCK_BIT);
+
+ result = extra->flags;
+
+ g_bit_unlock(&extra->lock, HOLE_LOCK_BIT);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : symbol = symbole à venir consulter. *
* *
* Description : Fournit une étiquette pour viser un symbole. *
@@ -626,7 +753,7 @@ static int g_binary_symbol_contains_cursor(const GBinSymbol *symbol, size_t inde
* *
******************************************************************************/
-static BufferLineFlags g_binary_symbol_get_flags(const GBinSymbol *symbol, size_t index, size_t repeat)
+static BufferLineFlags g_binary_symbol_get_line_flags(const GBinSymbol *symbol, size_t index, size_t repeat)
{
return BLF_IS_LABEL;
diff --git a/src/format/symbol.h b/src/format/symbol.h
index 48f740e..e304d69 100644
--- a/src/format/symbol.h
+++ b/src/format/symbol.h
@@ -50,7 +50,6 @@ typedef enum _SymbolType
} SymbolType;
-
/* Visibilité du symbole */
typedef enum _SymbolStatus
{
@@ -63,6 +62,16 @@ typedef enum _SymbolStatus
} SymbolStatus;
+/* Indications supplémentaires liées aux symboles */
+typedef enum _SymbolFlag
+{
+ SFL_NONE = (0 << 0), /* Aucune propriété */
+ SFL_PREFIXED_NAME = (1 << 0), /* Indication en amont du nom */
+
+ SFL_COUNT
+
+} SymbolFlag;
+
#define G_TYPE_BIN_SYMBOL g_binary_symbol_get_type()
#define G_BIN_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_BIN_SYMBOL, GBinSymbol))
@@ -109,6 +118,18 @@ void g_binary_symbol_set_status(GBinSymbol *, SymbolStatus);
/* Fournit la visibilité du symbole. */
SymbolStatus g_binary_symbol_get_status(const GBinSymbol *);
+/* Ajoute une information complémentaire à un symbole. */
+bool g_binary_symbol_set_flag(GBinSymbol *, SymbolFlag);
+
+/* Retire une information complémentaire à un symbole. */
+bool g_binary_symbol_unset_flag(GBinSymbol *, SymbolFlag);
+
+/* Détermine si un symbole possède un fanion particulier. */
+bool g_binary_symbol_has_flag(const GBinSymbol *, SymbolFlag);
+
+/* Fournit les particularités du symbole. */
+SymbolFlag g_binary_symbol_get_flags(const GBinSymbol *);
+
/* Fournit une étiquette pour viser un symbole. */
char *g_binary_symbol_get_label(const GBinSymbol *);