summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-28 00:24:40 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-28 00:24:40 (GMT)
commit94cb8acac1027a4deee933c84d7918f4a5ea4983 (patch)
treee6f5a1f372cdceb942d4bd659668c20dc34e649b /plugins/pychrysalide/helpers.c
parentfa99f722ed6b06ea7f6b56a8816c61ecd5053289 (diff)
Allowed to filter contents before running analysis.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c45
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. *
* *