summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/analysis
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/analysis
parent36945bffa2ca648b58c99905ebf9b1b536a9188a (diff)
Reorganized the Python plugin code.
Diffstat (limited to 'plugins/pychrysalide/analysis')
-rw-r--r--plugins/pychrysalide/analysis/binary.c26
-rw-r--r--plugins/pychrysalide/analysis/binary.h2
-rw-r--r--plugins/pychrysalide/analysis/block.c28
-rw-r--r--plugins/pychrysalide/analysis/block.h2
-rw-r--r--plugins/pychrysalide/analysis/content.c20
-rw-r--r--plugins/pychrysalide/analysis/content.h2
-rw-r--r--plugins/pychrysalide/analysis/contents/encapsulated.c20
-rw-r--r--plugins/pychrysalide/analysis/contents/encapsulated.h2
-rw-r--r--plugins/pychrysalide/analysis/contents/file.c20
-rw-r--r--plugins/pychrysalide/analysis/contents/file.h2
-rw-r--r--plugins/pychrysalide/analysis/contents/memory.c20
-rw-r--r--plugins/pychrysalide/analysis/contents/memory.h2
-rw-r--r--plugins/pychrysalide/analysis/contents/module.c54
-rw-r--r--plugins/pychrysalide/analysis/contents/module.h7
-rw-r--r--plugins/pychrysalide/analysis/contents/restricted.c21
-rw-r--r--plugins/pychrysalide/analysis/contents/restricted.h2
-rw-r--r--plugins/pychrysalide/analysis/db/certs.c29
-rw-r--r--plugins/pychrysalide/analysis/db/certs.h2
-rw-r--r--plugins/pychrysalide/analysis/db/collection.c20
-rw-r--r--plugins/pychrysalide/analysis/db/collection.h2
-rw-r--r--plugins/pychrysalide/analysis/db/item.c20
-rw-r--r--plugins/pychrysalide/analysis/db/item.h2
-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
-rw-r--r--plugins/pychrysalide/analysis/db/module.c59
-rw-r--r--plugins/pychrysalide/analysis/db/module.h7
-rw-r--r--plugins/pychrysalide/analysis/loaded.c22
-rw-r--r--plugins/pychrysalide/analysis/loaded.h2
-rw-r--r--plugins/pychrysalide/analysis/loading.c43
-rw-r--r--plugins/pychrysalide/analysis/loading.h4
-rw-r--r--plugins/pychrysalide/analysis/module.c76
-rw-r--r--plugins/pychrysalide/analysis/module.h7
-rw-r--r--plugins/pychrysalide/analysis/project.c22
-rw-r--r--plugins/pychrysalide/analysis/project.h2
-rw-r--r--plugins/pychrysalide/analysis/routine.c26
-rw-r--r--plugins/pychrysalide/analysis/routine.h2
-rw-r--r--plugins/pychrysalide/analysis/type.c26
-rw-r--r--plugins/pychrysalide/analysis/type.h2
-rw-r--r--plugins/pychrysalide/analysis/types/array.c23
-rw-r--r--plugins/pychrysalide/analysis/types/array.h2
-rw-r--r--plugins/pychrysalide/analysis/types/basic.c27
-rw-r--r--plugins/pychrysalide/analysis/types/basic.h2
-rw-r--r--plugins/pychrysalide/analysis/types/cse.c28
-rw-r--r--plugins/pychrysalide/analysis/types/cse.h2
-rw-r--r--plugins/pychrysalide/analysis/types/encaps.c28
-rw-r--r--plugins/pychrysalide/analysis/types/encaps.h2
-rw-r--r--plugins/pychrysalide/analysis/types/expr.c23
-rw-r--r--plugins/pychrysalide/analysis/types/expr.h2
-rw-r--r--plugins/pychrysalide/analysis/types/literal.c23
-rw-r--r--plugins/pychrysalide/analysis/types/literal.h2
-rw-r--r--plugins/pychrysalide/analysis/types/module.c64
-rw-r--r--plugins/pychrysalide/analysis/types/module.h7
-rw-r--r--plugins/pychrysalide/analysis/types/override.c24
-rw-r--r--plugins/pychrysalide/analysis/types/override.h2
-rw-r--r--plugins/pychrysalide/analysis/types/proto.c23
-rw-r--r--plugins/pychrysalide/analysis/types/proto.h2
-rw-r--r--plugins/pychrysalide/analysis/types/template.c24
-rw-r--r--plugins/pychrysalide/analysis/types/template.h2
-rw-r--r--plugins/pychrysalide/analysis/variable.c22
-rw-r--r--plugins/pychrysalide/analysis/variable.h2
62 files changed, 657 insertions, 364 deletions
diff --git a/plugins/pychrysalide/analysis/binary.c b/plugins/pychrysalide/analysis/binary.c
index 1ca5b3c..8640bc2 100644
--- a/plugins/pychrysalide/analysis/binary.c
+++ b/plugins/pychrysalide/analysis/binary.c
@@ -34,6 +34,8 @@
#include <analysis/binary.h>
+#include "loaded.h"
+#include "../access.h"
#include "../helpers.h"
#include "../format/executable.h"
@@ -279,7 +281,7 @@ PyTypeObject *get_python_loaded_binary_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.LoadedBinary'.*
* *
@@ -289,17 +291,27 @@ PyTypeObject *get_python_loaded_binary_type(void)
* *
******************************************************************************/
-bool register_python_loaded_binary(PyObject *module)
+bool ensure_python_loaded_binary_is_registered(void)
{
- PyTypeObject *py_loaded_binary_type; /* Type Python 'LoadedBinary' */
+ PyTypeObject *type; /* Type Python 'ProxyFeeder' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_loaded_binary_type = get_python_loaded_binary_type();
+ type = get_python_loaded_binary_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_loaded_content_is_registered())
+ return false;
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_LOADED_BINARY, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_LOADED_BINARY, py_loaded_binary_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/binary.h b/plugins/pychrysalide/analysis/binary.h
index 1d72a59..235e018 100644
--- a/plugins/pychrysalide/analysis/binary.h
+++ b/plugins/pychrysalide/analysis/binary.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_loaded_binary_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.LoadedBinary'. */
-bool register_python_loaded_binary(PyObject *);
+bool ensure_python_loaded_binary_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/block.c b/plugins/pychrysalide/analysis/block.c
index e646ba8..010efd4 100644
--- a/plugins/pychrysalide/analysis/block.c
+++ b/plugins/pychrysalide/analysis/block.c
@@ -31,6 +31,7 @@
#include <analysis/block.h>
+#include "../access.h"
#include "../helpers.h"
@@ -216,11 +217,9 @@ PyTypeObject *get_python_instr_block_type(void)
return &py_instr_block_type;
}
-
-
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.InstrBlock'. *
* *
@@ -230,22 +229,25 @@ PyTypeObject *get_python_instr_block_type(void)
* *
******************************************************************************/
-bool register_python_instr_block(PyObject *module)
+bool ensure_python_instr_block_is_registered(void)
{
-#if 0
- PyTypeObject *py_instr_block_type; /* Type Python 'InstrBlock' */
+ PyTypeObject *type; /* Type Python 'InstrBlock' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_instr_block_type = get_python_instr_block_type();
+ type = get_python_instr_block_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
- if (!register_class_for_pygobject(dict, G_TYPE_INSTR_BLOCK, py_instr_block_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_CODE_BLOCK, type, &PyGObject_Type))
+ return false;
+
+ }
- if (!py_instructions_block_define_constants(py_instr_block_type))
- return false;
-#endif
return true;
}
diff --git a/plugins/pychrysalide/analysis/block.h b/plugins/pychrysalide/analysis/block.h
index dc3f517..84ff679 100644
--- a/plugins/pychrysalide/analysis/block.h
+++ b/plugins/pychrysalide/analysis/block.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_instr_block_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.InstrBlock'. */
-bool register_python_instr_block(PyObject *);
+bool ensure_python_instr_block_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/content.c b/plugins/pychrysalide/analysis/content.c
index 4be318d..e657857 100644
--- a/plugins/pychrysalide/analysis/content.c
+++ b/plugins/pychrysalide/analysis/content.c
@@ -36,6 +36,7 @@
#include <common/endianness.h>
+#include "../access.h"
#include "../arch/vmpa.h"
@@ -480,7 +481,7 @@ PyTypeObject *get_python_binary_content_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.BinContent'. *
* *
@@ -490,15 +491,22 @@ PyTypeObject *get_python_binary_content_type(void)
* *
******************************************************************************/
-bool register_python_binary_content(PyObject *module)
+bool ensure_python_binary_content_is_registered(void)
{
- PyTypeObject *py_binary_content_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'BinContent' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_binary_content_type = get_python_binary_content_type();
+ type = get_python_binary_content_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "BinContent", G_TYPE_BIN_CONTENT, py_binary_content_type);
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "BinContent", G_TYPE_BIN_CONTENT, type);
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/content.h b/plugins/pychrysalide/analysis/content.h
index 71d8100..b433828 100644
--- a/plugins/pychrysalide/analysis/content.h
+++ b/plugins/pychrysalide/analysis/content.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_binary_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.BinContent'. */
-bool register_python_binary_content(PyObject *);
+bool ensure_python_binary_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/contents/encapsulated.c b/plugins/pychrysalide/analysis/contents/encapsulated.c
index a81e45b..0b604c7 100644
--- a/plugins/pychrysalide/analysis/contents/encapsulated.c
+++ b/plugins/pychrysalide/analysis/contents/encapsulated.c
@@ -32,6 +32,7 @@
#include "../content.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -143,17 +144,24 @@ PyTypeObject *get_python_encaps_content_type(void)
* *
******************************************************************************/
-bool register_python_encaps_content(PyObject *module)
+bool ensure_python_encaps_content_is_registered(void)
{
- PyTypeObject *py_encaps_content_type; /* Type 'EncapsulatedContent' */
+ PyTypeObject *type; /* Type 'EncapsulatedContent' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_encaps_content_type = get_python_encaps_content_type();
+ type = get_python_encaps_content_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.contents");
- if (!register_class_for_pygobject(dict, G_TYPE_ENCAPS_CONTENT, py_encaps_content_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_ENCAPS_CONTENT, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/contents/encapsulated.h b/plugins/pychrysalide/analysis/contents/encapsulated.h
index ebd760c..1d46fdc 100644
--- a/plugins/pychrysalide/analysis/contents/encapsulated.h
+++ b/plugins/pychrysalide/analysis/contents/encapsulated.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_encaps_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.contents.EncapsulatedContent'. */
-bool register_python_encaps_content(PyObject *);
+bool ensure_python_encaps_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/contents/file.c b/plugins/pychrysalide/analysis/contents/file.c
index b033611..a44263e 100644
--- a/plugins/pychrysalide/analysis/contents/file.c
+++ b/plugins/pychrysalide/analysis/contents/file.c
@@ -31,6 +31,7 @@
#include <analysis/contents/file.h>
+#include "../../access.h"
#include "../../helpers.h"
@@ -132,17 +133,24 @@ PyTypeObject *get_python_file_content_type(void)
* *
******************************************************************************/
-bool register_python_file_content(PyObject *module)
+bool ensure_python_file_content_is_registered(void)
{
- PyTypeObject *py_file_content_type; /* Type Python 'FileContent' */
+ PyTypeObject *type; /* Type Python 'FileContent' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_file_content_type = get_python_file_content_type();
+ type = get_python_file_content_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.contents");
- if (!register_class_for_pygobject(dict, G_TYPE_FILE_CONTENT, py_file_content_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_FILE_CONTENT, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/contents/file.h b/plugins/pychrysalide/analysis/contents/file.h
index 04f4395..110a6da 100644
--- a/plugins/pychrysalide/analysis/contents/file.h
+++ b/plugins/pychrysalide/analysis/contents/file.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_file_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.contents.FileContent'. */
-bool register_python_file_content(PyObject *);
+bool ensure_python_file_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/contents/memory.c b/plugins/pychrysalide/analysis/contents/memory.c
index fadc9bf..ee8b13c 100644
--- a/plugins/pychrysalide/analysis/contents/memory.c
+++ b/plugins/pychrysalide/analysis/contents/memory.c
@@ -31,6 +31,7 @@
#include <analysis/contents/memory.h>
+#include "../../access.h"
#include "../../helpers.h"
@@ -137,17 +138,24 @@ PyTypeObject *get_python_memory_content_type(void)
* *
******************************************************************************/
-bool register_python_memory_content(PyObject *module)
+bool ensure_python_memory_content_is_registered(void)
{
- PyTypeObject *py_memory_content_type; /* Type Python 'MemoryContent' */
+ PyTypeObject *type; /* Type Python 'MemoryContent' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_memory_content_type = get_python_memory_content_type();
+ type = get_python_memory_content_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.contents");
- if (!register_class_for_pygobject(dict, G_TYPE_MEMORY_CONTENT, py_memory_content_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_MEMORY_CONTENT, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/contents/memory.h b/plugins/pychrysalide/analysis/contents/memory.h
index f3db9a7..3941e39 100644
--- a/plugins/pychrysalide/analysis/contents/memory.h
+++ b/plugins/pychrysalide/analysis/contents/memory.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_memory_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.contents.MemoryContent'. */
-bool register_python_memory_content(PyObject *);
+bool ensure_python_memory_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/contents/module.c b/plugins/pychrysalide/analysis/contents/module.c
index 53fcdc8..d1650ac 100644
--- a/plugins/pychrysalide/analysis/contents/module.c
+++ b/plugins/pychrysalide/analysis/contents/module.c
@@ -32,29 +32,28 @@
#include "file.h"
#include "memory.h"
#include "restricted.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 'contents' au module Python. *
+* Description : Ajoute le module 'analysis.contents' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_analysis_contents_module_to_python_module(PyObject *super)
+bool add_analysis_contents_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_contents_module = {
+ static PyModuleDef py_chrysalide_analysis_contents_module = {
.m_base = PyModuleDef_HEAD_INIT,
@@ -65,32 +64,37 @@ bool add_analysis_contents_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_analysis_contents_module);
- module = PyModule_Create(&py_chrysalide_contents_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_contents_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.contents");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "contents", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis.contents'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_encaps_content(module);
- result &= register_python_file_content(module);
- result &= register_python_memory_content(module);
- result &= register_python_restricted_content(module);
+bool populate_analysis_contents_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.analysis.contents", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_encaps_content_is_registered();
+ if (result) result = ensure_python_file_content_is_registered();
+ if (result) result = ensure_python_memory_content_is_registered();
+ if (result) result = ensure_python_restricted_content_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/analysis/contents/module.h b/plugins/pychrysalide/analysis/contents/module.h
index 5c7418a..441e515 100644
--- a/plugins/pychrysalide/analysis/contents/module.h
+++ b/plugins/pychrysalide/analysis/contents/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'contents' au module Python. */
-bool add_analysis_contents_module_to_python_module(PyObject *);
+/* Ajoute le module 'analysis.contents' à un module Python. */
+bool add_analysis_contents_module(PyObject *);
+
+/* Intègre les objets du module 'analysis.contents'. */
+bool populate_analysis_contents_module(void);
diff --git a/plugins/pychrysalide/analysis/contents/restricted.c b/plugins/pychrysalide/analysis/contents/restricted.c
index f8b0b98..edd6666 100644
--- a/plugins/pychrysalide/analysis/contents/restricted.c
+++ b/plugins/pychrysalide/analysis/contents/restricted.c
@@ -35,6 +35,7 @@
#include "../content.h"
+#include "../../access.h"
#include "../../helpers.h"
#include "../../arch/vmpa.h"
@@ -155,18 +156,24 @@ PyTypeObject *get_python_restricted_content_type(void)
* *
******************************************************************************/
-bool register_python_restricted_content(PyObject *module)
+bool ensure_python_restricted_content_is_registered(void)
{
- PyTypeObject *py_restricted_content_type;/* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'Restricted...' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_restricted_content_type = get_python_restricted_content_type();
+ type = get_python_restricted_content_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.contents");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_RESTRICTED_CONTENT,
- py_restricted_content_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_RESTRICTED_CONTENT, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/contents/restricted.h b/plugins/pychrysalide/analysis/contents/restricted.h
index 5b7b910..35eb3fb 100644
--- a/plugins/pychrysalide/analysis/contents/restricted.h
+++ b/plugins/pychrysalide/analysis/contents/restricted.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_restricted_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.contents.RestrictedContent'. */
-bool register_python_restricted_content(PyObject *);
+bool ensure_python_restricted_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/db/certs.c b/plugins/pychrysalide/analysis/db/certs.c
index e0358d1..385e277 100644
--- a/plugins/pychrysalide/analysis/db/certs.c
+++ b/plugins/pychrysalide/analysis/db/certs.c
@@ -33,6 +33,7 @@
#include <analysis/db/certs.h>
+#include "../../access.h"
#include "../../helpers.h"
@@ -307,21 +308,31 @@ PyTypeObject *get_python_certs_type(void)
* *
******************************************************************************/
-bool register_python_certs(PyObject *module)
+bool ensure_python_certs_is_registered(void)
{
- PyTypeObject *py_certs_type; /* Type Python pour 'certs' */
+ PyTypeObject *type; /* Type Python pour 'certs' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_certs_type = get_python_certs_type();
+ type = get_python_certs_type();
- py_certs_type->tp_new = PyType_GenericNew;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ type->tp_new = PyType_GenericNew;
- if (PyType_Ready(py_certs_type) != 0)
- return false;
+ if (PyType_Ready(type) != 0)
+ return false;
- Py_INCREF(py_certs_type);
- ret = PyModule_AddObject(module, "certs", (PyObject *)py_certs_type);
+ module = get_access_to_python_module("pychrysalide.analysis.db");
- return (ret == 0);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "certs", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
+
+ return true;
}
diff --git a/plugins/pychrysalide/analysis/db/certs.h b/plugins/pychrysalide/analysis/db/certs.h
index 2e90778..c9769b9 100644
--- a/plugins/pychrysalide/analysis/db/certs.h
+++ b/plugins/pychrysalide/analysis/db/certs.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_certs_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.db.certs'. */
-bool register_python_certs(PyObject *);
+bool ensure_python_certs_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/db/collection.c b/plugins/pychrysalide/analysis/db/collection.c
index 80fcfc2..7f8ac2d 100644
--- a/plugins/pychrysalide/analysis/db/collection.c
+++ b/plugins/pychrysalide/analysis/db/collection.c
@@ -32,6 +32,7 @@
#include <analysis/db/collection.h>
+#include "../../access.h"
#include "../../helpers.h"
@@ -93,17 +94,24 @@ PyTypeObject *get_python_db_collection_type(void)
* *
******************************************************************************/
-bool register_python_db_collection(PyObject *module)
+bool ensure_python_db_collection_is_registered(void)
{
- PyTypeObject *py_db_collection_type; /* Type Python 'DbCollection' */
+ PyTypeObject *type; /* Type Python 'DbCollection' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_db_collection_type = get_python_db_collection_type();
+ type = get_python_db_collection_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.format");
- if (!register_class_for_pygobject(dict, G_TYPE_DB_COLLECTION, py_db_collection_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_COLLECTION, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/db/collection.h b/plugins/pychrysalide/analysis/db/collection.h
index 76256bc..9fa3c8a 100644
--- a/plugins/pychrysalide/analysis/db/collection.h
+++ b/plugins/pychrysalide/analysis/db/collection.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_db_collection_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.db.DbCollection'. */
-bool register_python_db_collection(PyObject *);
+bool ensure_python_db_collection_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/db/item.c b/plugins/pychrysalide/analysis/db/item.c
index 27b5bac..23e6933 100644
--- a/plugins/pychrysalide/analysis/db/item.c
+++ b/plugins/pychrysalide/analysis/db/item.c
@@ -32,6 +32,7 @@
#include <analysis/db/item.h>
+#include "../../access.h"
#include "../../helpers.h"
@@ -165,17 +166,24 @@ PyTypeObject *get_python_db_item_type(void)
* *
******************************************************************************/
-bool register_python_db_item(PyObject *module)
+bool ensure_python_db_item_is_registered(void)
{
- PyTypeObject *py_db_item_type; /* Type Python 'DbItem' */
+ PyTypeObject *type; /* Type Python 'DbItem' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_db_item_type = get_python_db_item_type();
+ type = get_python_db_item_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.format");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, py_db_item_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_DB_ITEM, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/db/item.h b/plugins/pychrysalide/analysis/db/item.h
index 96122e6..376371b 100644
--- a/plugins/pychrysalide/analysis/db/item.h
+++ b/plugins/pychrysalide/analysis/db/item.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_db_item_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.db.DbItem'. */
-bool register_python_db_item(PyObject *);
+bool ensure_python_db_item_is_registered(void);
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);
diff --git a/plugins/pychrysalide/analysis/db/module.c b/plugins/pychrysalide/analysis/db/module.c
index 1c4da25..33af35f 100644
--- a/plugins/pychrysalide/analysis/db/module.c
+++ b/plugins/pychrysalide/analysis/db/module.c
@@ -32,29 +32,28 @@
#include "collection.h"
#include "item.h"
#include "items/module.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 'db' au module Python. *
+* Description : Ajoute le module 'analysis.db' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_analysis_db_module_to_python_module(PyObject *super)
+bool add_analysis_db_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_db_module = {
+ static PyModuleDef py_chrysalide_analysis_db_module = {
.m_base = PyModuleDef_HEAD_INIT,
@@ -65,33 +64,43 @@ bool add_analysis_db_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_analysis_db_module);
- module = PyModule_Create(&py_chrysalide_db_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_db_module);
- if (ret != 0) goto loading_failed;
+ if (result) result = add_analysis_db_items_module(module);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.db");
- if (ret != 0) goto loading_failed;
+ if (!result)
+ Py_XDECREF(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "db", module);
- if (ret != 0) goto loading_failed;
+ return result;
- result = true;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis.db'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_certs(module);
- result &= register_python_db_collection(module);
- result &= register_python_db_item(module);
+bool populate_analysis_db_module(void)
+{
+ bool result; /* Bilan à retourner */
- result &= add_analysis_db_items_module_to_python_module(module);
+ result = true;
- if (result)
- register_access_to_python_module("pychrysalide.analysis.db", module);
+ if (result) result = ensure_python_certs_is_registered();
+ if (result) result = ensure_python_db_collection_is_registered();
+ if (result) result = ensure_python_db_item_is_registered();
- loading_failed:
+ if (result) result = populate_analysis_db_items_module();
assert(result);
diff --git a/plugins/pychrysalide/analysis/db/module.h b/plugins/pychrysalide/analysis/db/module.h
index d545ecb..80ee1f5 100644
--- a/plugins/pychrysalide/analysis/db/module.h
+++ b/plugins/pychrysalide/analysis/db/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'db' au module Python. */
-bool add_analysis_db_module_to_python_module(PyObject *);
+/* Ajoute le module 'analysis.db' à un module Python. */
+bool add_analysis_db_module(PyObject *);
+
+/* Intègre les objets du module 'analysis.db'. */
+bool populate_analysis_db_module(void);
diff --git a/plugins/pychrysalide/analysis/loaded.c b/plugins/pychrysalide/analysis/loaded.c
index 9b280a2..ac8176f 100644
--- a/plugins/pychrysalide/analysis/loaded.c
+++ b/plugins/pychrysalide/analysis/loaded.c
@@ -36,6 +36,9 @@
#include <analysis/loaded.h>
+#include "../access.h"
+
+
/* Lance l'analyse propre à l'élément chargé. */
static PyObject *py_loaded_content_analyze(PyObject *, PyObject *);
@@ -251,7 +254,7 @@ PyTypeObject *get_python_loaded_content_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.....LoadedContent'. *
* *
@@ -261,15 +264,22 @@ PyTypeObject *get_python_loaded_content_type(void)
* *
******************************************************************************/
-bool register_python_loaded_content(PyObject *module)
+bool ensure_python_loaded_content_is_registered(void)
{
- PyTypeObject *py_loaded_content_type; /* Type Python 'LoadedContent' */
+ PyTypeObject *type; /* Type Python 'LoadedContent' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_loaded_content_type = get_python_loaded_content_type();
+ type = get_python_loaded_content_type();
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "LoadedContent", G_TYPE_LOADED_CONTENT, py_loaded_content_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "LoadedContent", G_TYPE_LOADED_CONTENT, type);
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/loaded.h b/plugins/pychrysalide/analysis/loaded.h
index 8f9478b..d87867f 100644
--- a/plugins/pychrysalide/analysis/loaded.h
+++ b/plugins/pychrysalide/analysis/loaded.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_loaded_content_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.LoadedContent'. */
-bool register_python_loaded_content(PyObject *);
+bool ensure_python_loaded_content_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/loading.c b/plugins/pychrysalide/analysis/loading.c
index fca9929..77ff7fa 100644
--- a/plugins/pychrysalide/analysis/loading.c
+++ b/plugins/pychrysalide/analysis/loading.c
@@ -31,6 +31,7 @@
#include <analysis/loading.h>
+#include "../access.h"
#include "../helpers.h"
@@ -92,7 +93,7 @@ PyTypeObject *get_python_content_explorer_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide...ContentExplorer'. *
* *
@@ -102,17 +103,24 @@ PyTypeObject *get_python_content_explorer_type(void)
* *
******************************************************************************/
-bool register_python_content_explorer(PyObject *module)
+bool ensure_python_content_explorer_is_registered(void)
{
- PyTypeObject *py_content_explorer_type; /* Type 'ContentExplorer' */
+ PyTypeObject *type; /* Type 'ContentExplorer' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_content_explorer_type = get_python_content_explorer_type();
+ type = get_python_content_explorer_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_CONTENT_EXPLORER, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_CONTENT_EXPLORER, py_content_explorer_type, &PyGObject_Type))
- return false;
+ }
return true;
@@ -169,7 +177,7 @@ PyTypeObject *get_python_content_resolver_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide...ContentResolver'. *
* *
@@ -179,17 +187,24 @@ PyTypeObject *get_python_content_resolver_type(void)
* *
******************************************************************************/
-bool register_python_content_resolver(PyObject *module)
+bool ensure_python_content_resolver_is_registered(void)
{
- PyTypeObject *py_content_resolver_type; /* Type 'ContentResolver' */
+ PyTypeObject *type; /* Type 'ContentResolver' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_content_resolver_type = get_python_content_resolver_type();
+ type = get_python_content_resolver_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_CONTENT_RESOLVER, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_CONTENT_RESOLVER, py_content_resolver_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/loading.h b/plugins/pychrysalide/analysis/loading.h
index 56cdd21..948b80e 100644
--- a/plugins/pychrysalide/analysis/loading.h
+++ b/plugins/pychrysalide/analysis/loading.h
@@ -38,7 +38,7 @@
PyTypeObject *get_python_content_explorer_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.ContentExplorer'. */
-bool register_python_content_explorer(PyObject *);
+bool ensure_python_content_explorer_is_registered(void);
@@ -49,7 +49,7 @@ bool register_python_content_explorer(PyObject *);
PyTypeObject *get_python_content_resolver_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.ContentResolver'. */
-bool register_python_content_resolver(PyObject *);
+bool ensure_python_content_resolver_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/module.c b/plugins/pychrysalide/analysis/module.c
index 60f08ce..cafb4fa 100644
--- a/plugins/pychrysalide/analysis/module.c
+++ b/plugins/pychrysalide/analysis/module.c
@@ -40,27 +40,26 @@
#include "contents/module.h"
#include "db/module.h"
#include "types/module.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 'analysis' au module Python. *
+* Description : Ajoute le module 'analysis' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_analysis_module_to_python_module(PyObject *super)
+bool add_analysis_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_analysis_module = {
@@ -73,43 +72,54 @@ bool add_analysis_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_analysis_module);
- module = PyModule_Create(&py_chrysalide_analysis_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_analysis_module);
- if (ret != 0) goto loading_failed;
+ if (result) result = add_analysis_contents_module(module);
+ if (result) result = add_analysis_db_module(module);
+ if (result) result = add_analysis_types_module(module);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis");
- if (ret != 0) goto loading_failed;
+ if (!result)
+ Py_XDECREF(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "analysis", module);
- if (ret != 0) goto loading_failed;
+ return result;
- result = true;
+}
- result &= register_python_binary_content(module);
- result &= register_python_loaded_content(module);
- result &= register_python_content_explorer(module);
- result &= register_python_content_resolver(module);
- result &= register_python_loaded_binary(module);
- result &= register_python_instr_block(module);
- result &= register_python_binary_routine(module);
- result &= register_python_data_type(module);
- result &= register_python_study_project(module);
- result &= register_python_binary_variable(module);
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= add_analysis_contents_module_to_python_module(module);
- result &= add_analysis_db_module_to_python_module(module);
- result &= add_analysis_types_module_to_python_module(module);
+bool populate_analysis_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.analysis", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_loaded_binary_is_registered();
+ if (result) result = ensure_python_instr_block_is_registered();
+ if (result) result = ensure_python_binary_content_is_registered();
+ if (result) result = ensure_python_loaded_content_is_registered();
+ if (result) result = ensure_python_content_explorer_is_registered();
+ if (result) result = ensure_python_content_resolver_is_registered();
+ if (result) result = ensure_python_study_project_is_registered();
+ if (result) result = ensure_python_binary_routine_is_registered();
+ if (result) result = ensure_python_data_type_is_registered();
+ if (result) result = ensure_python_binary_variable_is_registered();
+
+ if (result) result = populate_analysis_contents_module();
+ if (result) result = populate_analysis_db_module();
+ if (result) result = populate_analysis_types_module();
assert(result);
diff --git a/plugins/pychrysalide/analysis/module.h b/plugins/pychrysalide/analysis/module.h
index 310fc0c..cf6c1c6 100644
--- a/plugins/pychrysalide/analysis/module.h
+++ b/plugins/pychrysalide/analysis/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'analysis' au module Python. */
-bool add_analysis_module_to_python_module(PyObject *);
+/* Ajoute le module 'analysis' à un module Python. */
+bool add_analysis_module(PyObject *);
+
+/* Intègre les objets du module 'analysis'. */
+bool populate_analysis_module(void);
diff --git a/plugins/pychrysalide/analysis/project.c b/plugins/pychrysalide/analysis/project.c
index fa7de72..62ce43b 100644
--- a/plugins/pychrysalide/analysis/project.c
+++ b/plugins/pychrysalide/analysis/project.c
@@ -33,6 +33,7 @@
#include "loaded.h"
+#include "../access.h"
#include "../helpers.h"
@@ -216,7 +217,7 @@ PyTypeObject *get_python_study_project_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.StudyProject'.*
* *
@@ -226,17 +227,24 @@ PyTypeObject *get_python_study_project_type(void)
* *
******************************************************************************/
-bool register_python_study_project(PyObject *module)
+bool ensure_python_study_project_is_registered(void)
{
- PyTypeObject *py_study_project_type; /* Type Python 'StudyProject' */
+ PyTypeObject *type; /* Type Python 'StudyProject' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_study_project_type = get_python_study_project_type();
+ type = get_python_study_project_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_STUDY_PROJECT, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_STUDY_PROJECT, py_study_project_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/project.h b/plugins/pychrysalide/analysis/project.h
index 7909604..1e0c698 100644
--- a/plugins/pychrysalide/analysis/project.h
+++ b/plugins/pychrysalide/analysis/project.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_study_project_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.StudyProject'. */
-bool register_python_study_project(PyObject *);
+bool ensure_python_study_project_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/routine.c b/plugins/pychrysalide/analysis/routine.c
index fddc026..1e255bb 100644
--- a/plugins/pychrysalide/analysis/routine.c
+++ b/plugins/pychrysalide/analysis/routine.c
@@ -38,6 +38,7 @@
#include "block.h"
#include "type.h"
+#include "../access.h"
#include "../helpers.h"
#include "../format/symbol.h"
@@ -651,7 +652,7 @@ PyTypeObject *get_python_binary_routine_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.BinRoutine'. *
* *
@@ -661,18 +662,27 @@ PyTypeObject *get_python_binary_routine_type(void)
* *
******************************************************************************/
-bool register_python_binary_routine(PyObject *module)
+bool ensure_python_binary_routine_is_registered(void)
{
- PyTypeObject *py_binary_routine_type; /* Type Python 'BinRoutine' */
+ PyTypeObject *type; /* Type Python 'BinRoutine' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_binary_routine_type = get_python_binary_routine_type();
+ type = get_python_binary_routine_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_binary_symbol_is_registered())
+ return false;
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_ROUTINE, type, get_python_binary_symbol_type()))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_BIN_ROUTINE,
- py_binary_routine_type, get_python_binary_symbol_type()))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/routine.h b/plugins/pychrysalide/analysis/routine.h
index 71d71dc..702cbd8 100644
--- a/plugins/pychrysalide/analysis/routine.h
+++ b/plugins/pychrysalide/analysis/routine.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_binary_routine_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.BinRoutine'. */
-bool register_python_binary_routine(PyObject *);
+bool ensure_python_binary_routine_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/type.c b/plugins/pychrysalide/analysis/type.c
index 3694877..ea81642 100644
--- a/plugins/pychrysalide/analysis/type.c
+++ b/plugins/pychrysalide/analysis/type.c
@@ -35,6 +35,7 @@
#include <analysis/type.h>
+#include "../access.h"
#include "../helpers.h"
@@ -419,7 +420,7 @@ static bool py_data_type_define_constants(PyTypeObject *obj_type)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.DataType'. *
* *
@@ -429,20 +430,27 @@ static bool py_data_type_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_data_type(PyObject *module)
+bool ensure_python_data_type_is_registered(void)
{
- PyTypeObject *py_data_type_type; /* Type Python 'DataType' */
+ PyTypeObject *type; /* Type Python 'DataType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_data_type_type = get_python_data_type_type();
+ type = get_python_data_type_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
- dict = PyModule_GetDict(module);
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_DATA_TYPE, py_data_type_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_DATA_TYPE, type, &PyGObject_Type))
+ return false;
- if (!py_data_type_define_constants(py_data_type_type))
- return false;
+ if (!py_data_type_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/type.h b/plugins/pychrysalide/analysis/type.h
index 03edfc7..e75a993 100644
--- a/plugins/pychrysalide/analysis/type.h
+++ b/plugins/pychrysalide/analysis/type.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_data_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.DataType'. */
-bool register_python_data_type(PyObject *);
+bool ensure_python_data_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/array.c b/plugins/pychrysalide/analysis/types/array.c
index 6f70b02..0e6760a 100644
--- a/plugins/pychrysalide/analysis/types/array.c
+++ b/plugins/pychrysalide/analysis/types/array.c
@@ -34,6 +34,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -408,17 +409,27 @@ PyTypeObject *get_python_array_type_type(void)
* *
******************************************************************************/
-bool register_python_array_type(PyObject *module)
+bool ensure_python_array_type_is_registered(void)
{
- PyTypeObject *py_array_type_type; /* Type Python 'ArrayType' */
+ PyTypeObject *type; /* Type Python 'ArrayType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_array_type_type = get_python_array_type_type();
+ type = get_python_array_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_ARRAY_TYPE, py_array_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_ARRAY_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/array.h b/plugins/pychrysalide/analysis/types/array.h
index 8762548..6abcfe4 100644
--- a/plugins/pychrysalide/analysis/types/array.h
+++ b/plugins/pychrysalide/analysis/types/array.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_array_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.ArrayType'. */
-bool register_python_array_type(PyObject *);
+bool ensure_python_array_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/basic.c b/plugins/pychrysalide/analysis/types/basic.c
index e3bde6e..f584bb6 100644
--- a/plugins/pychrysalide/analysis/types/basic.c
+++ b/plugins/pychrysalide/analysis/types/basic.c
@@ -33,6 +33,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -230,20 +231,30 @@ static bool py_basic_type_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_basic_type(PyObject *module)
+bool ensure_python_basic_type_is_registered(void)
{
- PyTypeObject *py_basic_type_type; /* Type Python 'BasicType' */
+ PyTypeObject *type; /* Type Python 'BasicType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_basic_type_type = get_python_basic_type_type();
+ type = get_python_basic_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_BASIC_TYPE, py_basic_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BASIC_TYPE, type, get_python_data_type_type()))
+ return false;
- if (!py_basic_type_define_constants(py_basic_type_type))
- return false;
+ if (!py_basic_type_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/basic.h b/plugins/pychrysalide/analysis/types/basic.h
index ced9312..87b30d8 100644
--- a/plugins/pychrysalide/analysis/types/basic.h
+++ b/plugins/pychrysalide/analysis/types/basic.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_basic_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.BasicType'. */
-bool register_python_basic_type(PyObject *);
+bool ensure_python_basic_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/cse.c b/plugins/pychrysalide/analysis/types/cse.c
index ff3984f..3444cc3 100644
--- a/plugins/pychrysalide/analysis/types/cse.c
+++ b/plugins/pychrysalide/analysis/types/cse.c
@@ -33,6 +33,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -248,21 +249,30 @@ static bool py_class_enum_type_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_class_enum_type(PyObject *module)
+bool ensure_python_class_enum_type_is_registered(void)
{
- PyTypeObject *py_class_enum_type_type; /* Type Python 'ClassEnumType' */
+ PyTypeObject *type; /* Type Python 'ClassEnumType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_class_enum_type_type = get_python_class_enum_type_type();
+ type = get_python_class_enum_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE,
- py_class_enum_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_CLASS_ENUM_TYPE, type, get_python_data_type_type()))
+ return false;
- if (!py_class_enum_type_define_constants(py_class_enum_type_type))
- return false;
+ if (!py_class_enum_type_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/cse.h b/plugins/pychrysalide/analysis/types/cse.h
index 26d25d6..41b27f5 100644
--- a/plugins/pychrysalide/analysis/types/cse.h
+++ b/plugins/pychrysalide/analysis/types/cse.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_class_enum_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.ClassEnumType'. */
-bool register_python_class_enum_type(PyObject *);
+bool ensure_python_class_enum_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/encaps.c b/plugins/pychrysalide/analysis/types/encaps.c
index 6fa1487..3b5dc18 100644
--- a/plugins/pychrysalide/analysis/types/encaps.c
+++ b/plugins/pychrysalide/analysis/types/encaps.c
@@ -32,6 +32,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -241,21 +242,30 @@ static bool py_encapsulated_type_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_encapsulated_type(PyObject *module)
+bool ensure_python_encapsulated_type_is_registered(void)
{
- PyTypeObject *py_encapsulated_type_type;/* Type 'EncapsulatedType' */
+ PyTypeObject *type; /* Type 'EncapsulatedType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_encapsulated_type_type = get_python_encapsulated_type_type();
+ type = get_python_encapsulated_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
- if (!register_class_for_pygobject(dict, G_TYPE_ENCAPSULATED_TYPE,
- py_encapsulated_type_type, get_python_data_type_type()))
- return false;
+ dict = PyModule_GetDict(module);
- if (!py_encapsulated_type_define_constants(py_encapsulated_type_type))
- return false;
+ if (!ensure_python_data_type_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, G_TYPE_ENCAPSULATED_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ if (!py_encapsulated_type_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/encaps.h b/plugins/pychrysalide/analysis/types/encaps.h
index 227527e..f1acfc0 100644
--- a/plugins/pychrysalide/analysis/types/encaps.h
+++ b/plugins/pychrysalide/analysis/types/encaps.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_encapsulated_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.EncapsulatedType'. */
-bool register_python_encapsulated_type(PyObject *);
+bool ensure_python_encapsulated_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/expr.c b/plugins/pychrysalide/analysis/types/expr.c
index 2988af9..619b2da 100644
--- a/plugins/pychrysalide/analysis/types/expr.c
+++ b/plugins/pychrysalide/analysis/types/expr.c
@@ -33,6 +33,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -168,17 +169,27 @@ PyTypeObject *get_python_expr_type_type(void)
* *
******************************************************************************/
-bool register_python_expr_type(PyObject *module)
+bool ensure_python_expr_type_is_registered(void)
{
- PyTypeObject *py_expr_type_type; /* Type Python 'ExprType' */
+ PyTypeObject *type; /* Type Python 'ExprType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_expr_type_type = get_python_expr_type_type();
+ type = get_python_expr_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
- if (!register_class_for_pygobject(dict, G_TYPE_EXPR_TYPE, py_expr_type_type, get_python_data_type_type()))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, G_TYPE_EXPR_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/expr.h b/plugins/pychrysalide/analysis/types/expr.h
index 4764892..6df17bd 100644
--- a/plugins/pychrysalide/analysis/types/expr.h
+++ b/plugins/pychrysalide/analysis/types/expr.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_expr_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.ExprType'. */
-bool register_python_expr_type(PyObject *);
+bool ensure_python_expr_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/literal.c b/plugins/pychrysalide/analysis/types/literal.c
index 7523153..7299be6 100644
--- a/plugins/pychrysalide/analysis/types/literal.c
+++ b/plugins/pychrysalide/analysis/types/literal.c
@@ -32,6 +32,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -118,17 +119,27 @@ PyTypeObject *get_python_literal_type_type(void)
* *
******************************************************************************/
-bool register_python_literal_type(PyObject *module)
+bool ensure_python_literal_type_is_registered(void)
{
- PyTypeObject *py_literal_type_type; /* Type 'LiteralType' */
+ PyTypeObject *type; /* Type 'LiteralType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_literal_type_type = get_python_literal_type_type();
+ type = get_python_literal_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
- if (!register_class_for_pygobject(dict, G_TYPE_LITERAL_TYPE, py_literal_type_type, get_python_data_type_type()))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, G_TYPE_LITERAL_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/literal.h b/plugins/pychrysalide/analysis/types/literal.h
index 8340093..7e12a02 100644
--- a/plugins/pychrysalide/analysis/types/literal.h
+++ b/plugins/pychrysalide/analysis/types/literal.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_literal_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.LiteralType'. */
-bool register_python_literal_type(PyObject *);
+bool ensure_python_literal_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/module.c b/plugins/pychrysalide/analysis/types/module.c
index 1566014..baa8ad1 100644
--- a/plugins/pychrysalide/analysis/types/module.c
+++ b/plugins/pychrysalide/analysis/types/module.c
@@ -37,29 +37,28 @@
#include "override.h"
#include "proto.h"
#include "template.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 'types' au module Python. *
+* Description : Ajoute le module 'analysis.types' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_analysis_types_module_to_python_module(PyObject *super)
+bool add_analysis_types_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_types_module = {
+ static PyModuleDef py_chrysalide_analysis_types_module = {
.m_base = PyModuleDef_HEAD_INIT,
@@ -70,35 +69,42 @@ bool add_analysis_types_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_analysis_types_module);
- module = PyModule_Create(&py_chrysalide_types_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_types_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.analysis.types");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "types", module);
- if (ret != 0) goto loading_failed;
- result = register_python_array_type(module);
- if (result) result = register_python_basic_type(module);
- if (result) result = register_python_class_enum_type(module);
- if (result) result = register_python_expr_type(module);
- if (result) result = register_python_encapsulated_type(module);
- if (result) result = register_python_literal_type(module);
- if (result) result = register_python_override_type(module);
- if (result) result = register_python_proto_type(module);
- if (result) result = register_python_template_type(module);
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'analysis.types'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- if (result)
- register_access_to_python_module("pychrysalide.analysis.types", module);
+bool populate_analysis_types_module(void)
+{
+ bool result; /* Bilan à retourner */
- loading_failed:
+ result = true;
+
+ if (result) result = ensure_python_array_type_is_registered();
+ if (result) result = ensure_python_basic_type_is_registered();
+ if (result) result = ensure_python_class_enum_type_is_registered();
+ if (result) result = ensure_python_expr_type_is_registered();
+ if (result) result = ensure_python_encapsulated_type_is_registered();
+ if (result) result = ensure_python_literal_type_is_registered();
+ if (result) result = ensure_python_override_type_is_registered();
+ if (result) result = ensure_python_proto_type_is_registered();
+ if (result) result = ensure_python_template_type_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/analysis/types/module.h b/plugins/pychrysalide/analysis/types/module.h
index 2c6824d..a53d427 100644
--- a/plugins/pychrysalide/analysis/types/module.h
+++ b/plugins/pychrysalide/analysis/types/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'types' au module Python. */
-bool add_analysis_types_module_to_python_module(PyObject *);
+/* Ajoute le module 'analysis.types' à un module Python. */
+bool add_analysis_types_module(PyObject *);
+
+/* Intègre les objets du module 'analysis.types'. */
+bool populate_analysis_types_module(void);
diff --git a/plugins/pychrysalide/analysis/types/override.c b/plugins/pychrysalide/analysis/types/override.c
index 17e32e3..c4b57b6 100644
--- a/plugins/pychrysalide/analysis/types/override.c
+++ b/plugins/pychrysalide/analysis/types/override.c
@@ -32,6 +32,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -229,18 +230,27 @@ PyTypeObject *get_python_override_type_type(void)
* *
******************************************************************************/
-bool register_python_override_type(PyObject *module)
+bool ensure_python_override_type_is_registered(void)
{
- PyTypeObject *py_override_type_type;/* Type 'OverrideType' */
+ PyTypeObject *type; /* Type 'OverrideType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_override_type_type = get_python_override_type_type();
+ type = get_python_override_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_OVERRIDE_TYPE,
- py_override_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_OVERRIDE_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/override.h b/plugins/pychrysalide/analysis/types/override.h
index 2e874ca..cd9a3da 100644
--- a/plugins/pychrysalide/analysis/types/override.h
+++ b/plugins/pychrysalide/analysis/types/override.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_override_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.OverrideType'. */
-bool register_python_override_type(PyObject *);
+bool ensure_python_override_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/proto.c b/plugins/pychrysalide/analysis/types/proto.c
index ac60deb..0477f0d 100644
--- a/plugins/pychrysalide/analysis/types/proto.c
+++ b/plugins/pychrysalide/analysis/types/proto.c
@@ -33,6 +33,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -297,17 +298,27 @@ PyTypeObject *get_python_proto_type_type(void)
* *
******************************************************************************/
-bool register_python_proto_type(PyObject *module)
+bool ensure_python_proto_type_is_registered(void)
{
- PyTypeObject *py_proto_type_type; /* Type Python 'ProtoType' */
+ PyTypeObject *type; /* Type Python 'ProtoType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_proto_type_type = get_python_proto_type_type();
+ type = get_python_proto_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_PROTO_TYPE, py_proto_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_PROTO_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/proto.h b/plugins/pychrysalide/analysis/types/proto.h
index 4e98df2..44437e8 100644
--- a/plugins/pychrysalide/analysis/types/proto.h
+++ b/plugins/pychrysalide/analysis/types/proto.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_proto_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.ProtoType'. */
-bool register_python_proto_type(PyObject *);
+bool ensure_python_proto_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/types/template.c b/plugins/pychrysalide/analysis/types/template.c
index b8b13fb..cd2fa52 100644
--- a/plugins/pychrysalide/analysis/types/template.c
+++ b/plugins/pychrysalide/analysis/types/template.c
@@ -34,6 +34,7 @@
#include "../type.h"
+#include "../../access.h"
#include "../../helpers.h"
@@ -293,18 +294,27 @@ PyTypeObject *get_python_template_type_type(void)
* *
******************************************************************************/
-bool register_python_template_type(PyObject *module)
+bool ensure_python_template_type_is_registered(void)
{
- PyTypeObject *py_template_type_type; /* Type Python 'TemplateType' */
+ PyTypeObject *type; /* Type Python 'TemplateType' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_template_type_type = get_python_template_type_type();
+ type = get_python_template_type_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis.types");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_data_type_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_TEMPLATE_TYPE,
- py_template_type_type, get_python_data_type_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_TEMPLATE_TYPE, type, get_python_data_type_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/types/template.h b/plugins/pychrysalide/analysis/types/template.h
index d5665e1..34f4ccd 100644
--- a/plugins/pychrysalide/analysis/types/template.h
+++ b/plugins/pychrysalide/analysis/types/template.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_template_type_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.types.TemplateType'. */
-bool register_python_template_type(PyObject *);
+bool ensure_python_template_type_is_registered(void);
diff --git a/plugins/pychrysalide/analysis/variable.c b/plugins/pychrysalide/analysis/variable.c
index 268e3c9..030b26f 100644
--- a/plugins/pychrysalide/analysis/variable.c
+++ b/plugins/pychrysalide/analysis/variable.c
@@ -35,6 +35,7 @@
#include <analysis/variable.h>
+#include "../access.h"
#include "../helpers.h"
@@ -241,7 +242,7 @@ PyTypeObject *get_python_binary_variable_type(void)
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : - *
* *
* Description : Prend en charge l'objet 'pychrysalide.analysis.BinVariable'. *
* *
@@ -251,17 +252,24 @@ PyTypeObject *get_python_binary_variable_type(void)
* *
******************************************************************************/
-bool register_python_binary_variable(PyObject *module)
+bool ensure_python_binary_variable_is_registered(void)
{
- PyTypeObject *py_binary_variable_type; /* Type Python 'BinVariable' */
+ PyTypeObject *type; /* Type Python 'ProxyFeeder' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_binary_variable_type = get_python_binary_variable_type();
+ type = get_python_binary_variable_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.analysis");
- dict = PyModule_GetDict(module);
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_BIN_VARIABLE, py_binary_variable_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_VARIABLE, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/analysis/variable.h b/plugins/pychrysalide/analysis/variable.h
index dad56d6..da481de 100644
--- a/plugins/pychrysalide/analysis/variable.h
+++ b/plugins/pychrysalide/analysis/variable.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_binary_variable_type(void);
/* Prend en charge l'objet 'pychrysalide.analysis.BinVariable'. */
-bool register_python_binary_variable(PyObject *);
+bool ensure_python_binary_variable_is_registered(void);