diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-08-16 09:16:53 (GMT) |
commit | fb315963527f6412273829f09513325e446eb6c9 (patch) | |
tree | 361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/common/pathname.c | |
parent | 36945bffa2ca648b58c99905ebf9b1b536a9188a (diff) |
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/common/pathname.c')
-rw-r--r-- | plugins/pychrysalide/common/pathname.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/plugins/pychrysalide/common/pathname.c b/plugins/pychrysalide/common/pathname.c index 40977df..c2d69c6 100644 --- a/plugins/pychrysalide/common/pathname.c +++ b/plugins/pychrysalide/common/pathname.c @@ -35,6 +35,9 @@ #include <common/pathname.h> +#include "../access.h" + + /* Calcule le chemin relatif entre deux fichiers donnés. */ static PyObject *py_build_relative_filename(PyObject *, PyObject *); @@ -183,21 +186,31 @@ PyTypeObject *get_python_pathname_type(void) * * ******************************************************************************/ -bool register_python_pathname(PyObject *module) +bool ensure_python_pathname_is_registered(void) { - PyTypeObject *py_pathname_type; /* Type Python pour 'pathname' */ + PyTypeObject *type; /* Type Python pour 'pathname' */ + PyObject *module; /* Module à recompléter */ int ret; /* Bilan d'un appel */ - py_pathname_type = get_python_pathname_type(); + type = get_python_pathname_type(); + + if (!PyType_HasFeature(type, Py_TPFLAGS_READY)) + { + //type->tp_new = PyType_GenericNew; - //py_pathname_type->tp_new = PyType_GenericNew; + if (PyType_Ready(type) != 0) + return false; - if (PyType_Ready(py_pathname_type) != 0) - return false; + module = get_access_to_python_module("pychrysalide.common"); - Py_INCREF(py_pathname_type); - ret = PyModule_AddObject(module, "pathname", (PyObject *)py_pathname_type); + Py_INCREF(type); + ret = PyModule_AddObject(module, "pathname", (PyObject *)type); + + if (ret != 0) + return false; + + } - return (ret == 0); + return true; } |