summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide')
-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
-rw-r--r--plugins/pychrysalide/arch/immediate.c32
-rw-r--r--plugins/pychrysalide/arch/immediate.h2
-rw-r--r--plugins/pychrysalide/arch/instriter.c27
-rw-r--r--plugins/pychrysalide/arch/instriter.h2
-rw-r--r--plugins/pychrysalide/arch/instruction.c28
-rw-r--r--plugins/pychrysalide/arch/instruction.h2
-rw-r--r--plugins/pychrysalide/arch/module.c65
-rw-r--r--plugins/pychrysalide/arch/module.h7
-rw-r--r--plugins/pychrysalide/arch/operand.c22
-rw-r--r--plugins/pychrysalide/arch/operand.h2
-rw-r--r--plugins/pychrysalide/arch/processor.c24
-rw-r--r--plugins/pychrysalide/arch/processor.h2
-rw-r--r--plugins/pychrysalide/arch/raw.c24
-rw-r--r--plugins/pychrysalide/arch/raw.h2
-rw-r--r--plugins/pychrysalide/arch/targetableop.c18
-rw-r--r--plugins/pychrysalide/arch/targetableop.h2
-rw-r--r--plugins/pychrysalide/arch/vmpa.c57
-rw-r--r--plugins/pychrysalide/arch/vmpa.h4
-rw-r--r--plugins/pychrysalide/common/bits.c27
-rw-r--r--plugins/pychrysalide/common/bits.h2
-rw-r--r--plugins/pychrysalide/common/fnv1a.c31
-rw-r--r--plugins/pychrysalide/common/fnv1a.h2
-rw-r--r--plugins/pychrysalide/common/module.c57
-rw-r--r--plugins/pychrysalide/common/module.h7
-rw-r--r--plugins/pychrysalide/common/pathname.c31
-rw-r--r--plugins/pychrysalide/common/pathname.h2
-rw-r--r--plugins/pychrysalide/core/demanglers.c29
-rw-r--r--plugins/pychrysalide/core/demanglers.h2
-rw-r--r--plugins/pychrysalide/core/formats.c33
-rw-r--r--plugins/pychrysalide/core/formats.h2
-rw-r--r--plugins/pychrysalide/core/global.c29
-rw-r--r--plugins/pychrysalide/core/global.h2
-rw-r--r--plugins/pychrysalide/core/logs.c33
-rw-r--r--plugins/pychrysalide/core/logs.h2
-rw-r--r--plugins/pychrysalide/core/module.c54
-rw-r--r--plugins/pychrysalide/core/module.h7
-rw-r--r--plugins/pychrysalide/core/params.c33
-rw-r--r--plugins/pychrysalide/core/params.h2
-rw-r--r--plugins/pychrysalide/debug/debugger.c20
-rw-r--r--plugins/pychrysalide/debug/debugger.h2
-rw-r--r--plugins/pychrysalide/debug/gdbrsp/gdb.c21
-rw-r--r--plugins/pychrysalide/debug/gdbrsp/gdb.h2
-rw-r--r--plugins/pychrysalide/debug/gdbrsp/module.c46
-rw-r--r--plugins/pychrysalide/debug/gdbrsp/module.h7
-rw-r--r--plugins/pychrysalide/debug/module.c53
-rw-r--r--plugins/pychrysalide/debug/module.h7
-rw-r--r--plugins/pychrysalide/format/executable.c23
-rw-r--r--plugins/pychrysalide/format/executable.h2
-rw-r--r--plugins/pychrysalide/format/flat.c24
-rw-r--r--plugins/pychrysalide/format/flat.h2
-rw-r--r--plugins/pychrysalide/format/format.c26
-rw-r--r--plugins/pychrysalide/format/format.h4
-rw-r--r--plugins/pychrysalide/format/module.c54
-rw-r--r--plugins/pychrysalide/format/module.h7
-rw-r--r--plugins/pychrysalide/format/symbol.c28
-rw-r--r--plugins/pychrysalide/format/symbol.h4
-rw-r--r--plugins/pychrysalide/format/symiter.c27
-rw-r--r--plugins/pychrysalide/format/symiter.h2
-rw-r--r--plugins/pychrysalide/glibext/buffercache.c22
-rw-r--r--plugins/pychrysalide/glibext/buffercache.h2
-rw-r--r--plugins/pychrysalide/glibext/bufferline.c24
-rw-r--r--plugins/pychrysalide/glibext/bufferline.h2
-rw-r--r--plugins/pychrysalide/glibext/configuration.c70
-rw-r--r--plugins/pychrysalide/glibext/configuration.h6
-rw-r--r--plugins/pychrysalide/glibext/linegen.c18
-rw-r--r--plugins/pychrysalide/glibext/linegen.h2
-rw-r--r--plugins/pychrysalide/glibext/loadedpanel.c22
-rw-r--r--plugins/pychrysalide/glibext/loadedpanel.h2
-rw-r--r--plugins/pychrysalide/glibext/module.c58
-rw-r--r--plugins/pychrysalide/glibext/module.h7
-rw-r--r--plugins/pychrysalide/gtkext/blockdisplay.c26
-rw-r--r--plugins/pychrysalide/gtkext/blockdisplay.h2
-rw-r--r--plugins/pychrysalide/gtkext/bufferdisplay.c26
-rw-r--r--plugins/pychrysalide/gtkext/bufferdisplay.h2
-rw-r--r--plugins/pychrysalide/gtkext/displaypanel.c34
-rw-r--r--plugins/pychrysalide/gtkext/displaypanel.h2
-rw-r--r--plugins/pychrysalide/gtkext/dockable.c20
-rw-r--r--plugins/pychrysalide/gtkext/dockable.h2
-rw-r--r--plugins/pychrysalide/gtkext/module.c50
-rw-r--r--plugins/pychrysalide/gtkext/module.h7
-rw-r--r--plugins/pychrysalide/gui/editem.c22
-rw-r--r--plugins/pychrysalide/gui/editem.h2
-rw-r--r--plugins/pychrysalide/gui/module.c55
-rw-r--r--plugins/pychrysalide/gui/module.h7
-rw-r--r--plugins/pychrysalide/gui/panels/module.c50
-rw-r--r--plugins/pychrysalide/gui/panels/module.h7
-rw-r--r--plugins/pychrysalide/gui/panels/panel.c32
-rw-r--r--plugins/pychrysalide/gui/panels/panel.h2
-rw-r--r--plugins/pychrysalide/helpers.c62
-rw-r--r--plugins/pychrysalide/helpers.h8
-rw-r--r--plugins/pychrysalide/mangling/demangler.c20
-rw-r--r--plugins/pychrysalide/mangling/demangler.h2
-rw-r--r--plugins/pychrysalide/mangling/module.c46
-rw-r--r--plugins/pychrysalide/mangling/module.h7
-rw-r--r--plugins/pychrysalide/pychrysa.c36
157 files changed, 1841 insertions, 1014 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);
diff --git a/plugins/pychrysalide/arch/immediate.c b/plugins/pychrysalide/arch/immediate.c
index e3c5c34..5ee2d41 100644
--- a/plugins/pychrysalide/arch/immediate.c
+++ b/plugins/pychrysalide/arch/immediate.c
@@ -36,6 +36,8 @@
#include "operand.h"
+#include "targetableop.h"
+#include "../access.h"
#include "../helpers.h"
@@ -674,21 +676,33 @@ PyTypeObject *get_python_imm_operand_type(void)
* *
******************************************************************************/
-bool register_python_imm_operand(PyObject *module)
+bool ensure_python_imm_operand_is_registered(void)
{
- PyTypeObject *py_imm_operand_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'ImmOperand' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_imm_operand_type = get_python_imm_operand_type();
+ type = get_python_imm_operand_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.arch");
+
+ dict = PyModule_GetDict(module);
+
+ if (!ensure_python_arch_operand_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_IMM_OPERAND,
- py_imm_operand_type, get_python_arch_operand_type()))
- return false;
+ if (!ensure_python_targetable_operand_is_registered())
+ return false;
- if (!py_imm_operand_define_constants(py_imm_operand_type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_IMM_OPERAND, type, get_python_arch_operand_type()))
+ return false;
+
+ if (!py_imm_operand_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/immediate.h b/plugins/pychrysalide/arch/immediate.h
index 3c99b19..fd456e4 100644
--- a/plugins/pychrysalide/arch/immediate.h
+++ b/plugins/pychrysalide/arch/immediate.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_imm_operand_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.ImmOperand'. */
-bool register_python_imm_operand(PyObject *);
+bool ensure_python_imm_operand_is_registered(void);
diff --git a/plugins/pychrysalide/arch/instriter.c b/plugins/pychrysalide/arch/instriter.c
index 244a825..f665cba 100644
--- a/plugins/pychrysalide/arch/instriter.c
+++ b/plugins/pychrysalide/arch/instriter.c
@@ -32,6 +32,7 @@
#include "processor.h"
+#include "../access.h"
@@ -258,19 +259,29 @@ PyTypeObject *get_python_instr_iterator_type(void)
* *
******************************************************************************/
-bool register_python_instr_iterator(PyObject *module)
+bool ensure_python_instr_iterator_is_registered(void)
{
- PyTypeObject *py_instr_iterator_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'InstrIterator' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_instr_iterator_type = get_python_instr_iterator_type();
+ type = get_python_instr_iterator_type();
- if (PyType_Ready(py_instr_iterator_type) < 0)
- return false;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) < 0)
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.arch");
+
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "InstrIterator", (PyObject *)type);
- Py_INCREF(py_instr_iterator_type);
- ret = PyModule_AddObject(module, "InstrIterator", (PyObject *)py_instr_iterator_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/arch/instriter.h b/plugins/pychrysalide/arch/instriter.h
index 3cb0e38..543d988 100644
--- a/plugins/pychrysalide/arch/instriter.h
+++ b/plugins/pychrysalide/arch/instriter.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_instr_iterator_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.InstrIterator'. */
-bool register_python_instr_iterator(PyObject *);
+bool ensure_python_instr_iterator_is_registered(void);
diff --git a/plugins/pychrysalide/arch/instruction.c b/plugins/pychrysalide/arch/instruction.c
index d659c87..df5bc15 100644
--- a/plugins/pychrysalide/arch/instruction.c
+++ b/plugins/pychrysalide/arch/instruction.c
@@ -33,6 +33,7 @@
#include "vmpa.h"
+#include "../access.h"
#include "../helpers.h"
#include "../glibext/linegen.h"
@@ -498,23 +499,30 @@ PyTypeObject *get_python_arch_instruction_type(void)
* *
******************************************************************************/
-bool register_python_arch_instruction(PyObject *module)
+bool ensure_python_arch_instruction_is_registered(void)
{
- PyTypeObject *py_arch_instruction_type; /* Type Python 'ArchInstruc...'*/
+ PyTypeObject *type; /* Type Python 'ArchInstruc...'*/
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- PyTypeObject *py_line_generator_type; /* Type Python 'LineGenerator' */
- py_arch_instruction_type = get_python_arch_instruction_type();
+ type = get_python_arch_instruction_type();
- APPLY_ABSTRACT_FLAG(py_arch_instruction_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ APPLY_ABSTRACT_FLAG(type);
+
+ module = get_access_to_python_module("pychrysalide.arch");
- dict = PyModule_GetDict(module);
+ dict = PyModule_GetDict(module);
- py_line_generator_type = get_python_line_generator_type();
+ if (!ensure_python_line_generator_is_registered())
+ return false;
- if (!_register_class_for_pygobject(dict, G_TYPE_ARCH_INSTRUCTION, py_arch_instruction_type,
- &PyGObject_Type, py_line_generator_type, NULL))
- return false;
+ if (!_register_class_for_pygobject(dict, G_TYPE_ARCH_INSTRUCTION, type,
+ &PyGObject_Type, get_python_line_generator_type(), NULL))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/instruction.h b/plugins/pychrysalide/arch/instruction.h
index ef1f598..5433222 100644
--- a/plugins/pychrysalide/arch/instruction.h
+++ b/plugins/pychrysalide/arch/instruction.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_arch_instruction_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.ArchInstruction'. */
-bool register_python_arch_instruction(PyObject *);
+bool ensure_python_arch_instruction_is_registered(void);
diff --git a/plugins/pychrysalide/arch/module.c b/plugins/pychrysalide/arch/module.c
index 406b78c..c81a762 100644
--- a/plugins/pychrysalide/arch/module.c
+++ b/plugins/pychrysalide/arch/module.c
@@ -39,7 +39,6 @@
#include "raw.h"
#include "targetableop.h"
#include "vmpa.h"
-#include "../access.h"
#include "../helpers.h"
@@ -94,21 +93,20 @@ static bool py_base_define_constants(PyTypeObject *obj_type)
/******************************************************************************
* *
-* 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 'arch' au module Python. *
+* Description : Ajoute le module 'arch' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_arch_module_to_python_module(PyObject *super)
+bool add_arch_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_arch_module = {
@@ -121,41 +119,44 @@ bool add_arch_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_arch_module);
- module = PyModule_Create(&py_chrysalide_arch_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_arch_module);
- if (ret != 0) goto loading_failed;
+ if (result) result = py_base_define_constants(Py_TYPE(module));
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.arch");
- if (ret != 0) goto loading_failed;
-
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "arch", module);
- if (ret != 0) goto loading_failed;
-
- result = true;
+ return result;
- result &= py_base_define_constants(Py_TYPE(module));
+}
- result &= register_python_targetable_operand(module);
- result &= register_python_arch_instruction(module);
- result &= register_python_arch_operand(module);
- result &= register_python_arch_processor(module);
- result &= register_python_instr_iterator(module);
- result &= register_python_raw_instruction(module);
- result &= register_python_vmpa(module);
- result &= register_python_mrange(module);
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'arch'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_imm_operand(module);
+bool populate_arch_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.arch", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_imm_operand_is_registered();
+ if (result) result = ensure_python_instr_iterator_is_registered();
+ if (result) result = ensure_python_arch_instruction_is_registered();
+ if (result) result = ensure_python_arch_operand_is_registered();
+ if (result) result = ensure_python_arch_processor_is_registered();
+ if (result) result = ensure_python_raw_instruction_is_registered();
+ if (result) result = ensure_python_targetable_operand_is_registered();
+ if (result) result = ensure_python_vmpa_is_registered();
+ if (result) result = ensure_python_mrange_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/arch/module.h b/plugins/pychrysalide/arch/module.h
index 07d3575..b4cde0e 100644
--- a/plugins/pychrysalide/arch/module.h
+++ b/plugins/pychrysalide/arch/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'arch' au module Python. */
-bool add_arch_module_to_python_module(PyObject *);
+/* Ajoute le module 'arch' à un module Python. */
+bool add_arch_module(PyObject *);
+
+/* Intègre les objets du module 'arch'. */
+bool populate_arch_module(void);
diff --git a/plugins/pychrysalide/arch/operand.c b/plugins/pychrysalide/arch/operand.c
index 427f92b..e464eac 100644
--- a/plugins/pychrysalide/arch/operand.c
+++ b/plugins/pychrysalide/arch/operand.c
@@ -31,6 +31,7 @@
#include <arch/operand.h>
+#include "../access.h"
#include "../helpers.h"
@@ -90,19 +91,26 @@ PyTypeObject *get_python_arch_operand_type(void)
* *
******************************************************************************/
-bool register_python_arch_operand(PyObject *module)
+bool ensure_python_arch_operand_is_registered(void)
{
- PyTypeObject *py_arch_operand_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'ArchOperand' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_arch_operand_type = get_python_arch_operand_type();
+ type = get_python_arch_operand_type();
- APPLY_ABSTRACT_FLAG(py_arch_operand_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ APPLY_ABSTRACT_FLAG(type);
- dict = PyModule_GetDict(module);
+ module = get_access_to_python_module("pychrysalide.arch");
- if (!register_class_for_pygobject(dict, G_TYPE_ARCH_OPERAND, py_arch_operand_type, &PyGObject_Type))
- return false;
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, G_TYPE_ARCH_OPERAND, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/operand.h b/plugins/pychrysalide/arch/operand.h
index 3ee7ed1..a718d8f 100644
--- a/plugins/pychrysalide/arch/operand.h
+++ b/plugins/pychrysalide/arch/operand.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_arch_operand_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.ArchOperand'. */
-bool register_python_arch_operand(PyObject *);
+bool ensure_python_arch_operand_is_registered(void);
diff --git a/plugins/pychrysalide/arch/processor.c b/plugins/pychrysalide/arch/processor.c
index c2ee530..3ac18fa 100644
--- a/plugins/pychrysalide/arch/processor.c
+++ b/plugins/pychrysalide/arch/processor.c
@@ -38,6 +38,7 @@
#include "instriter.h"
#include "instruction.h"
#include "vmpa.h"
+#include "../access.h"
#include "../helpers.h"
@@ -489,20 +490,27 @@ PyTypeObject *get_python_arch_processor_type(void)
* *
******************************************************************************/
-bool register_python_arch_processor(PyObject *module)
+bool ensure_python_arch_processor_is_registered(void)
{
- PyTypeObject *py_arch_processor_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'ArchProcessor' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_arch_processor_type = get_python_arch_processor_type();
+ type = get_python_arch_processor_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.arch");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_ARCH_PROCESSOR, py_arch_processor_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_ARCH_PROCESSOR, type, &PyGObject_Type))
+ return false;
- if (!define_python_arch_processor_constants(py_arch_processor_type))
- return false;
+ if (!define_python_arch_processor_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/processor.h b/plugins/pychrysalide/arch/processor.h
index ff6ccb3..2db8950 100644
--- a/plugins/pychrysalide/arch/processor.h
+++ b/plugins/pychrysalide/arch/processor.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_arch_processor_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.ArchProcessor'. */
-bool register_python_arch_processor(PyObject *);
+bool ensure_python_arch_processor_is_registered(void);
diff --git a/plugins/pychrysalide/arch/raw.c b/plugins/pychrysalide/arch/raw.c
index 39b5fe7..318eb6b 100644
--- a/plugins/pychrysalide/arch/raw.c
+++ b/plugins/pychrysalide/arch/raw.c
@@ -32,6 +32,7 @@
#include "instruction.h"
+#include "../access.h"
#include "../helpers.h"
@@ -243,20 +244,27 @@ PyTypeObject *get_python_raw_instruction_type(void)
* *
******************************************************************************/
-bool register_python_raw_instruction(PyObject *module)
+bool ensure_python_raw_instruction_is_registered(void)
{
- PyTypeObject *py_raw_instruction_type; /* Type Python 'RawInstruction'*/
+ PyTypeObject *type; /* Type Python 'RawInstruction'*/
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- PyTypeObject *base; /* Base parente pour héritage */
- py_raw_instruction_type = get_python_raw_instruction_type();
+ type = get_python_raw_instruction_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.arch");
- base = get_python_arch_instruction_type();
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_RAW_INSTRUCTION, py_raw_instruction_type, base))
- return false;
+ if (!ensure_python_arch_instruction_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, G_TYPE_RAW_INSTRUCTION, type, get_python_arch_instruction_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/raw.h b/plugins/pychrysalide/arch/raw.h
index 32c4e2d..552db41 100644
--- a/plugins/pychrysalide/arch/raw.h
+++ b/plugins/pychrysalide/arch/raw.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_raw_instruction_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.RawInstruction'. */
-bool register_python_raw_instruction(PyObject *);
+bool ensure_python_raw_instruction_is_registered(void);
diff --git a/plugins/pychrysalide/arch/targetableop.c b/plugins/pychrysalide/arch/targetableop.c
index 8951492..0fb23e0 100644
--- a/plugins/pychrysalide/arch/targetableop.c
+++ b/plugins/pychrysalide/arch/targetableop.c
@@ -37,6 +37,7 @@
#include "processor.h"
#include "vmpa.h"
+#include "../access.h"
#include "../format/format.h"
@@ -163,15 +164,22 @@ PyTypeObject *get_python_targetable_operand_type(void)
* *
******************************************************************************/
-bool register_python_targetable_operand(PyObject *module)
+bool ensure_python_targetable_operand_is_registered(void)
{
- PyTypeObject *py_targetable_operand_type; /* Type 'TargetableOperand' */
+ PyTypeObject *type; /* Type 'TargetableOperand' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_targetable_operand_type = get_python_targetable_operand_type();
+ type = get_python_targetable_operand_type();
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "TargetableOperand", G_TYPE_TARGETABLE_OPERAND, py_targetable_operand_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.arch");
+
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "TargetableOperand", G_TYPE_TARGETABLE_OPERAND, type);
+
+ }
return true;
diff --git a/plugins/pychrysalide/arch/targetableop.h b/plugins/pychrysalide/arch/targetableop.h
index d79bb87..4c41a4d 100644
--- a/plugins/pychrysalide/arch/targetableop.h
+++ b/plugins/pychrysalide/arch/targetableop.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_targetable_operand_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.TargetableOperand'. */
-bool register_python_targetable_operand(PyObject *);
+bool ensure_python_targetable_operand_is_registered(void);
diff --git a/plugins/pychrysalide/arch/vmpa.c b/plugins/pychrysalide/arch/vmpa.c
index 39b5cef..883491f 100644
--- a/plugins/pychrysalide/arch/vmpa.c
+++ b/plugins/pychrysalide/arch/vmpa.c
@@ -32,6 +32,7 @@
#include <i18n.h>
+#include "../access.h"
#include "../helpers.h"
@@ -678,23 +679,33 @@ PyTypeObject *get_python_vmpa_type(void)
* *
******************************************************************************/
-bool register_python_vmpa(PyObject *module)
+bool ensure_python_vmpa_is_registered(void)
{
- PyTypeObject *py_vmpa_type; /* Type Python pour 'vmpa' */
+ PyTypeObject *type; /* Type Python pour 'vmpa' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_vmpa_type = get_python_vmpa_type();
+ type = get_python_vmpa_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) != 0)
+ return false;
+
+ if (!py_vmpa_define_constants(type))
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.arch");
- if (PyType_Ready(py_vmpa_type) != 0)
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "vmpa", (PyObject *)type);
- if (!py_vmpa_define_constants(py_vmpa_type))
- return false;
+ if (ret != 0)
+ return false;
- Py_INCREF(py_vmpa_type);
- ret = PyModule_AddObject(module, "vmpa", (PyObject *)py_vmpa_type);
+ }
- return (ret == 0);
+ return true;
}
@@ -1234,20 +1245,30 @@ PyTypeObject *get_python_mrange_type(void)
* *
******************************************************************************/
-bool register_python_mrange(PyObject *module)
+bool ensure_python_mrange_is_registered(void)
{
- PyTypeObject *py_mrange_type; /* Type Python pour 'mrange' */
+ PyTypeObject *type; /* Type Python pour 'mrange' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_mrange_type = get_python_mrange_type();
+ type = get_python_mrange_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) != 0)
+ return false;
- if (PyType_Ready(py_mrange_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.arch");
- Py_INCREF(py_mrange_type);
- ret = PyModule_AddObject(module, "mrange", (PyObject *)py_mrange_type);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "mrange", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/arch/vmpa.h b/plugins/pychrysalide/arch/vmpa.h
index 46828f5..7705a10 100644
--- a/plugins/pychrysalide/arch/vmpa.h
+++ b/plugins/pychrysalide/arch/vmpa.h
@@ -38,7 +38,7 @@
PyTypeObject *get_python_vmpa_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.vmpa'. */
-bool register_python_vmpa(PyObject *);
+bool ensure_python_vmpa_is_registered(void);
/* Donne accès au coeur d'un objet 'pychrysalide.arch.vmpa'. */
vmpa2t *get_internal_vmpa(PyObject *);
@@ -58,7 +58,7 @@ int convert_any_to_vmpa(PyObject *, void *);
PyTypeObject *get_python_mrange_type(void);
/* Prend en charge l'objet 'pychrysalide.arch.mrange'. */
-bool register_python_mrange(PyObject *);
+bool ensure_python_mrange_is_registered(void);
/* Donne accès au coeur d'un objet 'pychrysalide.arch.mrange'. */
mrange_t *get_internal_mrange(PyObject *);
diff --git a/plugins/pychrysalide/common/bits.c b/plugins/pychrysalide/common/bits.c
index 065f32e..e137213 100644
--- a/plugins/pychrysalide/common/bits.c
+++ b/plugins/pychrysalide/common/bits.c
@@ -25,6 +25,7 @@
#include "bits.h"
+#include "../access.h"
#include "../helpers.h"
@@ -757,20 +758,30 @@ PyTypeObject *get_python_bitfield_type(void)
* *
******************************************************************************/
-bool register_python_bitfield(PyObject *module)
+bool ensure_python_bitfield_is_registered(void)
{
- PyTypeObject *py_bitfield_type; /* Type Python pour 'bitfield' */
+ PyTypeObject *type; /* Type Python pour 'bitfield' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_bitfield_type = get_python_bitfield_type();
+ type = get_python_bitfield_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) != 0)
+ return false;
- if (PyType_Ready(py_bitfield_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.common");
- Py_INCREF(py_bitfield_type);
- ret = PyModule_AddObject(module, "bitfield", (PyObject *)py_bitfield_type);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "bitfield", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/common/bits.h b/plugins/pychrysalide/common/bits.h
index 3e2af73..54a4414 100644
--- a/plugins/pychrysalide/common/bits.h
+++ b/plugins/pychrysalide/common/bits.h
@@ -38,7 +38,7 @@
PyTypeObject *get_python_bitfield_type(void);
/* Prend en charge l'objet 'pychrysalide.common.bitfield'. */
-bool register_python_bitfield(PyObject *);
+bool ensure_python_bitfield_is_registered(void);
/* Convertit une structure de type 'bitfield' en objet Python. */
PyObject *build_from_internal_bitfield(const bitfield_t *);
diff --git a/plugins/pychrysalide/common/fnv1a.c b/plugins/pychrysalide/common/fnv1a.c
index cc2c342..759c7ea 100644
--- a/plugins/pychrysalide/common/fnv1a.c
+++ b/plugins/pychrysalide/common/fnv1a.c
@@ -31,6 +31,9 @@
#include <common/fnv1a.h>
+#include "../access.h"
+
+
/* Détermine l'empreinte FNV1a d'une chaîne de caractères. */
static PyObject *py_fnv1a_hash(PyObject *, PyObject *);
@@ -125,21 +128,31 @@ PyTypeObject *get_python_fnv1a_type(void)
* *
******************************************************************************/
-bool register_python_fnv1a(PyObject *module)
+bool ensure_python_fnv1a_is_registered(void)
{
- PyTypeObject *py_fnv1a_type; /* Type Python pour 'fnv1a' */
+ PyTypeObject *type; /* Type Python pour 'fnv1a' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_fnv1a_type = get_python_fnv1a_type();
+ type = get_python_fnv1a_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ //type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(type) != 0)
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.common");
- //py_fnv1a_type->tp_new = PyType_GenericNew;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "fnv1a", (PyObject *)type);
- if (PyType_Ready(py_fnv1a_type) != 0)
- return false;
+ if (ret != 0)
+ return false;
- Py_INCREF(py_fnv1a_type);
- ret = PyModule_AddObject(module, "fnv1a", (PyObject *)py_fnv1a_type);
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/common/fnv1a.h b/plugins/pychrysalide/common/fnv1a.h
index 0a40770..07a5c6c 100644
--- a/plugins/pychrysalide/common/fnv1a.h
+++ b/plugins/pychrysalide/common/fnv1a.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_fnv1a_type(void);
/* Prend en charge l'objet 'pychrysalide.common.fnv1a'. */
-bool register_python_fnv1a(PyObject *);
+bool ensure_python_fnv1a_is_registered(void);
diff --git a/plugins/pychrysalide/common/module.c b/plugins/pychrysalide/common/module.c
index 7ff7528..9df257e 100644
--- a/plugins/pychrysalide/common/module.c
+++ b/plugins/pychrysalide/common/module.c
@@ -28,27 +28,26 @@
#include "bits.h"
#include "fnv1a.h"
#include "pathname.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 'common' au module Python. *
+* Description : Ajoute le module 'common' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_common_module_to_python_module(PyObject *super)
+bool add_common_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_common_module = {
@@ -61,38 +60,38 @@ bool add_common_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_common_module);
- module = PyModule_Create(&py_chrysalide_common_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_common_module);
- if (ret != 0) goto acmtpm_exit;
-
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.common");
- if (ret != 0) goto acmtpm_exit;
+ return result;
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "common", module);
- if (ret != 0) goto acmtpm_exit;
+}
- result = true;
- result &= register_python_bitfield(module);
- result &= register_python_fnv1a(module);
- result &= register_python_pathname(module);
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'common'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- if (result)
- register_access_to_python_module("pychrysalide.common", module);
+bool populate_common_module(void)
+{
+ bool result; /* Bilan à retourner */
- acmtpm_exit:
+ result = true;
- if (!result)
- {
- printf("something went wrong in %s...\n", __FUNCTION__);
- /* ... */
+ if (result) result = ensure_python_bitfield_is_registered();
+ if (result) result = ensure_python_fnv1a_is_registered();
+ if (result) result = ensure_python_pathname_is_registered();
- }
+ assert(result);
return result;
diff --git a/plugins/pychrysalide/common/module.h b/plugins/pychrysalide/common/module.h
index 446f6fe..ad25052 100644
--- a/plugins/pychrysalide/common/module.h
+++ b/plugins/pychrysalide/common/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'common' au module Python. */
-bool add_common_module_to_python_module(PyObject *);
+/* Ajoute le module 'common' à un module Python. */
+bool add_common_module(PyObject *);
+
+/* Intègre les objets du module 'common'. */
+bool populate_common_module(void);
diff --git a/plugins/pychrysalide/common/pathname.c b/plugins/pychrysalide/common/pathname.c
index 40977df..c2d69c6 100644
--- a/plugins/pychrysalide/common/pathname.c
+++ b/plugins/pychrysalide/common/pathname.c
@@ -35,6 +35,9 @@
#include <common/pathname.h>
+#include "../access.h"
+
+
/* Calcule le chemin relatif entre deux fichiers donnés. */
static PyObject *py_build_relative_filename(PyObject *, PyObject *);
@@ -183,21 +186,31 @@ PyTypeObject *get_python_pathname_type(void)
* *
******************************************************************************/
-bool register_python_pathname(PyObject *module)
+bool ensure_python_pathname_is_registered(void)
{
- PyTypeObject *py_pathname_type; /* Type Python pour 'pathname' */
+ PyTypeObject *type; /* Type Python pour 'pathname' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_pathname_type = get_python_pathname_type();
+ type = get_python_pathname_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ //type->tp_new = PyType_GenericNew;
- //py_pathname_type->tp_new = PyType_GenericNew;
+ if (PyType_Ready(type) != 0)
+ return false;
- if (PyType_Ready(py_pathname_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.common");
- Py_INCREF(py_pathname_type);
- ret = PyModule_AddObject(module, "pathname", (PyObject *)py_pathname_type);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "pathname", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/common/pathname.h b/plugins/pychrysalide/common/pathname.h
index a3940c9..d571f2f 100644
--- a/plugins/pychrysalide/common/pathname.h
+++ b/plugins/pychrysalide/common/pathname.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_pathname_type(void);
/* Prend en charge l'objet 'pychrysalide.common.pathname'. */
-bool register_python_pathname(PyObject *);
+bool ensure_python_pathname_is_registered(void);
diff --git a/plugins/pychrysalide/core/demanglers.c b/plugins/pychrysalide/core/demanglers.c
index c3c1881..2c98ee1 100644
--- a/plugins/pychrysalide/core/demanglers.c
+++ b/plugins/pychrysalide/core/demanglers.c
@@ -31,6 +31,7 @@
#include <core/demanglers.h>
+#include "../access.h"
#include "../helpers.h"
@@ -140,21 +141,31 @@ PyTypeObject *get_python_demanglers_type(void)
* *
******************************************************************************/
-bool register_python_demanglers(PyObject *module)
+bool ensure_python_demanglers_is_registered(void)
{
- PyTypeObject *py_demanglers_type; /* Type Python de 'demanglers' */
+ PyTypeObject *type; /* Type Python de 'demanglers' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_demanglers_type = get_python_demanglers_type();
+ type = get_python_demanglers_type();
- py_demanglers_type->tp_new = PyType_GenericNew;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(type) != 0)
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.core");
- if (PyType_Ready(py_demanglers_type) != 0)
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "demanglers", (PyObject *)type);
- Py_INCREF(py_demanglers_type);
- ret = PyModule_AddObject(module, "demanglers", (PyObject *)py_demanglers_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/core/demanglers.h b/plugins/pychrysalide/core/demanglers.h
index b17c4cb..5fc1cf0 100644
--- a/plugins/pychrysalide/core/demanglers.h
+++ b/plugins/pychrysalide/core/demanglers.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_demanglers_type(void);
/* Prend en charge l'objet 'pychrysalide.core.demanglers'. */
-bool register_python_demanglers(PyObject *);
+bool ensure_python_demanglers_is_registered(void);
diff --git a/plugins/pychrysalide/core/formats.c b/plugins/pychrysalide/core/formats.c
index 4f7c33a..f11bb46 100644
--- a/plugins/pychrysalide/core/formats.c
+++ b/plugins/pychrysalide/core/formats.c
@@ -31,6 +31,7 @@
#include <core/formats.h>
+#include "../access.h"
#include "../helpers.h"
@@ -167,24 +168,34 @@ static bool py_formats_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_formats(PyObject *module)
+bool ensure_python_formats_is_registered(void)
{
- PyTypeObject *py_formats_type; /* Type Python pour 'formats' */
+ PyTypeObject *type; /* Type Python pour 'formats' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_formats_type = get_python_formats_type();
+ type = get_python_formats_type();
- py_formats_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 (!py_formats_define_constants(type))
+ return false;
- if (PyType_Ready(py_formats_type) != 0)
- return false;
+ module = get_access_to_python_module("pychrysalide.core");
- if (!py_formats_define_constants(py_formats_type))
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "formats", (PyObject *)type);
- Py_INCREF(py_formats_type);
- ret = PyModule_AddObject(module, "formats", (PyObject *)py_formats_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/core/formats.h b/plugins/pychrysalide/core/formats.h
index ca12c3e..55d948a 100644
--- a/plugins/pychrysalide/core/formats.h
+++ b/plugins/pychrysalide/core/formats.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_formats_type(void);
/* Prend en charge l'objet 'pychrysalide.core.formats'. */
-bool register_python_formats(PyObject *);
+bool ensure_python_formats_is_registered(void);
diff --git a/plugins/pychrysalide/core/global.c b/plugins/pychrysalide/core/global.c
index 0fe767f..e84af68 100644
--- a/plugins/pychrysalide/core/global.c
+++ b/plugins/pychrysalide/core/global.c
@@ -31,6 +31,7 @@
#include <core/global.h>
+#include "../access.h"
#include "../helpers.h"
#include "../analysis/project.h"
@@ -260,21 +261,31 @@ PyTypeObject *get_python_global_type(void)
* *
******************************************************************************/
-bool register_python_global(PyObject *module)
+bool ensure_python_global_is_registered(void)
{
- PyTypeObject *py_global_type; /* Type Python de 'global' */
+ PyTypeObject *type; /* Type Python de 'global' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_global_type = get_python_global_type();
+ type = get_python_global_type();
- py_global_type->tp_new = PyType_GenericNew;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ type->tp_new = PyType_GenericNew;
+
+ if (PyType_Ready(type) != 0)
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.core");
- if (PyType_Ready(py_global_type) != 0)
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "_global", (PyObject *)type);
- Py_INCREF(py_global_type);
- ret = PyModule_AddObject(module, "_global", (PyObject *)py_global_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/core/global.h b/plugins/pychrysalide/core/global.h
index b136cdb..3246947 100644
--- a/plugins/pychrysalide/core/global.h
+++ b/plugins/pychrysalide/core/global.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_global_type(void);
/* Prend en charge l'objet 'pychrysalide.core._global'. */
-bool register_python_global(PyObject *);
+bool ensure_python_global_is_registered(void);
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;
}
diff --git a/plugins/pychrysalide/core/logs.h b/plugins/pychrysalide/core/logs.h
index a43d9ca..3165897 100644
--- a/plugins/pychrysalide/core/logs.h
+++ b/plugins/pychrysalide/core/logs.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_logs_type(void);
/* Prend en charge l'objet 'pychrysalide.core.logs'. */
-bool register_python_logs(PyObject *);
+bool ensure_python_logs_is_registered(void);
diff --git a/plugins/pychrysalide/core/module.c b/plugins/pychrysalide/core/module.c
index 22d9a48..6171e18 100644
--- a/plugins/pychrysalide/core/module.c
+++ b/plugins/pychrysalide/core/module.c
@@ -33,27 +33,26 @@
#include "global.h"
#include "logs.h"
#include "params.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 'core' au module Python. *
+* Description : Ajoute le module 'core' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_core_module_to_python_module(PyObject *super)
+bool add_core_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_core_module = {
@@ -66,33 +65,38 @@ bool add_core_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_core_module);
- module = PyModule_Create(&py_chrysalide_core_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_core_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.core");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "core", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'core'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_demanglers(module);
- result &= register_python_formats(module);
- result &= register_python_global(module);
- result &= register_python_logs(module);
- result &= register_python_params(module);
+bool populate_core_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.core", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_demanglers_is_registered();
+ if (result) result = ensure_python_formats_is_registered();
+ if (result) result = ensure_python_global_is_registered();
+ if (result) result = ensure_python_logs_is_registered();
+ if (result) result = ensure_python_params_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/core/module.h b/plugins/pychrysalide/core/module.h
index 8581425..c625c82 100644
--- a/plugins/pychrysalide/core/module.h
+++ b/plugins/pychrysalide/core/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'core' au module Python. */
-bool add_core_module_to_python_module(PyObject *);
+/* Ajoute le module 'core' à un module Python. */
+bool add_core_module(PyObject *);
+
+/* Intègre les objets du module 'core'. */
+bool populate_core_module(void);
diff --git a/plugins/pychrysalide/core/params.c b/plugins/pychrysalide/core/params.c
index df71a88..4a55a2b 100644
--- a/plugins/pychrysalide/core/params.c
+++ b/plugins/pychrysalide/core/params.c
@@ -31,6 +31,7 @@
#include <core/params.h>
+#include "../access.h"
#include "../helpers.h"
@@ -156,24 +157,34 @@ static bool py_params_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_params(PyObject *module)
+bool ensure_python_params_is_registered(void)
{
- PyTypeObject *py_params_type; /* Type Python pour 'params' */
+ PyTypeObject *type; /* Type Python pour 'params' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_params_type = get_python_params_type();
+ type = get_python_params_type();
- py_params_type->tp_new = PyType_GenericNew;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ type->tp_new = PyType_GenericNew;
- if (PyType_Ready(py_params_type) != 0)
- return false;
+ if (PyType_Ready(type) != 0)
+ return false;
- if (!py_params_define_constants(py_params_type))
- return false;
+ if (!py_params_define_constants(type))
+ return false;
- Py_INCREF(py_params_type);
- ret = PyModule_AddObject(module, "params", (PyObject *)py_params_type);
+ module = get_access_to_python_module("pychrysalide.core");
- return (ret == 0);
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "params", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
+
+ return true;
}
diff --git a/plugins/pychrysalide/core/params.h b/plugins/pychrysalide/core/params.h
index e7297b3..b3bcece 100644
--- a/plugins/pychrysalide/core/params.h
+++ b/plugins/pychrysalide/core/params.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_params_type(void);
/* Prend en charge l'objet 'pychrysalide.core.params'. */
-bool register_python_params(PyObject *);
+bool ensure_python_params_is_registered(void);
diff --git a/plugins/pychrysalide/debug/debugger.c b/plugins/pychrysalide/debug/debugger.c
index 5d8181f..0a7f97c 100644
--- a/plugins/pychrysalide/debug/debugger.c
+++ b/plugins/pychrysalide/debug/debugger.c
@@ -33,6 +33,7 @@
#include <debug/debugger.h>
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -1168,17 +1169,24 @@ PyTypeObject *get_python_binary_debugger_type(void)
* *
******************************************************************************/
-bool register_python_binary_debugger(PyObject *module)
+bool ensure_python_binary_debugger_is_registered(void)
{
- PyTypeObject *py_binary_debugger_type; /* Type Python 'BinaryDebugger'*/
+ PyTypeObject *type; /* Type Python 'BinaryDebugger'*/
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_binary_debugger_type = get_python_binary_debugger_type();
+ type = get_python_binary_debugger_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.debug");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_BINARY_DEBUGGER, py_binary_debugger_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BINARY_DEBUGGER, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/debug/debugger.h b/plugins/pychrysalide/debug/debugger.h
index 97f91ac..7a47456 100644
--- a/plugins/pychrysalide/debug/debugger.h
+++ b/plugins/pychrysalide/debug/debugger.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_binary_debugger_type(void);
/* Prend en charge l'objet 'pychrysalide.debug.BinaryDebugger'. */
-bool register_python_binary_debugger(PyObject *);
+bool ensure_python_binary_debugger_is_registered(void);
diff --git a/plugins/pychrysalide/debug/gdbrsp/gdb.c b/plugins/pychrysalide/debug/gdbrsp/gdb.c
index a4cde20..df56ca4 100644
--- a/plugins/pychrysalide/debug/gdbrsp/gdb.c
+++ b/plugins/pychrysalide/debug/gdbrsp/gdb.c
@@ -35,6 +35,7 @@
#include "../debugger.h"
+#include "../../access.h"
#include "../../helpers.h"
#include "../../analysis/binary.h"
@@ -148,18 +149,24 @@ PyTypeObject *get_python_gdb_debugger_type(void)
* *
******************************************************************************/
-bool register_python_gdb_debugger(PyObject *module)
+bool ensure_python_gdb_debugger_is_registered(void)
{
- PyTypeObject *py_gdb_debugger_type; /* Type Python 'GdbDebugger' */
+ PyTypeObject *type; /* Type Python 'GdbDebugger' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_gdb_debugger_type = get_python_gdb_debugger_type();
+ type = get_python_gdb_debugger_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.debug.gdbrsp");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_GDB_DEBUGGER,
- py_gdb_debugger_type, get_python_binary_debugger_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_GDB_DEBUGGER, type, get_python_binary_debugger_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/debug/gdbrsp/gdb.h b/plugins/pychrysalide/debug/gdbrsp/gdb.h
index 00afab5..057a38d 100644
--- a/plugins/pychrysalide/debug/gdbrsp/gdb.h
+++ b/plugins/pychrysalide/debug/gdbrsp/gdb.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_gdb_debugger_type(void);
/* Prend en charge l'objet 'pychrysalide.debug.gdbrsp.GdbDebugger'. */
-bool register_python_gdb_debugger(PyObject *);
+bool ensure_python_gdb_debugger_is_registered(void);
diff --git a/plugins/pychrysalide/debug/gdbrsp/module.c b/plugins/pychrysalide/debug/gdbrsp/module.c
index 6e7896c..c077aa7 100644
--- a/plugins/pychrysalide/debug/gdbrsp/module.c
+++ b/plugins/pychrysalide/debug/gdbrsp/module.c
@@ -26,28 +26,28 @@
#include "gdb.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 'debug.gdbrsp' au module Python. *
+* Description : Ajoute le module 'debug.gdbresp' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_debug_gdbrsp_module_to_python_module(PyObject *super)
+bool add_debug_gdbresp_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_gdbrsp_module = {
+ static PyModuleDef py_chrysalide_debug_gdbresp_module = {
.m_base = PyModuleDef_HEAD_INIT,
@@ -58,26 +58,34 @@ bool add_debug_gdbrsp_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_debug_gdbresp_module);
- module = PyModule_Create(&py_chrysalide_gdbrsp_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_gdbrsp_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.debug.gdbrsp");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "gdbrsp", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'debug.gdbresp'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_gdb_debugger(module);
+bool populate_debug_gdbresp_module(void)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_gdb_debugger_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/debug/gdbrsp/module.h b/plugins/pychrysalide/debug/gdbrsp/module.h
index edc2b11..0ed3719 100644
--- a/plugins/pychrysalide/debug/gdbrsp/module.h
+++ b/plugins/pychrysalide/debug/gdbrsp/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'debug.gdbrsp' au module Python. */
-bool add_debug_gdbrsp_module_to_python_module(PyObject *);
+/* Ajoute le module 'debug.gdbresp' à un module Python. */
+bool add_debug_gdbresp_module(PyObject *);
+
+/* Intègre les objets du module 'debug.gdbresp'. */
+bool populate_debug_gdbresp_module(void);
diff --git a/plugins/pychrysalide/debug/module.c b/plugins/pychrysalide/debug/module.c
index ea586be..a2df8bf 100644
--- a/plugins/pychrysalide/debug/module.c
+++ b/plugins/pychrysalide/debug/module.c
@@ -27,27 +27,26 @@
#include "debugger.h"
#include "gdbrsp/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 'debug' au module Python. *
+* Description : Ajoute le module 'debug' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_debug_module_to_python_module(PyObject *super)
+bool add_debug_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_debug_module = {
@@ -60,31 +59,41 @@ bool add_debug_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_debug_module);
- module = PyModule_Create(&py_chrysalide_debug_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_debug_module);
- if (ret != 0) goto loading_failed;
+ if (result) result = add_debug_gdbresp_module(module);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.debug");
- if (ret != 0) goto loading_failed;
+ if (!result)
+ Py_XDECREF(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "debug", module);
- if (ret != 0) goto loading_failed;
+ return result;
- result = true;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'debug'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_binary_debugger(module);
+bool populate_debug_module(void)
+{
+ bool result; /* Bilan à retourner */
- result &= add_debug_gdbrsp_module_to_python_module(module);
+ result = true;
- if (result)
- register_access_to_python_module("pychrysalide.debug", module);
+ if (result) result = ensure_python_binary_debugger_is_registered();
- loading_failed:
+ if (result) result = populate_debug_gdbresp_module();
assert(result);
diff --git a/plugins/pychrysalide/debug/module.h b/plugins/pychrysalide/debug/module.h
index b723ab8..0216652 100644
--- a/plugins/pychrysalide/debug/module.h
+++ b/plugins/pychrysalide/debug/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'debug' au module Python. */
-bool add_debug_module_to_python_module(PyObject *);
+/* Ajoute le module 'debug' à un module Python. */
+bool add_debug_module(PyObject *);
+
+/* Intègre les objets du module 'debug'. */
+bool populate_debug_module(void);
diff --git a/plugins/pychrysalide/format/executable.c b/plugins/pychrysalide/format/executable.c
index a3bcdd1..8e24699 100644
--- a/plugins/pychrysalide/format/executable.c
+++ b/plugins/pychrysalide/format/executable.c
@@ -32,6 +32,7 @@
#include "format.h"
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -198,17 +199,27 @@ PyTypeObject *get_python_executable_format_type(void)
* *
******************************************************************************/
-bool register_python_executable_format(PyObject *module)
+bool ensure_python_executable_format_is_registered(void)
{
- PyTypeObject *py_exe_format_type; /* Type Python 'ExeFormat' */
+ PyTypeObject *type; /* Type Python 'ExeFormat' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_exe_format_type = get_python_executable_format_type();
+ type = get_python_executable_format_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 (!ensure_python_binary_format_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_EXE_FORMAT, py_exe_format_type, get_python_binary_format_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_EXE_FORMAT, type, get_python_binary_format_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/format/executable.h b/plugins/pychrysalide/format/executable.h
index 2157b93..8a952cd 100644
--- a/plugins/pychrysalide/format/executable.h
+++ b/plugins/pychrysalide/format/executable.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_executable_format_type(void);
/* Prend en charge l'objet 'pychrysalide.format.ExeFormat'. */
-bool register_python_executable_format(PyObject *);
+bool ensure_python_executable_format_is_registered(void);
diff --git a/plugins/pychrysalide/format/flat.c b/plugins/pychrysalide/format/flat.c
index c85ee37..18ad414 100644
--- a/plugins/pychrysalide/format/flat.c
+++ b/plugins/pychrysalide/format/flat.c
@@ -32,6 +32,7 @@
#include "executable.h"
+#include "../access.h"
#include "../helpers.h"
#include "../analysis/content.h"
@@ -188,18 +189,27 @@ PyTypeObject *get_python_flat_format_type(void)
* *
******************************************************************************/
-bool register_python_flat_format(PyObject *module)
+bool ensure_python_flat_format_is_registered(void)
{
- PyTypeObject *py_flat_format_type; /* Type Python 'FlatFormat' */
+ PyTypeObject *type; /* Type Python 'FlatFormat' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_flat_format_type = get_python_flat_format_type();
+ type = get_python_flat_format_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 (!ensure_python_executable_format_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_FLAT_FORMAT, py_flat_format_type, \
- get_python_executable_format_type()))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_FLAT_FORMAT, type, get_python_executable_format_type()))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/format/flat.h b/plugins/pychrysalide/format/flat.h
index 92e5f9e..d7447dd 100644
--- a/plugins/pychrysalide/format/flat.h
+++ b/plugins/pychrysalide/format/flat.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_flat_format_type(void);
/* Prend en charge l'objet 'pychrysalide.format.FlatFormat'. */
-bool register_python_flat_format(PyObject *);
+bool ensure_python_flat_format_is_registered(void);
diff --git a/plugins/pychrysalide/format/format.c b/plugins/pychrysalide/format/format.c
index 561c0c2..bf6c3f1 100644
--- a/plugins/pychrysalide/format/format.c
+++ b/plugins/pychrysalide/format/format.c
@@ -33,6 +33,7 @@
#include "symbol.h"
#include "symiter.h"
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -732,22 +733,29 @@ PyTypeObject *get_python_binary_format_type(void)
* *
******************************************************************************/
-bool register_python_binary_format(PyObject *module)
+bool ensure_python_binary_format_is_registered(void)
{
- PyTypeObject *py_bin_format_type; /* Type Python 'BinFormat' */
+ PyTypeObject *type; /* Type Python 'BinFormat' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_bin_format_type = get_python_binary_format_type();
+ type = get_python_binary_format_type();
- APPLY_ABSTRACT_FLAG(py_bin_format_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.format");
+
+ APPLY_ABSTRACT_FLAG(type);
- dict = PyModule_GetDict(module);
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, py_bin_format_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_FORMAT, type, &PyGObject_Type))
+ return false;
- if (!define_python_binary_format_constants(py_bin_format_type))
- return false;
+ if (!define_python_binary_format_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/format/format.h b/plugins/pychrysalide/format/format.h
index a8dfbf0..6423821 100644
--- a/plugins/pychrysalide/format/format.h
+++ b/plugins/pychrysalide/format/format.h
@@ -38,7 +38,7 @@
PyTypeObject *get_python_binary_symbol_iterator_type(void);
/* Prend en charge l'objet 'pychrysalide...BinSymbolIterator'. */
-bool register_python_binary_symbol_iterator(PyObject *);
+bool ensure_python_binary_symbol_iterator_is_registered(void);
@@ -49,7 +49,7 @@ bool register_python_binary_symbol_iterator(PyObject *);
PyTypeObject *get_python_binary_format_type(void);
/* Prend en charge l'objet 'pychrysalide.format.BinFormat'. */
-bool register_python_binary_format(PyObject *);
+bool ensure_python_binary_format_is_registered(void);
diff --git a/plugins/pychrysalide/format/module.c b/plugins/pychrysalide/format/module.c
index 9a88dcd..46d8f43 100644
--- a/plugins/pychrysalide/format/module.c
+++ b/plugins/pychrysalide/format/module.c
@@ -33,27 +33,26 @@
#include "format.h"
#include "symbol.h"
#include "symiter.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 'format' au module Python. *
+* Description : Ajoute le module 'format' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_format_module_to_python_module(PyObject *super)
+bool add_format_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_format_module = {
@@ -66,33 +65,38 @@ bool add_format_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_format_module);
- module = PyModule_Create(&py_chrysalide_format_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_format_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.format");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "format", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'format'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_binary_format(module);
- result &= register_python_executable_format(module);
- result &= register_python_flat_format(module);
- result &= register_python_binary_symbol(module);
- result &= register_python_sym_iterator(module);
+bool populate_format_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.format", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_executable_format_is_registered();
+ if (result) result = ensure_python_flat_format_is_registered();
+ if (result) result = ensure_python_binary_format_is_registered();
+ if (result) result = ensure_python_binary_symbol_is_registered();
+ if (result) result = ensure_python_sym_iterator_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/format/module.h b/plugins/pychrysalide/format/module.h
index fb84580..5d305d4 100644
--- a/plugins/pychrysalide/format/module.h
+++ b/plugins/pychrysalide/format/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'format' au module Python. */
-bool add_format_module_to_python_module(PyObject *);
+/* Ajoute le module 'format' à un module Python. */
+bool add_format_module(PyObject *);
+
+/* Intègre les objets du module 'format'. */
+bool populate_format_module(void);
diff --git a/plugins/pychrysalide/format/symbol.c b/plugins/pychrysalide/format/symbol.c
index d6298d4..d2d1637 100644
--- a/plugins/pychrysalide/format/symbol.c
+++ b/plugins/pychrysalide/format/symbol.c
@@ -35,11 +35,13 @@
#include <format/symbol.h>
+#include "../access.h"
#include "../helpers.h"
#include "../analysis/routine.h"
#include "../analysis/db/items/comment.h"
#include "../arch/instruction.h"
#include "../arch/vmpa.h"
+#include "../glibext/linegen.h"
@@ -435,20 +437,30 @@ PyTypeObject *get_python_binary_symbol_type(void)
* *
******************************************************************************/
-bool register_python_binary_symbol(PyObject *module)
+bool ensure_python_binary_symbol_is_registered(void)
{
- PyTypeObject *py_bin_symbol_type; /* Type Python 'BinSymbol' */
+ PyTypeObject *type; /* Type Python 'BinSymbol' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_bin_symbol_type = get_python_binary_symbol_type();
+ type = get_python_binary_symbol_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 (!ensure_python_line_generator_is_registered())
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_BIN_SYMBOL, py_bin_symbol_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BIN_SYMBOL, type, &PyGObject_Type))
+ return false;
- if (!py_binary_symbol_define_constants(py_bin_symbol_type))
- return false;
+ if (!py_binary_symbol_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/format/symbol.h b/plugins/pychrysalide/format/symbol.h
index 913da74..a9161c6 100644
--- a/plugins/pychrysalide/format/symbol.h
+++ b/plugins/pychrysalide/format/symbol.h
@@ -35,8 +35,8 @@
PyTypeObject *get_python_binary_symbol_type(void);
/* Prend en charge l'objet 'pychrysalide.format.BinSymbol'. */
-bool register_python_binary_symbol(PyObject *);
+bool ensure_python_binary_symbol_is_registered(void);
-#endif /* _PLUGINS_PYCHRYSALIDE_FORMAT_EXECUTABLE_H */
+#endif /* _PLUGINS_PYCHRYSALIDE_FORMAT_SYMBOL_H */
diff --git a/plugins/pychrysalide/format/symiter.c b/plugins/pychrysalide/format/symiter.c
index db0b744..74a215d 100644
--- a/plugins/pychrysalide/format/symiter.c
+++ b/plugins/pychrysalide/format/symiter.c
@@ -32,6 +32,7 @@
#include "format.h"
+#include "../access.h"
@@ -258,19 +259,29 @@ PyTypeObject *get_python_sym_iterator_type(void)
* *
******************************************************************************/
-bool register_python_sym_iterator(PyObject *module)
+bool ensure_python_sym_iterator_is_registered(void)
{
- PyTypeObject *py_sym_iterator_type; /* Type Python 'BinContent' */
+ PyTypeObject *type; /* Type Python 'SymIterator' */
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_sym_iterator_type = get_python_sym_iterator_type();
+ type = get_python_sym_iterator_type();
- if (PyType_Ready(py_sym_iterator_type) < 0)
- return false;
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ if (PyType_Ready(type) < 0)
+ return false;
+
+ module = get_access_to_python_module("pychrysalide.format");
+
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "SymIterator", (PyObject *)type);
- Py_INCREF(py_sym_iterator_type);
- ret = PyModule_AddObject(module, "SymIterator", (PyObject *)py_sym_iterator_type);
+ if (ret != 0)
+ return false;
+
+ }
- return (ret == 0);
+ return true;
}
diff --git a/plugins/pychrysalide/format/symiter.h b/plugins/pychrysalide/format/symiter.h
index 6cc1d29..fc66884 100644
--- a/plugins/pychrysalide/format/symiter.h
+++ b/plugins/pychrysalide/format/symiter.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_sym_iterator_type(void);
/* Prend en charge l'objet 'pychrysalide.format.SymIterator'. */
-bool register_python_sym_iterator(PyObject *);
+bool ensure_python_sym_iterator_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/buffercache.c b/plugins/pychrysalide/glibext/buffercache.c
index f61d34f..b01b68c 100644
--- a/plugins/pychrysalide/glibext/buffercache.c
+++ b/plugins/pychrysalide/glibext/buffercache.c
@@ -31,8 +31,9 @@
#include <glibext/gbuffercache.h>
-#include "../arch/vmpa.h"
+#include "../access.h"
#include "../helpers.h"
+#include "../arch/vmpa.h"
@@ -148,17 +149,24 @@ PyTypeObject *get_python_buffer_cache_type(void)
* *
******************************************************************************/
-bool register_python_buffer_cache(PyObject *module)
+bool ensure_python_buffer_cache_is_registered(void)
{
- PyTypeObject *py_buffer_cache_type; /* Type Python 'BufferCache' */
+ PyTypeObject *type; /* Type Python 'BufferCache' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_buffer_cache_type = get_python_buffer_cache_type();
+ type = get_python_buffer_cache_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_CACHE, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_CACHE, py_buffer_cache_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/glibext/buffercache.h b/plugins/pychrysalide/glibext/buffercache.h
index dd41cfe..728acd7 100644
--- a/plugins/pychrysalide/glibext/buffercache.h
+++ b/plugins/pychrysalide/glibext/buffercache.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_buffer_cache_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. */
-bool register_python_buffer_cache(PyObject *);
+bool ensure_python_buffer_cache_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/bufferline.c b/plugins/pychrysalide/glibext/bufferline.c
index bfb894b..5bc8449 100644
--- a/plugins/pychrysalide/glibext/bufferline.c
+++ b/plugins/pychrysalide/glibext/bufferline.c
@@ -35,6 +35,7 @@
#include <glibext/gbufferline.h>
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -353,20 +354,27 @@ PyTypeObject *get_python_buffer_line_type(void)
* *
******************************************************************************/
-bool register_python_buffer_line(PyObject *module)
+bool ensure_python_buffer_line_is_registered(void)
{
- PyTypeObject *py_buffer_line_type; /* Type Python 'BufferLine' */
+ PyTypeObject *type; /* Type Python 'BufferLine' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_buffer_line_type = get_python_buffer_line_type();
+ type = get_python_buffer_line_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_LINE, py_buffer_line_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_LINE, type, &PyGObject_Type))
+ return false;
- if (!py_buffer_line_define_constants(py_buffer_line_type))
- return false;
+ if (!py_buffer_line_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/glibext/bufferline.h b/plugins/pychrysalide/glibext/bufferline.h
index d905de3..9fbebe5 100644
--- a/plugins/pychrysalide/glibext/bufferline.h
+++ b/plugins/pychrysalide/glibext/bufferline.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_buffer_line_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.BufferLine'. */
-bool register_python_buffer_line(PyObject *);
+bool ensure_python_buffer_line_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/configuration.c b/plugins/pychrysalide/glibext/configuration.c
index a780f73..18ed5db 100644
--- a/plugins/pychrysalide/glibext/configuration.c
+++ b/plugins/pychrysalide/glibext/configuration.c
@@ -31,6 +31,7 @@
#include <glibext/configuration.h>
+#include "../access.h"
#include "../helpers.h"
@@ -575,20 +576,27 @@ static bool py_config_param_define_constants(PyObject *dict)
* *
******************************************************************************/
-bool register_python_config_param(PyObject *module)
+bool ensure_python_config_param_is_registered(void)
{
- PyTypeObject *py_config_param_type; /* Type Python 'ConfigParam' */
+ PyTypeObject *type; /* Type Python 'ConfigParam' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_config_param_type = get_python_config_param_type();
+ type = get_python_config_param_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_CFG_PARAM, py_config_param_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_CFG_PARAM, type, &PyGObject_Type))
+ return false;
- if (!py_config_param_define_constants(py_config_param_type->tp_dict))
- return false;
+ if (!py_config_param_define_constants(type->tp_dict))
+ return false;
+
+ }
return true;
@@ -770,21 +778,30 @@ PyTypeObject *get_python_config_param_iterator_type(void)
* *
******************************************************************************/
-bool register_python_config_param_iterator(PyObject *module)
+bool ensure_python_config_param_iterator_is_registered(void)
{
- PyTypeObject *py_config_param_iterator_type;/* Type Python 'Cnf...Iter'*/
+ PyTypeObject *type; /* Type Python 'Cnf...Iter'*/
+ PyObject *module; /* Module à recompléter */
int ret; /* Bilan d'un appel */
- py_config_param_iterator_type = get_python_config_param_iterator_type();
+ type = get_python_config_param_iterator_type();
+
+ type->tp_base = &PyBaseObject_Type;
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
- py_config_param_iterator_type->tp_base = &PyBaseObject_Type;
+ if (PyType_Ready(type) != 0)
+ return false;
- if (PyType_Ready(py_config_param_iterator_type) != 0)
- return false;
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "ConfigParamIterator", (PyObject *)type);
- Py_INCREF(py_config_param_iterator_type);
- ret = PyModule_AddObject(module, "ConfigParamIterator", (PyObject *)py_config_param_iterator_type);
- if (ret != 0) return false;
+ if (ret != 0)
+ return false;
+
+ }
return true;
@@ -1148,17 +1165,24 @@ PyTypeObject *get_python_generic_config_type(void)
* *
******************************************************************************/
-bool register_python_generic_config(PyObject *module)
+bool ensure_python_generic_config_is_registered(void)
{
- PyTypeObject *py_generic_config_type; /* Type Python 'GenConfig' */
+ PyTypeObject *type; /* Type Python 'GenConfig' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_generic_config_type = get_python_generic_config_type();
+ type = get_python_generic_config_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_GEN_CONFIG, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_GEN_CONFIG, py_generic_config_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/glibext/configuration.h b/plugins/pychrysalide/glibext/configuration.h
index a34d8c2..7a85548 100644
--- a/plugins/pychrysalide/glibext/configuration.h
+++ b/plugins/pychrysalide/glibext/configuration.h
@@ -38,7 +38,7 @@
PyTypeObject *get_python_config_param_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.ConfigParam'. */
-bool register_python_config_param(PyObject *);
+bool ensure_python_config_param_is_registered(void);
@@ -49,7 +49,7 @@ bool register_python_config_param(PyObject *);
PyTypeObject *get_python_config_param_iterator_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.ConfigParamIterator'. */
-bool register_python_config_param_iterator(PyObject *);
+bool ensure_python_config_param_iterator_is_registered(void);
/* ----------------------- GESTION GENERIQUE DE CONFIGURATION ----------------------- */
@@ -59,7 +59,7 @@ bool register_python_config_param_iterator(PyObject *);
PyTypeObject *get_python_generic_config_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.GenConfig'. */
-bool register_python_generic_config(PyObject *);
+bool ensure_python_generic_config_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/linegen.c b/plugins/pychrysalide/glibext/linegen.c
index 8368548..7b93f7e 100644
--- a/plugins/pychrysalide/glibext/linegen.c
+++ b/plugins/pychrysalide/glibext/linegen.c
@@ -32,6 +32,7 @@
#include <glibext/linegen.h>
+#include "../access.h"
#include "../helpers.h"
#include "../analysis/content.h"
#include "../arch/vmpa.h"
@@ -393,15 +394,22 @@ PyTypeObject *get_python_line_generator_type(void)
* *
******************************************************************************/
-bool register_python_line_generator(PyObject *module)
+bool ensure_python_line_generator_is_registered(void)
{
- PyTypeObject *py_line_generator_type; /* Type Python 'LineGenerator' */
+ PyTypeObject *type; /* Type Python 'LineGenerator' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_line_generator_type = get_python_line_generator_type();
+ type = get_python_line_generator_type();
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "LineGenerator", G_TYPE_LINE_GENERATOR, py_line_generator_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
+
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "LineGenerator", G_TYPE_LINE_GENERATOR, type);
+
+ }
return true;
diff --git a/plugins/pychrysalide/glibext/linegen.h b/plugins/pychrysalide/glibext/linegen.h
index 6c2d161..3665d5e 100644
--- a/plugins/pychrysalide/glibext/linegen.h
+++ b/plugins/pychrysalide/glibext/linegen.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_line_generator_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.LineGenerator'. */
-bool register_python_line_generator(PyObject *);
+bool ensure_python_line_generator_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/loadedpanel.c b/plugins/pychrysalide/glibext/loadedpanel.c
index ba4ced0..44f7ce6 100644
--- a/plugins/pychrysalide/glibext/loadedpanel.c
+++ b/plugins/pychrysalide/glibext/loadedpanel.c
@@ -31,6 +31,7 @@
#include <glibext/gloadedpanel.h>
+#include "../access.h"
#include "../helpers.h"
@@ -229,18 +230,25 @@ PyTypeObject *get_python_loaded_panel_type(void)
* *
******************************************************************************/
-bool register_python_loaded_panel(PyObject *module)
+bool ensure_python_loaded_panel_is_registered(void)
{
- PyTypeObject *py_loaded_panel_type; /* Type Python 'LineGenerator' */
+ PyTypeObject *type; /* Type Python 'LineGenerator' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_loaded_panel_type = get_python_loaded_panel_type();
+ type = get_python_loaded_panel_type();
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "LoadedPanel", G_TYPE_LOADED_PANEL, py_loaded_panel_type);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.glibext");
- if (!py_loaded_panel_define_constants(py_loaded_panel_type))
- return false;
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "LoadedPanel", G_TYPE_LOADED_PANEL, type);
+
+ if (!py_loaded_panel_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/glibext/loadedpanel.h b/plugins/pychrysalide/glibext/loadedpanel.h
index 84f1741..35a76d1 100644
--- a/plugins/pychrysalide/glibext/loadedpanel.h
+++ b/plugins/pychrysalide/glibext/loadedpanel.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_loaded_panel_type(void);
/* Prend en charge l'objet 'pychrysalide.glibext.LoadedPanel'. */
-bool register_python_loaded_panel(PyObject *);
+bool ensure_python_loaded_panel_is_registered(void);
diff --git a/plugins/pychrysalide/glibext/module.c b/plugins/pychrysalide/glibext/module.c
index a3b0a25..45c92e8 100644
--- a/plugins/pychrysalide/glibext/module.c
+++ b/plugins/pychrysalide/glibext/module.c
@@ -33,27 +33,26 @@
#include "configuration.h"
#include "linegen.h"
#include "loadedpanel.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 'glibext' au module Python. *
+* Description : Ajoute le module 'glibext' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_glibext_module_to_python_module(PyObject *super)
+bool add_glibext_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_glibext_module = {
@@ -66,35 +65,40 @@ bool add_glibext_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_glibext_module);
- module = PyModule_Create(&py_chrysalide_glibext_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_glibext_module);
- if (ret != 0) goto agmtpm_exit;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.glibext");
- if (ret != 0) goto agmtpm_exit;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "glibext", module);
- if (ret != 0) goto agmtpm_exit;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'glibext'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_buffer_cache(module);
- result &= register_python_buffer_line(module);
- result &= register_python_config_param(module);
- result &= register_python_config_param_iterator(module);
- result &= register_python_generic_config(module);
- result &= register_python_line_generator(module);
- result &= register_python_loaded_panel(module);
+bool populate_glibext_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.glibext", module);
+ result = true;
- agmtpm_exit:
+ if (result) result = ensure_python_buffer_cache_is_registered();
+ if (result) result = ensure_python_buffer_line_is_registered();
+ if (result) result = ensure_python_config_param_is_registered();
+ if (result) result = ensure_python_config_param_iterator_is_registered();
+ if (result) result = ensure_python_generic_config_is_registered();
+ if (result) result = ensure_python_line_generator_is_registered();
+ if (result) result = ensure_python_loaded_panel_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/glibext/module.h b/plugins/pychrysalide/glibext/module.h
index f5ec0b4..4ba5d61 100644
--- a/plugins/pychrysalide/glibext/module.h
+++ b/plugins/pychrysalide/glibext/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'glibext' au module Python. */
-bool add_glibext_module_to_python_module(PyObject *);
+/* Ajoute le module 'glibext' à un module Python. */
+bool add_glibext_module(PyObject *);
+
+/* Intègre les objets du module 'glibext'. */
+bool populate_glibext_module(void);
diff --git a/plugins/pychrysalide/gtkext/blockdisplay.c b/plugins/pychrysalide/gtkext/blockdisplay.c
index c2ccfbb..6d53528 100644
--- a/plugins/pychrysalide/gtkext/blockdisplay.c
+++ b/plugins/pychrysalide/gtkext/blockdisplay.c
@@ -33,6 +33,7 @@
#include "bufferdisplay.h"
+#include "../access.h"
#include "../helpers.h"
@@ -97,19 +98,28 @@ PyTypeObject *get_python_block_display_type(void)
* *
******************************************************************************/
-bool register_python_block_display(PyObject *module)
+bool ensure_python_block_display_is_registered(void)
{
- bool result; /* Bilan à retourner */
- PyTypeObject *py_block_display_type; /* Type Python 'BlockDisplay' */
+ PyTypeObject *type; /* Type Python 'BlockDisplay' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_block_display_type = get_python_block_display_type();
+ type = get_python_block_display_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gtkext");
- result = register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY,
- py_block_display_type, get_python_buffer_display_type());
+ dict = PyModule_GetDict(module);
- return result;
+ if (!ensure_python_buffer_display_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY, type, get_python_buffer_display_type()))
+ return false;
+
+ }
+
+ return true;
}
diff --git a/plugins/pychrysalide/gtkext/blockdisplay.h b/plugins/pychrysalide/gtkext/blockdisplay.h
index ab15ac5..30ee0db 100644
--- a/plugins/pychrysalide/gtkext/blockdisplay.h
+++ b/plugins/pychrysalide/gtkext/blockdisplay.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_block_display_type(void);
/* Prend en charge l'objet 'pychrysalide.gtkext.BlockDisplay'. */
-bool register_python_block_display(PyObject *module);
+bool ensure_python_block_display_is_registered(void);
diff --git a/plugins/pychrysalide/gtkext/bufferdisplay.c b/plugins/pychrysalide/gtkext/bufferdisplay.c
index 9aa1bca..d7f0bbd 100644
--- a/plugins/pychrysalide/gtkext/bufferdisplay.c
+++ b/plugins/pychrysalide/gtkext/bufferdisplay.c
@@ -33,6 +33,7 @@
#include "displaypanel.h"
+#include "../access.h"
#include "../helpers.h"
@@ -97,19 +98,28 @@ PyTypeObject *get_python_buffer_display_type(void)
* *
******************************************************************************/
-bool register_python_buffer_display(PyObject *module)
+bool ensure_python_buffer_display_is_registered(void)
{
- bool result; /* Bilan à retourner */
- PyTypeObject *py_buffer_display_type; /* Type Python 'BufferDisplay' */
+ PyTypeObject *type; /* Type Python 'BufferDisplay' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_buffer_display_type = get_python_buffer_display_type();
+ type = get_python_buffer_display_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gtkext");
- result = register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY,
- py_buffer_display_type, get_python_display_panel_type());
+ dict = PyModule_GetDict(module);
- return result;
+ if (!ensure_python_display_panel_is_registered())
+ return false;
+
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY, type, get_python_display_panel_type()))
+ return false;
+
+ }
+
+ return true;
}
diff --git a/plugins/pychrysalide/gtkext/bufferdisplay.h b/plugins/pychrysalide/gtkext/bufferdisplay.h
index 4a21fb9..7f0b878 100644
--- a/plugins/pychrysalide/gtkext/bufferdisplay.h
+++ b/plugins/pychrysalide/gtkext/bufferdisplay.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_buffer_display_type(void);
/* Prend en charge l'objet 'pychrysalide.gtkext.BufferDisplay'. */
-bool register_python_buffer_display(PyObject *module);
+bool ensure_python_buffer_display_is_registered(void);
diff --git a/plugins/pychrysalide/gtkext/displaypanel.c b/plugins/pychrysalide/gtkext/displaypanel.c
index 16bd1d9..079ac73 100644
--- a/plugins/pychrysalide/gtkext/displaypanel.c
+++ b/plugins/pychrysalide/gtkext/displaypanel.c
@@ -32,6 +32,7 @@
#include <gtkext/gtkdisplaypanel.h>
+#include "../access.h"
#include "../helpers.h"
#include "../arch/vmpa.h"
@@ -152,32 +153,41 @@ PyTypeObject *get_python_display_panel_type(void)
* *
******************************************************************************/
-bool register_python_display_panel(PyObject *module)
+bool ensure_python_display_panel_is_registered(void)
{
bool result; /* Bilan à retourner */
- PyTypeObject *py_display_panel_type; /* Type Python 'DisplayPanel' */
+ PyTypeObject *type; /* Type Python 'DisplayPanel' */
PyObject *parent_mod; /* Module Python Fixed */
PyObject *fixed; /* Module "GtkFixed" */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
result = false;
- py_display_panel_type = get_python_display_panel_type();
+ type = get_python_display_panel_type();
- parent_mod = PyImport_ImportModule("gi.repository.Gtk");
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gtkext");
- if (parent_mod == NULL)
- goto rpdp_exit;
+ parent_mod = PyImport_ImportModule("gi.repository.Gtk");
- fixed = PyObject_GetAttrString(parent_mod, "Fixed");
+ if (parent_mod == NULL)
+ goto rpdp_exit;
- Py_DECREF(parent_mod);
+ fixed = PyObject_GetAttrString(parent_mod, "Fixed");
- dict = PyModule_GetDict(module);
+ Py_DECREF(parent_mod);
- result = register_class_for_pygobject(dict, GTK_TYPE_DISPLAY_PANEL,
- py_display_panel_type, (PyTypeObject *)fixed);
- Py_DECREF(fixed);
+ dict = PyModule_GetDict(module);
+
+ result = register_class_for_pygobject(dict, GTK_TYPE_DISPLAY_PANEL, type, (PyTypeObject *)fixed);
+ Py_DECREF(fixed);
+
+ }
+
+ else
+ result = true;
rpdp_exit:
diff --git a/plugins/pychrysalide/gtkext/displaypanel.h b/plugins/pychrysalide/gtkext/displaypanel.h
index 318a9f6..d16a415 100644
--- a/plugins/pychrysalide/gtkext/displaypanel.h
+++ b/plugins/pychrysalide/gtkext/displaypanel.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_display_panel_type(void);
/* Prend en charge l'objet 'pychrysalide.gtkext.DisplayPanel'. */
-bool register_python_display_panel(PyObject *module);
+bool ensure_python_display_panel_is_registered(void);
diff --git a/plugins/pychrysalide/gtkext/dockable.c b/plugins/pychrysalide/gtkext/dockable.c
index 9c66159..f67e0fa 100644
--- a/plugins/pychrysalide/gtkext/dockable.c
+++ b/plugins/pychrysalide/gtkext/dockable.c
@@ -31,6 +31,9 @@
#include <gtkext/gtkdockable.h>
+#include "../access.h"
+
+
/******************************************************************************
* *
@@ -87,15 +90,22 @@ PyTypeObject *get_python_gtk_dockable_type(void)
* *
******************************************************************************/
-bool register_python_gtk_dockable(PyObject *module)
+bool ensure_python_gtk_dockable_is_registered(void)
{
- PyTypeObject *py_gtk_dockable_type; /* Type Python 'LineGenerator' */
+ PyTypeObject *type; /* Type Python 'GtkDockable' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_gtk_dockable_type = get_python_gtk_dockable_type();
+ type = get_python_gtk_dockable_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gtkext");
+
+ dict = PyModule_GetDict(module);
+ pyg_register_interface(dict, "LineGenerator", GTK_TYPE_DOCKABLE, type);
- dict = PyModule_GetDict(module);
- pyg_register_interface(dict, "LineGenerator", GTK_TYPE_DOCKABLE, py_gtk_dockable_type);
+ }
return true;
diff --git a/plugins/pychrysalide/gtkext/dockable.h b/plugins/pychrysalide/gtkext/dockable.h
index dfec74d..29df25c 100644
--- a/plugins/pychrysalide/gtkext/dockable.h
+++ b/plugins/pychrysalide/gtkext/dockable.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_gtk_dockable_type(void);
/* Prend en charge l'objet 'pychrysalide.gtkext.GtkDockable'. */
-bool register_python_gtk_dockable(PyObject *);
+bool ensure_python_gtk_dockable_is_registered(void);
diff --git a/plugins/pychrysalide/gtkext/module.c b/plugins/pychrysalide/gtkext/module.c
index 8b2cc5e..2108b04 100644
--- a/plugins/pychrysalide/gtkext/module.c
+++ b/plugins/pychrysalide/gtkext/module.c
@@ -32,26 +32,26 @@
#include "bufferdisplay.h"
#include "displaypanel.h"
#include "dockable.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 'gtkext' au module Python. *
+* Description : Ajoute le module 'gtkext' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_gtkext_module_to_python_module(PyObject *super)
+bool add_gtkext_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_gtkext_module = {
@@ -64,29 +64,37 @@ bool add_gtkext_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_gtkext_module);
- module = PyModule_Create(&py_chrysalide_gtkext_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_gtkext_module);
- if (ret != 0) goto agmtpm_exit;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.gtkext");
- if (ret != 0) goto agmtpm_exit;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "gtkext", module);
- if (ret != 0) goto agmtpm_exit;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'gtkext'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_display_panel(module);
- result &= register_python_buffer_display(module);
- result &= register_python_block_display(module);
- result &= register_python_gtk_dockable(module);
+bool populate_gtkext_module(void)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
- agmtpm_exit:
+ if (result) result = ensure_python_block_display_is_registered();
+ if (result) result = ensure_python_buffer_display_is_registered();
+ if (result) result = ensure_python_display_panel_is_registered();
+ if (result) result = ensure_python_gtk_dockable_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/gtkext/module.h b/plugins/pychrysalide/gtkext/module.h
index 8d346cb..975055a 100644
--- a/plugins/pychrysalide/gtkext/module.h
+++ b/plugins/pychrysalide/gtkext/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'gtkext' au module Python. */
-bool add_gtkext_module_to_python_module(PyObject *);
+/* Ajoute le module 'gtkext' à un module Python. */
+bool add_gtkext_module(PyObject *);
+
+/* Intègre les objets du module 'gtkext'. */
+bool populate_gtkext_module(void);
diff --git a/plugins/pychrysalide/gui/editem.c b/plugins/pychrysalide/gui/editem.c
index 8fd2c17..03ad97a 100644
--- a/plugins/pychrysalide/gui/editem.c
+++ b/plugins/pychrysalide/gui/editem.c
@@ -31,9 +31,8 @@
#include <gui/editem-int.h>
+#include "../access.h"
#include "../helpers.h"
-
-
#include "../analysis/binary.h"
#include "../gtkext/displaypanel.h"
@@ -357,17 +356,24 @@ PyTypeObject *get_python_editor_item_type(void)
* *
******************************************************************************/
-bool register_python_editor_item(PyObject *module)
+bool ensure_python_editor_item_is_registered(void)
{
- PyTypeObject *py_editor_item_type; /* Type Python 'LoadedBinary' */
+ PyTypeObject *type; /* Type Python 'EditorItem' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_editor_item_type = get_python_editor_item_type();
+ type = get_python_editor_item_type();
+
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gui");
+
+ dict = PyModule_GetDict(module);
- dict = PyModule_GetDict(module);
+ if (!register_class_for_pygobject(dict, G_TYPE_EDITOR_ITEM, type, &PyGObject_Type))
+ return false;
- if (!register_class_for_pygobject(dict, G_TYPE_EDITOR_ITEM, py_editor_item_type, &PyGObject_Type))
- return false;
+ }
return true;
diff --git a/plugins/pychrysalide/gui/editem.h b/plugins/pychrysalide/gui/editem.h
index e34690c..9baebee 100644
--- a/plugins/pychrysalide/gui/editem.h
+++ b/plugins/pychrysalide/gui/editem.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_editor_item_type(void);
/* Prend en charge l'objet 'pychrysalide.gui.EditorItem'. */
-bool register_python_editor_item(PyObject *);
+bool ensure_python_editor_item_is_registered(void);
diff --git a/plugins/pychrysalide/gui/module.c b/plugins/pychrysalide/gui/module.c
index 192b1e6..5dd9e72 100644
--- a/plugins/pychrysalide/gui/module.c
+++ b/plugins/pychrysalide/gui/module.c
@@ -31,64 +31,73 @@
#include "editem.h"
#include "panels/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 'gui' au module Python. *
+* Description : Ajoute le module 'gui' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_gui_module_to_python_module(PyObject *super)
+bool add_gui_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_gui_module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "pychrysalide.gui",
- .m_doc = "Python module for the Chrysalide GUI",
+ .m_doc = "Python module for Chrysalide.gui",
.m_size = -1,
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_gui_module);
- module = PyModule_Create(&py_chrysalide_gui_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_gui_module);
- if (ret != 0) goto loading_failed;
+ if (result) result = add_gui_panels_module(module);
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.gui");
- if (ret != 0) goto loading_failed;
+ if (!result)
+ Py_XDECREF(module);
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "gui", module);
- if (ret != 0) goto loading_failed;
+ return result;
- result = true;
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'gui'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_editor_item(module);
+bool populate_gui_module(void)
+{
+ bool result; /* Bilan à retourner */
- result &= add_gui_panels_module_to_python_module(module);
+ result = true;
- if (result)
- register_access_to_python_module("pychrysalide.gui", module);
+ if (result) result = ensure_python_editor_item_is_registered();
- loading_failed:
+ if (result) result = populate_gui_panels_module();
assert(result);
diff --git a/plugins/pychrysalide/gui/module.h b/plugins/pychrysalide/gui/module.h
index 8609d66..f97f3b2 100644
--- a/plugins/pychrysalide/gui/module.h
+++ b/plugins/pychrysalide/gui/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'gui' au module Python. */
-bool add_gui_module_to_python_module(PyObject *);
+/* Ajoute le module 'gui' à un module Python. */
+bool add_gui_module(PyObject *);
+
+/* Intègre les objets du module 'gui'. */
+bool populate_gui_module(void);
diff --git a/plugins/pychrysalide/gui/panels/module.c b/plugins/pychrysalide/gui/panels/module.c
index 21b487e..dd6b91e 100644
--- a/plugins/pychrysalide/gui/panels/module.c
+++ b/plugins/pychrysalide/gui/panels/module.c
@@ -29,62 +29,66 @@
#include "panel.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 'gui.panels' au module Python. *
+* Description : Ajoute le module 'gui.panels' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_gui_panels_module_to_python_module(PyObject *super)
+bool add_gui_panels_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_panels_module = {
+ static PyModuleDef py_chrysalide_gui_panels_module = {
.m_base = PyModuleDef_HEAD_INIT,
- .m_name = "gui.analysis.panels",
+ .m_name = "pychrysalide.gui.panels",
.m_doc = "Python module for Chrysalide.gui.panels",
.m_size = -1,
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_gui_panels_module);
- module = PyModule_Create(&py_chrysalide_panels_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_panels_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.gui.panels");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "panels", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'gui.panels'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_panel_item(module);
+bool populate_gui_panels_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.gui.panels", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_panel_item_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/gui/panels/module.h b/plugins/pychrysalide/gui/panels/module.h
index 34fac70..559a8c4 100644
--- a/plugins/pychrysalide/gui/panels/module.h
+++ b/plugins/pychrysalide/gui/panels/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'gui.panels' au module Python. */
-bool add_gui_panels_module_to_python_module(PyObject *);
+/* Ajoute le module 'gui.panels' à un module Python. */
+bool add_gui_panels_module(PyObject *);
+
+/* Intègre les objets du module 'gui.panels'. */
+bool populate_gui_panels_module(void);
diff --git a/plugins/pychrysalide/gui/panels/panel.c b/plugins/pychrysalide/gui/panels/panel.c
index 72c9e7e..6613fac 100644
--- a/plugins/pychrysalide/gui/panels/panel.c
+++ b/plugins/pychrysalide/gui/panels/panel.c
@@ -34,6 +34,7 @@
#include "../editem.h"
+#include "../../access.h"
#include "../../helpers.h"
#include "../../gtkext/dockable.h"
@@ -223,21 +224,34 @@ static bool py_panel_item_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_panel_item(PyObject *module)
+bool ensure_python_panel_item_is_registered(void)
{
- PyTypeObject *py_panel_item_type; /* Type Python 'LoadedBinary' */
+ PyTypeObject *type; /* Type Python 'LoadedBinary' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_panel_item_type = get_python_panel_item_type();
+ type = get_python_panel_item_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gui.panels");
- if (!_register_class_for_pygobject(dict, G_TYPE_PANEL_ITEM, py_panel_item_type,
- get_python_editor_item_type(), get_python_gtk_dockable_type(), NULL))
- return false;
+ dict = PyModule_GetDict(module);
- if (!py_panel_item_define_constants(py_panel_item_type))
- return false;
+ if (!ensure_python_editor_item_is_registered())
+ return false;
+
+ if (!ensure_python_gtk_dockable_is_registered())
+ return false;
+
+ if (!_register_class_for_pygobject(dict, G_TYPE_PANEL_ITEM, type,
+ get_python_editor_item_type(), get_python_gtk_dockable_type(), NULL))
+ return false;
+
+ if (!py_panel_item_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/gui/panels/panel.h b/plugins/pychrysalide/gui/panels/panel.h
index f0406d5..7fb473b 100644
--- a/plugins/pychrysalide/gui/panels/panel.h
+++ b/plugins/pychrysalide/gui/panels/panel.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_panel_item_type(void);
/* Prend en charge l'objet 'pychrysalide.gui.panels.PanelItem'. */
-bool register_python_panel_item(PyObject *);
+bool ensure_python_panel_item_is_registered(void);
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index 4c25be5..4ada405 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -25,11 +25,15 @@
#include <assert.h>
+#include <malloc.h>
#include <pygobject.h>
#include <stdarg.h>
#include <string.h>
+#include "access.h"
+
+
/* ---------------------------------------------------------------------------------- */
/* ACCELERATEURS POUR PYTHON UNIQUEMENT */
@@ -250,6 +254,64 @@ bool PyDict_AddStringConstant(PyTypeObject *obj_type, const char *key, const cha
/* ---------------------------------------------------------------------------------- */
+/* MISE EN PLACE DE MODULES */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : super = module dont la définition est à compléter. *
+* def = définition du module à créer. *
+* *
+* Description : Met en place un nouveau module Python. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *build_python_module(PyObject *super, PyModuleDef *def)
+{
+ PyObject *result; /* Création à retourner */
+ int ret; /* Bilan d'un appel */
+ char *dot; /* Dernier point de ce chemin */
+
+ result = PyModule_Create(def);
+ if (result == NULL) goto quick_bad_exit;
+
+ ret = PyState_AddModule(super, def);
+ if (ret != 0) goto bad_exit;
+
+ ret = _PyImport_FixupBuiltin(result, def->m_name);
+ if (ret != 0) goto bad_exit;
+
+ dot = strrchr(def->m_name, '.');
+ assert(dot != NULL);
+
+ Py_INCREF(result);
+ ret = PyModule_AddObject(super, dot + 1, result);
+ if (ret != 0) goto bad_exit;
+
+ register_access_to_python_module(def->m_name, result);
+
+ return result;
+
+ bad_exit:
+
+ Py_DECREF(result);
+
+ quick_bad_exit:
+
+ assert(false);
+
+ return false;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
/* CONFORTS CIBLANT PYGOBJECT */
/* ---------------------------------------------------------------------------------- */
diff --git a/plugins/pychrysalide/helpers.h b/plugins/pychrysalide/helpers.h
index e025cf7..d8d75af 100644
--- a/plugins/pychrysalide/helpers.h
+++ b/plugins/pychrysalide/helpers.h
@@ -58,6 +58,14 @@ bool PyDict_AddStringConstant(PyTypeObject *, const char *, const char *);
+/* ---------------------------- MISE EN PLACE DE MODULES ---------------------------- */
+
+
+/* Met en place un nouveau module Python. */
+PyObject *build_python_module(PyObject *, PyModuleDef *);
+
+
+
/* --------------------------- CONFORTS CIBLANT PYGOBJECT --------------------------- */
diff --git a/plugins/pychrysalide/mangling/demangler.c b/plugins/pychrysalide/mangling/demangler.c
index 37935c9..15c9c62 100644
--- a/plugins/pychrysalide/mangling/demangler.c
+++ b/plugins/pychrysalide/mangling/demangler.c
@@ -31,6 +31,7 @@
#include <mangling/demangler.h>
+#include "../access.h"
#include "../helpers.h"
@@ -202,17 +203,24 @@ PyTypeObject *get_python_compiler_demangler_type(void)
* *
******************************************************************************/
-bool register_python_compiler_demangler(PyObject *module)
+bool ensure_python_compiler_demangler_is_registered(void)
{
- PyTypeObject *py_comp_demangler_type; /* Type Python 'CompDemangler' */
+ PyTypeObject *type; /* Type Python 'CompDemangler' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_comp_demangler_type = get_python_compiler_demangler_type();
+ type = get_python_compiler_demangler_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.mangling");
+
+ dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, G_TYPE_COMP_DEMANGLER, py_comp_demangler_type, &PyGObject_Type))
- return false;
+ if (!register_class_for_pygobject(dict, G_TYPE_COMP_DEMANGLER, type, &PyGObject_Type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/mangling/demangler.h b/plugins/pychrysalide/mangling/demangler.h
index c2094b7..0c31f7c 100644
--- a/plugins/pychrysalide/mangling/demangler.h
+++ b/plugins/pychrysalide/mangling/demangler.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_compiler_demangler_type(void);
/* Prend en charge l'objet 'pychrysalide.format.elf.ElfFormat'. */
-bool register_python_compiler_demangler(PyObject *);
+bool ensure_python_compiler_demangler_is_registered(void);
diff --git a/plugins/pychrysalide/mangling/module.c b/plugins/pychrysalide/mangling/module.c
index a462e3e..2b2aef7 100644
--- a/plugins/pychrysalide/mangling/module.c
+++ b/plugins/pychrysalide/mangling/module.c
@@ -29,27 +29,26 @@
#include "demangler.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 'mangling' au module Python. *
+* Description : Ajoute le module 'mangling' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_mangling_module_to_python_module(PyObject *super)
+bool add_mangling_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
static PyModuleDef py_chrysalide_mangling_module = {
@@ -62,27 +61,34 @@ bool add_mangling_module_to_python_module(PyObject *super)
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_mangling_module);
- module = PyModule_Create(&py_chrysalide_mangling_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_mangling_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.mangling");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "mangling", module);
- if (ret != 0) goto loading_failed;
- result = register_python_compiler_demangler(module);
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'mangling'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool populate_mangling_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.mangling", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_compiler_demangler_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/mangling/module.h b/plugins/pychrysalide/mangling/module.h
index 126aa7e..27c7353 100644
--- a/plugins/pychrysalide/mangling/module.h
+++ b/plugins/pychrysalide/mangling/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'mangling' au module Python. */
-bool add_mangling_module_to_python_module(PyObject *);
+/* Ajoute le module 'mangling' à un module Python. */
+bool add_mangling_module(PyObject *);
+
+/* Intègre les objets du module 'mangling'. */
+bool populate_mangling_module(void);
diff --git a/plugins/pychrysalide/pychrysa.c b/plugins/pychrysalide/pychrysa.c
index c1fdd6f..dee0d84 100644
--- a/plugins/pychrysalide/pychrysa.c
+++ b/plugins/pychrysalide/pychrysa.c
@@ -362,21 +362,27 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
status = register_python_py_struct(result);
- /* Interface 'LineGenerator' en premier... */
- if (status) status = add_glibext_module_to_python_module(result);
-
- /* BinRoutine hérite de BinSymbol... */
- if (status) status = add_format_module_to_python_module(result);
-
- if (status) status = register_python_plugin_module(result);
- if (status) status = add_analysis_module_to_python_module(result);
- if (status) status = add_arch_module_to_python_module(result);
- if (status) status = add_common_module_to_python_module(result);
- if (status) status = add_core_module_to_python_module(result);
- if (status) status = add_debug_module_to_python_module(result);
- if (status) status = add_gtkext_module_to_python_module(result);
- if (status) status = add_gui_module_to_python_module(result);
- if (status) status = add_mangling_module_to_python_module(result);
+ if (status) status = add_analysis_module(result);
+ if (status) status = add_arch_module(result);
+ if (status) status = add_common_module(result);
+ if (status) status = add_core_module(result);
+ if (status) status = add_debug_module(result);
+ if (status) status = add_format_module(result);
+ if (status) status = add_glibext_module(result);
+ if (status) status = add_gtkext_module(result);
+ if (status) status = add_gui_module(result);
+ if (status) status = add_mangling_module(result);
+
+ if (status) status = populate_analysis_module();
+ if (status) status = populate_arch_module();
+ if (status) status = populate_common_module();
+ if (status) status = populate_core_module();
+ if (status) status = populate_debug_module();
+ if (status) status = populate_format_module();
+ if (status) status = populate_glibext_module();
+ if (status) status = populate_gtkext_module();
+ if (status) status = populate_gui_module();
+ if (status) status = populate_mangling_module();
if (!status)
{