diff options
Diffstat (limited to 'plugins/pychrysa/helpers.c')
-rw-r--r-- | plugins/pychrysa/helpers.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/pychrysa/helpers.c b/plugins/pychrysa/helpers.c index 36d0d76..df1df05 100644 --- a/plugins/pychrysa/helpers.c +++ b/plugins/pychrysa/helpers.c @@ -31,6 +31,60 @@ /****************************************************************************** * * +* Paramètres : status = bilan de comparaison à traduire. * +* op = type de comparaison menée. * +* * +* Description : Traduit pour Python le bilan d'une comparaison riche. * +* * +* Retour : Objet Python à référencer. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyObject *status_to_rich_cmp_state(int status, int op) +{ + PyObject *result; /* Bilan àretourner */ + + 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; + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : target = propriétaire de la routine visée. * * method = désignation de la fonction à appeler. * * * |