diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-09-10 15:59:44 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-09-10 15:59:44 (GMT) |
commit | 49f75f22fe67ac356f05c7f81d3a78c48461655b (patch) | |
tree | 063b9c55fd5e0a498289fbdc902b14990976a41d /plugins/pychrysa/format/dex | |
parent | fe884ef58959412972a5a84231d1ee06f34a80be (diff) |
Updated the Python bindings used to load Elf and Dex files.
Diffstat (limited to 'plugins/pychrysa/format/dex')
-rw-r--r-- | plugins/pychrysa/format/dex/dex.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/plugins/pychrysa/format/dex/dex.c b/plugins/pychrysa/format/dex/dex.c index 6bb1888..68f259b 100644 --- a/plugins/pychrysa/format/dex/dex.c +++ b/plugins/pychrysa/format/dex/dex.c @@ -28,6 +28,9 @@ #include <pygobject.h> +#include <i18n.h> + + #include <format/dex/class.h> #include <format/dex/dex.h> @@ -79,22 +82,52 @@ static PyObject *py_dex_format_new(PyTypeObject *type, PyObject *args, PyObject if (!ret) return NULL; ret = PyObject_IsInstance(content_obj, (PyObject *)get_python_binary_content_type()); - if (!ret) return NULL; + if (!ret) + { + PyErr_SetString(PyExc_TypeError, _("The first argument must be an instance of BinContent.")); + return NULL; + } - ret = PyObject_IsInstance(parent_obj, (PyObject *)get_python_executable_format_type()); - if (!ret) return NULL; + content = G_BIN_CONTENT(pygobject_get(content_obj)); - /* - FIXME - ret = PyObject_IsInstance(status_obj, (PyObject *)get_python_binary_content_type()); - if (!ret) return NULL; - */ + if (parent_obj == Py_None) + parent = NULL; - content = G_BIN_CONTENT(pygobject_get(content_obj)); - parent = G_EXE_FORMAT(pygobject_get(parent_obj)); - status = GTK_STATUS_STACK(pygobject_get(status_obj)); + else + { + ret = PyObject_IsInstance(parent_obj, (PyObject *)get_python_executable_format_type()); + if (!ret) + { + PyErr_SetString(PyExc_TypeError, _("The second argument must be a container format or None.")); + return NULL; + } + + parent = G_EXE_FORMAT(pygobject_get(parent_obj)); + + } + + if (status_obj == Py_None) + status = NULL; + + else + { + ret = PyObject_IsInstance(status_obj, (PyObject *)get_python_binary_content_type()); + if (!ret) + { + PyErr_SetString(PyExc_TypeError, _("The third argument must be a status bar object or None.")); + return NULL; + } + + status = GTK_STATUS_STACK(pygobject_get(status_obj)); + + } format = g_dex_format_new(content, parent, status); + if (format == NULL) + { + PyErr_SetString(PyExc_RuntimeError, _("Unable to load the DEX format.")); + return NULL; + } result = pygobject_new(G_OBJECT(format)); |