summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/format/program.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/format/program.c')
-rw-r--r--plugins/pychrysalide/format/program.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/plugins/pychrysalide/format/program.c b/plugins/pychrysalide/format/program.c
index 28c1540..57a359a 100644
--- a/plugins/pychrysalide/format/program.c
+++ b/plugins/pychrysalide/format/program.c
@@ -55,9 +55,9 @@
/* Initialise la classe des formats de programmes. */
-static void py_program_format_init_gclass(GProgramFormatClass *, gpointer);
+static int py_program_format_init_gclass(GProgramFormatClass *, PyTypeObject *);
-CREATE_DYN_ABSTRACT_CONSTRUCTOR(program_format, G_TYPE_PROGRAM_FORMAT, py_program_format_init_gclass);
+CREATE_DYN_ABSTRACT_CONSTRUCTOR(program_format, G_TYPE_PROGRAM_FORMAT);
/* Initialise une instance sur la base du dérivé de GObject. */
static int py_program_format_init(PyObject *, PyObject *, PyObject *);
@@ -66,7 +66,7 @@ static int py_program_format_init(PyObject *, PyObject *, PyObject *);
static SourceEndian py_program_format_get_endianness_wrapper(const GProgramFormat *);
/* Fournit l'emplacement d'une section donnée. */
-static bool py_program_format_get_section_range_by_name_wrapper(const GProgramFormat *, const char *, mrange_t *);
+static bool py_program_format_find_section_range_by_name_wrapper(const GProgramFormat *, const char *, mrange_t *);
@@ -86,7 +86,7 @@ static PyObject *py_program_format_has_flag(PyObject *, PyObject *);
/* Fournit l'emplacement d'une section donnée. */
-static PyObject *py_program_format_get_section_range_by_name(PyObject *, PyObject *);
+static PyObject *py_program_format_find_section_range_by_name(PyObject *, PyObject *);
#if 0
@@ -140,21 +140,23 @@ static PyObject *py_program_format_get_errors(PyObject *, void *);
/******************************************************************************
* *
-* Paramètres : class = classe à initialiser. *
-* unused = données non utilisées ici. *
+* Paramètres : gclass = classe GLib à initialiser. *
+* pyclass = classe Python à initialiser. *
* *
* Description : Initialise la classe des formats de programmes. *
* *
-* Retour : - *
+* Retour : 0 pour indiquer un succès de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-static void py_program_format_init_gclass(GProgramFormatClass *class, gpointer unused)
+static int py_program_format_init_gclass(GProgramFormatClass *gclass, PyTypeObject *pyclass)
{
- class->get_endian = py_program_format_get_endianness_wrapper;
- class->get_range_by_name = py_program_format_get_section_range_by_name_wrapper;
+ PY_CLASS_SET_WRAPPER(gclass->get_endian, py_program_format_get_endianness_wrapper);
+ PY_CLASS_SET_WRAPPER(gclass->find_range_by_name, py_program_format_find_section_range_by_name_wrapper);
+
+ return 0;
}
@@ -188,7 +190,7 @@ static int py_program_format_init(PyObject *self, PyObject *args, PyObject *kwds
"* pychrysalide.format.ProgramFormat._get_endianness().\n" \
"\n" \
"Other optional method may be defined for new classes:\n" \
- "* pychrysalide.format.ProgramFormat._get_section_range_by_name().\n" \
+ "* pychrysalide.format.ProgramFormat._find_section_range_by_name().\n" \
"\n" \
"Calls to the *__init__* constructor of this abstract object expect" \
" only one argument: a binary content, provided as a" \
@@ -295,7 +297,7 @@ static SourceEndian py_program_format_get_endianness_wrapper(const GProgramForma
* *
******************************************************************************/
-static bool py_program_format_get_section_range_by_name_wrapper(const GProgramFormat *format, const char *name, mrange_t *range)
+static bool py_program_format_find_section_range_by_name_wrapper(const GProgramFormat *format, const char *name, mrange_t *range)
{
bool result; /* Bilan à retourner */
PyGILState_STATE gstate; /* Sauvegarde d'environnement */
@@ -303,15 +305,15 @@ static bool py_program_format_get_section_range_by_name_wrapper(const GProgramFo
PyObject *pyret; /* Valeur retournée */
int ret; /* Bilan d'une conversion */
-#define PROGRAM_FORMAT_GET_SECTION_RANGE_BY_NAME_WRAPPER PYTHON_WRAPPER_DEF \
-( \
- _get_section_range_by_name_wrapper, "$self, name", \
- METH_VARARGS, \
- "Abstract method used to compute the area of a section identified by" \
- " its name.\n" \
- "\n" \
- "The expected returned value is a pychrysalide.arch.mrange instance or" \
- " *None* in case of failure." \
+#define PROGRAM_FORMAT_FIND_SECTION_RANGE_BY_NAME_WRAPPER PYTHON_WRAPPER_DEF \
+( \
+ _find_section_range_by_name_wrapper, "$self, name", \
+ METH_VARARGS, \
+ "Abstract method used to compute the area of a section identified by" \
+ " its name.\n" \
+ "\n" \
+ "The expected returned value is a pychrysalide.arch.mrange instance or" \
+ " *None* in case of failure." \
)
result = false;
@@ -320,9 +322,9 @@ static bool py_program_format_get_section_range_by_name_wrapper(const GProgramFo
pyobj = pygobject_new(G_OBJECT(format));
- if (has_python_method(pyobj, "_get_section_range_by_name"))
+ if (has_python_method(pyobj, "_find_section_range_by_name"))
{
- pyret = run_python_method(pyobj, "_get_section_range_by_name", NULL);
+ pyret = run_python_method(pyobj, "_find_section_range_by_name", NULL);
if (pyret != NULL)
{
@@ -520,7 +522,7 @@ static PyObject *py_program_format_has_flag(PyObject *self, PyObject *args)
* *
******************************************************************************/
-static PyObject *py_program_format_get_section_range_by_name(PyObject *self, PyObject *args)
+static PyObject *py_program_format_find_section_range_by_name(PyObject *self, PyObject *args)
{
PyObject *result; /* Emplacement à retourner */
const char *name; /* Nom de section ciblée */
@@ -529,9 +531,9 @@ static PyObject *py_program_format_get_section_range_by_name(PyObject *self, PyO
mrange_t range; /* Emplacement obtenu ? */
bool status; /* Bilan de l'opération */
-#define PROGRAM_FORMAT_GET_SECTION_RANGE_BY_NAME_METHOD PYTHON_METHOD_DEF \
+#define PROGRAM_FORMAT_FIND_SECTION_RANGE_BY_NAME_METHOD PYTHON_METHOD_DEF \
( \
- get_section_range_by_name, "$self, name, /", \
+ find_section_range_by_name, "$self, name, /", \
METH_VARARGS, py_program_format, \
"Compute the area of a section identified by its name.\n" \
"\n" \
@@ -546,7 +548,7 @@ static PyObject *py_program_format_get_section_range_by_name(PyObject *self, PyO
format = G_PROGRAM_FORMAT(pygobject_get(self));
- status = g_program_format_get_section_range_by_name(format, name, &range);
+ status = g_program_format_find_section_range_by_name(format, name, &range);
if (status)
result = build_from_internal_mrange(&range);
@@ -1194,8 +1196,8 @@ PyTypeObject *get_python_program_format_type(void)
{
static PyMethodDef py_program_format_methods[] = {
PROGRAM_FORMAT_GET_ENDIANNESS_WRAPPER,
- PROGRAM_FORMAT_GET_SECTION_RANGE_BY_NAME_WRAPPER,
- PROGRAM_FORMAT_GET_SECTION_RANGE_BY_NAME_METHOD,
+ PROGRAM_FORMAT_FIND_SECTION_RANGE_BY_NAME_WRAPPER,
+ PROGRAM_FORMAT_FIND_SECTION_RANGE_BY_NAME_METHOD,
/*
PROGRAM_FORMAT_SET_FLAG_METHOD,
PROGRAM_FORMAT_UNSET_FLAG_METHOD,
@@ -1273,6 +1275,8 @@ bool ensure_python_program_format_is_registered(void)
if (!ensure_python_known_format_is_registered())
return false;
+ pyg_register_class_init(G_TYPE_PROGRAM_FORMAT, (PyGClassInitFunc)py_program_format_init_gclass);
+
if (!register_class_for_pygobject(dict, G_TYPE_PROGRAM_FORMAT, type))
return false;