diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2021-02-07 23:18:18 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2021-02-07 23:18:18 (GMT) |
commit | 3071d472057feb974bd5167d3a3ef9297b602b26 (patch) | |
tree | 3b8617cb2aaa91184853903f76d54a4f4c8040bc /plugins/pychrysalide/plugins/constants.c | |
parent | 42540e681161aab0a1c27c66541ed5dc833ca411 (diff) |
Extended the Python API to list plugins.
Diffstat (limited to 'plugins/pychrysalide/plugins/constants.c')
-rw-r--r-- | plugins/pychrysalide/plugins/constants.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/pychrysalide/plugins/constants.c b/plugins/pychrysalide/plugins/constants.c index 9de044a..8791d91 100644 --- a/plugins/pychrysalide/plugins/constants.c +++ b/plugins/pychrysalide/plugins/constants.c @@ -98,3 +98,50 @@ bool define_plugin_module_constants(PyTypeObject *type) return result; } + + +/****************************************************************************** +* * +* 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 constante PluginAction. * +* * +* Retour : Bilan de l'opération, voire indications supplémentaires. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_plugin_action(PyObject *arg, void *dst) +{ + int result; /* Bilan à retourner */ + unsigned long value; /* Valeur récupérée */ + + result = PyObject_IsInstance(arg, (PyObject *)&PyLong_Type); + + 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 PluginAction"); + break; + + case 1: + value = PyLong_AsUnsignedLong(arg); + *((PluginAction *)dst) = value; + break; + + default: + assert(false); + break; + + } + + return result; + +} |