diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-01-28 00:24:40 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-01-28 00:24:40 (GMT) |
commit | 94cb8acac1027a4deee933c84d7918f4a5ea4983 (patch) | |
tree | e6f5a1f372cdceb942d4bd659668c20dc34e649b /plugins/pychrysalide/helpers.c | |
parent | fa99f722ed6b06ea7f6b56a8816c61ecd5053289 (diff) |
Allowed to filter contents before running analysis.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r-- | plugins/pychrysalide/helpers.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c index 7e31fa7..2b62e57 100644 --- a/plugins/pychrysalide/helpers.c +++ b/plugins/pychrysalide/helpers.c @@ -109,6 +109,51 @@ PyObject *status_to_rich_cmp_state(int status, int op) /****************************************************************************** * * +* Paramètres : arg = argument quelconque à tenter de convertir. * +* dst = destination des valeurs récupérées en cas de succès. * +* * +* Description : Tente de convertir en élément appelable. * +* * +* Retour : Bilan de l'opération, voire indications supplémentaires. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_callable(PyObject *arg, void *dst) +{ + int result; /* Bilan à retourner */ + + result = PyCallable_Check(arg); + + switch (result) + { + case -1: + /* L'exception est déjà fixée par Python */ + result = 0; + break; + + case 0: + PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to a callable object"); + break; + + case 1: + *((PyObject **)dst) = arg; + break; + + default: + assert(false); + break; + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : target = propriétaire de la routine visée. * * method = désignation de la fonction à appeler. * * * |