summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/format
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-05-10 20:21:56 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-05-10 20:21:56 (GMT)
commit8e76324b01e5b4979f346f0bc8c84372477a3d38 (patch)
tree3db4057e113aa9f664f5b217dd349bb1e9288009 /plugins/pychrysa/format
parentb0c6ffacf5c6c45c047172e348c737cb85fb5b36 (diff)
Rewritten the whole bitfield management.
Diffstat (limited to 'plugins/pychrysa/format')
-rw-r--r--plugins/pychrysa/format/symbol.c39
1 files changed, 5 insertions, 34 deletions
diff --git a/plugins/pychrysa/format/symbol.c b/plugins/pychrysa/format/symbol.c
index 53fb9c9..75f226a 100644
--- a/plugins/pychrysa/format/symbol.c
+++ b/plugins/pychrysa/format/symbol.c
@@ -85,8 +85,9 @@ static bool py_binary_symbol_define_constants(PyTypeObject *);
/******************************************************************************
* *
-* Paramètres : obj = objet Python à tenter de convertir. *
-* addr = structure équivalente pour Chrysalide. *
+* Paramètres : a = premier object Python à consulter. *
+* b = second object Python à consulter. *
+* op = type de comparaison menée. *
* *
* Description : Effectue une comparaison avec un objet Python 'BinSymbol'. *
* *
@@ -98,7 +99,7 @@ static bool py_binary_symbol_define_constants(PyTypeObject *);
static PyObject *py_binary_symbol_richcompare(PyObject *a, PyObject *b, int op)
{
- PyObject *result; /* Chaîne à retourner */
+ PyObject *result; /* Bilan à retourner */
int ret; /* Bilan de lecture des args. */
const GBinSymbol *sym_a; /* Premier élément à traiter */
const GBinSymbol *sym_b; /* Second élément à traiter */
@@ -116,37 +117,7 @@ static PyObject *py_binary_symbol_richcompare(PyObject *a, PyObject *b, int op)
status = g_binary_symbol_cmp(&sym_a, &sym_b);
- switch (op)
- {
- case Py_LT:
- result = status < 0 ? Py_True : Py_False;
- break;
-
- case Py_LE:
- result = status <= 0 ? Py_True : Py_False;
- break;
-
- case Py_EQ:
- result = status == 0 ? Py_True : Py_False;
- break;
-
- case Py_NE:
- result = status != 0 ? Py_True : Py_False;
- break;
-
- case Py_GT:
- result = status > 0 ? Py_True : Py_False;
- break;
-
- case Py_GE:
- result = status >= 0 ? Py_True : Py_False;
- break;
-
- default:
- result = Py_NotImplemented;
- break;
-
- }
+ result = status_to_rich_cmp_state(status, op);
cmp_done: