summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis/db/items
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/analysis/db/items')
-rw-r--r--plugins/pychrysalide/analysis/db/items/comment.c23
-rw-r--r--plugins/pychrysalide/analysis/db/items/comment.h2
-rw-r--r--plugins/pychrysalide/analysis/db/items/module.c48
-rw-r--r--plugins/pychrysalide/analysis/db/items/module.h7
4 files changed, 49 insertions, 31 deletions
diff --git a/plugins/pychrysalide/analysis/db/items/comment.c b/plugins/pychrysalide/analysis/db/items/comment.c
index 28886f5..cae866f 100644
--- a/plugins/pychrysalide/analysis/db/items/comment.c
+++ b/plugins/pychrysalide/analysis/db/items/comment.c
@@ -34,6 +34,7 @@
#include "../item.h"
+#include "../../../access.h"
#include "../../../helpers.h"
#include "../../../arch/vmpa.h"
@@ -224,17 +225,27 @@ PyTypeObject *get_python_db_comment_type(void)
* *
******************************************************************************/
-bool register_python_db_comment(PyObject *module)
+bool ensure_python_db_comment_is_registered(void)
{
- PyTypeObject *py_db_comment_type; /* Type Python 'DbComment' */
+ PyTypeObject *type; /* Type Python 'DbComment' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_db_comment_type = get_python_db_comment_type();
+ type = get_python_db_comment_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.db.items");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_db_item_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_DB_COMMENT, py_db_comment_type, get_python_db_item_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_COMMENT, type, get_python_db_item_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/db/items/comment.h b/plugins/pychrysalide/analysis/db/items/comment.h
index 2b4f130..9c598b1 100644
--- a/plugins/pychrysalide/analysis/db/items/comment.h
+++ b/plugins/pychrysalide/analysis/db/items/comment.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_db_comment_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.db.items.DbComment'. */
-bool register_python_db_comment(PyObject *);
+bool ensure_python_db_comment_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/db/items/module.c b/plugins/pychrysalide/analysis/db/items/module.c
index cf0fe56..1f9e580 100644
--- a/plugins/pychrysalide/analysis/db/items/module.c
+++ b/plugins/pychrysalide/analysis/db/items/module.c
@@ -29,29 +29,28 @@
#include "comment.h"
-#include "../../../access.h"
+#include "../../../helpers.h"
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : super = module dont la définition est à compléter. *
* *
-* Description : Ajoute le module 'items' au module Python. *
+* Description : Ajoute le module 'analysis.db.items' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_analysis_db_items_module_to_python_module(PyObject *super)
+bool add_analysis_db_items_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_items_module = {
+ static PyModuleDef py_chrysalide_analysis_db_items_module = {
.m_base = PyModuleDef_HEAD_INIT,
@@ -62,29 +61,34 @@ bool add_analysis_db_items_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_analysis_db_items_module);
- module = PyModule_Create(&py_chrysalide_items_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_items_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.db.items");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "items", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis.db.items'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_db_comment(module);
+bool populate_analysis_db_items_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.analysis.db.items", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_db_comment_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/analysis/db/items/module.h b/plugins/pychrysalide/analysis/db/items/module.h
index 1382226..d5112b0 100644
--- a/plugins/pychrysalide/analysis/db/items/module.h
+++ b/plugins/pychrysalide/analysis/db/items/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'items' au module Python. */
-bool add_analysis_db_items_module_to_python_module(PyObject *);
+/* Ajoute le module 'analysis.db.items' à un module Python. */
+bool add_analysis_db_items_module(PyObject *);
+
+/* Intègre les objets du module 'analysis.db.items'. */
+bool populate_analysis_db_items_module(void);