summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-04-12 22:25:43 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-04-12 22:25:43 (GMT)
commit8d4c5ae6dfd812b753109a25d7e84f7e524d4bf0 (patch)
treeb437de37b5447daa02263901aca4ef7a7d2d0386 /plugins/pychrysalide/format
parentb4cbeedf6ed4e04dd85c92e8345b4cb8dcaab27d (diff)
Improved support of type prefix for symbols.
Diffstat (limited to 'plugins/pychrysalide/format')
-rw-r--r--plugins/pychrysalide/format/constants.c3
-rw-r--r--plugins/pychrysalide/format/symbol.c55
2 files changed, 54 insertions, 4 deletions
diff --git a/plugins/pychrysalide/format/constants.c b/plugins/pychrysalide/format/constants.c
index dfa4615..a0d71f7 100644
--- a/plugins/pychrysalide/format/constants.c
+++ b/plugins/pychrysalide/format/constants.c
@@ -88,7 +88,8 @@ bool define_binary_symbol_constants(PyTypeObject *type)
values = PyDict_New();
result = add_const_to_group(values, "NONE", SFL_NONE);
- if (result) result = add_const_to_group(values, "PREFIXED_NAME", SFL_PREFIXED_NAME);
+ if (result) result = add_const_to_group(values, "HAS_NM_PREFIX", SFL_HAS_NM_PREFIX);
+ if (result) result = add_const_to_group(values, "MASK", SFL_MASK);
if (!result)
{
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index 75eb8f4..6f1c1d2 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -93,9 +93,6 @@ static PyObject *py_binary_symbol_get_stype(PyObject *, void *);
/* Définit le type du symbole. */
static int py_binary_symbol_set_stype(PyObject *, PyObject *, void *);
-/* Fournit un étiquette pour viser un symbole. */
-static PyObject *py_binary_symbol_get_label(PyObject *, void *);
-
/* Fournit la visibilité du symbole. */
static PyObject *py_binary_symbol_get_status(PyObject *, void *);
@@ -105,6 +102,12 @@ static int py_binary_symbol_set_status(PyObject *, PyObject *, void *);
/* Fournit les particularités du symbole. */
static PyObject *py_binary_symbol_get_flags(PyObject *, void *);
+/* Fournit le préfixe compatible avec une sortie "nm". */
+static PyObject *py_binary_symbol_get_nm_prefix(PyObject *, void *);
+
+/* Fournit un étiquette pour viser un symbole. */
+static PyObject *py_binary_symbol_get_label(PyObject *, void *);
+
/* Définit un autre nom pour le symbole. */
static int py_binary_symbol_set_label(PyObject *, PyObject *, void *);
@@ -747,6 +750,51 @@ static PyObject *py_binary_symbol_get_flags(PyObject *self, void *closure)
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
+* Description : Fournit le préfixe compatible avec une sortie "nm". *
+* *
+* Retour : Caractère éventuel ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_binary_symbol_get_nm_prefix(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GBinSymbol *symbol; /* Elément à consulter */
+ char prefix[2]; /* Eventuel préfixe "nm" */
+ bool status; /* Validité de ce préfixe */
+
+#define BINARY_SYMBOL_NM_PREFIX_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ nm_prefix, py_binary_symbol, \
+ "Single-byte string for an optional *nm* prefix, or None if any." \
+)
+
+ symbol = G_BIN_SYMBOL(pygobject_get(self));
+ status = g_binary_symbol_get_nm_prefix(symbol, &prefix[0]);
+
+ if (status)
+ {
+ prefix[1] = '\0';
+ result = PyUnicode_FromString(prefix);
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
* Description : Fournit un étiquette pour viser un symbole. *
* *
* Retour : Chaîne de caractères renvoyant au symbole. *
@@ -852,6 +900,7 @@ PyTypeObject *get_python_binary_symbol_type(void)
BINARY_SYMBOL_STYPE_ATTRIB,
BINARY_SYMBOL_STATUS_ATTRIB,
BINARY_SYMBOL_FLAGS_ATTRIB,
+ BINARY_SYMBOL_NM_PREFIX_ATTRIB,
BINARY_SYMBOL_LABEL_ATTRIB,
{ NULL }
};