summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/core/logs.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-08-16 09:16:53 (GMT)
commitfb315963527f6412273829f09513325e446eb6c9 (patch)
tree361f19767812a8f758545e8daa2973fe0b3c9de7 /plugins/pychrysalide/core/logs.c
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/core/logs.c')
-rw-r--r--plugins/pychrysalide/core/logs.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/plugins/pychrysalide/core/logs.c b/plugins/pychrysalide/core/logs.c
index 6476ed0..c0caddb 100644
--- a/plugins/pychrysalide/core/logs.c
+++ b/plugins/pychrysalide/core/logs.c
@@ -31,6 +31,7 @@
#include <core/logs.h>
+#include "../access.h"
#include "../helpers.h"
@@ -255,24 +256,34 @@ static bool define_python_log_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_logs(PyObject *module)
+bool ensure_python_logs_is_registered(void)
{
- PyTypeObject *py_logs_type; /* Type Python pour 'logs' */
+ PyTypeObject *type; /* Type Python pour 'logs' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_logs_type = get_python_logs_type();
+ type = get_python_logs_type();
- py_logs_type->tp_new = PyType_GenericNew;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(type) != 0)
+ return false;
+
+ if (!define_python_log_constants(type))
+ return false;
- if (PyType_Ready(py_logs_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.core");
- if (!define_python_log_constants(py_logs_type))
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "logs", (PyObject *)type);
- Py_INCREF(py_logs_type);
- ret = PyModule_AddObject(module, "logs", (PyObject *)py_logs_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}