summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-08-18 21:35:18 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-08-18 21:35:18 (GMT)
commitdd9974a5c2770a066d8b4edf47b41034fbd41c72 (patch)
tree55d6cc65b41e838ac615a6dff70606cd5bb8bc66 /plugins/pychrysalide/helpers.c
parentf021fec73e81943918325c658d6b5594dcdff0d4 (diff)
Prepared an improved Python documentation.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index 59bcd45..5b7c1e6 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -28,8 +28,10 @@
#include <malloc.h>
#include <pygobject.h>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <i18n.h>
@@ -1003,6 +1005,9 @@ bool attach_constants_group(PyTypeObject *owner, bool flags, const char *name, P
int ret; /* Bilan d'une insertion */
PyObject *args; /* Arguments de la construction*/
PyObject *kwargs; /* Mots clefs en complément */
+ char *dot; /* Point de séparation */
+ char *module; /* Module d'appartenance */
+ char *qualname; /* Désignation pour Pickle */
PyObject *new; /* Nouvelle instance en place */
PyObject *features; /* Module à recompléter */
PyObject *features_dict; /* Dictionnaire à compléter */
@@ -1046,10 +1051,27 @@ bool attach_constants_group(PyTypeObject *owner, bool flags, const char *name, P
kwargs = PyDict_New();
- str_obj = PyUnicode_FromString(owner->tp_name);
+ dot = rindex(owner->tp_name, '.');
+ assert(dot != NULL);
+
+ module = strndup(owner->tp_name, dot - owner->tp_name);
+
+ str_obj = PyUnicode_FromString(module);
ret = PyDict_SetItemString(kwargs, "module", str_obj);
Py_DECREF(str_obj);
+ free(module);
+
+ asprintf(&qualname, "%s.%s", dot + 1, name);
+
+ if (ret != 0) goto kwargs_error;
+
+ str_obj = PyUnicode_FromString(qualname);
+ ret = PyDict_SetItemString(kwargs, "qualname", str_obj);
+ Py_DECREF(str_obj);
+
+ free(qualname);
+
if (ret != 0) goto kwargs_error;
/* Constitution de l'énumération et enregistrement */