summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/helpers.h')
-rw-r--r--plugins/pychrysa/helpers.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/pychrysa/helpers.h b/plugins/pychrysa/helpers.h
index f957b9d..d47d8e7 100644
--- a/plugins/pychrysa/helpers.h
+++ b/plugins/pychrysa/helpers.h
@@ -26,14 +26,35 @@
#include <Python.h>
+#include <stdbool.h>
/* Appelle une routine Python. */
-PyObject *run_python_method(PyObject *, const char *, PyObject *);
+PyObject *_run_python_method(PyObject *, PyObject *);
/* Appelle une routine Python. */
-PyObject *_run_python_method(PyObject *, PyObject *);
+PyObject *run_python_method(PyObject *, const char *, PyObject *);
+
+/* Ajoute une constante au dictionnaire d'un type Python donné. */
+bool PyDict_AddIntConstant(PyTypeObject *, const char *, long);
+
+/* Ajoute une constante au dictionnaire d'un type Python donné. */
+bool PyDict_AddStringConstant(PyTypeObject *, const char *, const char *);
+
+
+#define PyDict_AddIntMacro(tp, c) PyDict_AddIntConstant(tp, #c, c)
+#define PyDict_AddStringMacro(tp, c) PyDict_AddStringConstant(tp, #c, c)
+
+
+/**
+ * Quelque chose est mal fait au niveau de l'abstraction GObject.
+ * Du coup, Py_TPFLAGS_IS_ABSTRACT n'est pas pris en compte.
+ * On force alors la méthode de base pour obtenir un traitement correct.
+ *
+ * Cf. http://stackoverflow.com/questions/20432335/can-python-abstract-base-classes-inherit-from-c-extensions
+ */
+#define APPLY_ABSTRACT_FLAG(tp) tp->tp_new = PyBaseObject_Type.tp_new