diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
commit | 24d3836fcf8d443eb654b981f65478cd9923b8f1 (patch) | |
tree | 7672a28b864127e8958c3c6cce751dcf646d2fbe /plugins/pychrysa/core/params.c | |
parent | a61f089babe336b012da31a494b0f7470b6e1a9a (diff) |
Updated the Python bindings.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@552 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/core/params.c')
-rw-r--r-- | plugins/pychrysa/core/params.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/plugins/pychrysa/core/params.c b/plugins/pychrysa/core/params.c index 987bca6..5029304 100644 --- a/plugins/pychrysa/core/params.c +++ b/plugins/pychrysa/core/params.c @@ -31,12 +31,15 @@ #include <core/params.h> +#include "../helpers.h" + + /* Fournit la version du programme global. */ static PyObject *py_params_get_main_configuration(PyObject *, PyObject *); /* Définit les constantes pour les paramètres. */ -static bool py_params_define_constants(PyObject *); +static bool py_params_define_constants(PyTypeObject *); @@ -114,7 +117,7 @@ PyTypeObject *get_python_params_type(void) /****************************************************************************** * * -* Paramètres : dict = dictionnaire à compléter. * +* Paramètres : obj_type = type dont le dictionnaire est à compléter. * * * * Description : Définit les constantes pour les paramètres. * * * @@ -124,21 +127,19 @@ PyTypeObject *get_python_params_type(void) * * ******************************************************************************/ -static bool py_params_define_constants(PyObject *dict) +static bool py_params_define_constants(PyTypeObject *obj_type) { - int ret; /* Bilan d'un ajout */ + bool result; /* Bilan à retourner */ -#define DEF_STR_CONST(name) \ - ret = PyDict_SetItemString(dict, #name, PyUnicode_FromString(name)); \ - if (ret == -1) return false; + result = true; - DEF_STR_CONST(MPK_LAST_PROJECT); - DEF_STR_CONST(MPK_ELLIPSIS_HEADER); - DEF_STR_CONST(MPK_ELLIPSIS_TAB); - DEF_STR_CONST(MPK_KEYBINDINGS_EDIT); - DEF_STR_CONST(MPK_AUTO_SAVE); + result &= PyDict_AddStringMacro(obj_type, MPK_LAST_PROJECT); + result &= PyDict_AddStringMacro(obj_type, MPK_ELLIPSIS_HEADER); + result &= PyDict_AddStringMacro(obj_type, MPK_ELLIPSIS_TAB); + result &= PyDict_AddStringMacro(obj_type, MPK_KEYBINDINGS_EDIT); + result &= PyDict_AddStringMacro(obj_type, MPK_AUTO_SAVE); - return true; + return result; } @@ -167,7 +168,7 @@ bool register_python_params(PyObject *module) if (PyType_Ready(py_params_type) != 0) return false; - if (!py_params_define_constants(py_params_type->tp_dict)) + if (!py_params_define_constants(py_params_type)) return false; Py_INCREF(py_params_type); |