diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
commit | 932ea7c83c07d3982fee605c6dd9895fd2753874 (patch) | |
tree | 766ad53bab9e3e3005334c30e823493de8e84168 /plugins/pychrysa/glibext | |
parent | 1b5d39bfbc48c33a0ea0924b60e48448c8b45dd4 (diff) |
Rewritten the line buffers using generators and on-demand building to save memory.
Diffstat (limited to 'plugins/pychrysa/glibext')
-rw-r--r-- | plugins/pychrysa/glibext/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/pychrysa/glibext/buffercache.c (renamed from plugins/pychrysa/glibext/codebuffer.c) | 40 | ||||
-rw-r--r-- | plugins/pychrysa/glibext/buffercache.h (renamed from plugins/pychrysa/glibext/codebuffer.h) | 12 | ||||
-rw-r--r-- | plugins/pychrysa/glibext/module.c | 4 |
4 files changed, 31 insertions, 27 deletions
diff --git a/plugins/pychrysa/glibext/Makefile.am b/plugins/pychrysa/glibext/Makefile.am index 74def8a..b53f4b0 100644 --- a/plugins/pychrysa/glibext/Makefile.am +++ b/plugins/pychrysa/glibext/Makefile.am @@ -2,8 +2,8 @@ noinst_LTLIBRARIES = libpychrysaglibext.la libpychrysaglibext_la_SOURCES = \ + buffercache.h buffercache.c \ bufferline.h bufferline.c \ - codebuffer.h codebuffer.c \ configuration.h configuration.c \ module.h module.c diff --git a/plugins/pychrysa/glibext/codebuffer.c b/plugins/pychrysa/glibext/buffercache.c index 7ca9435..c79fda2 100644 --- a/plugins/pychrysa/glibext/codebuffer.c +++ b/plugins/pychrysa/glibext/buffercache.c @@ -1,6 +1,6 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * codebuffer.c - équivalent Python du fichier "glibext/gcodebuffer.h" + * buffercache.c - équivalent Python du fichier "glibext/gbuffercache.h" * * Copyright (C) 2012 Cyrille Bagard * @@ -22,13 +22,13 @@ */ -#include "codebuffer.h" +#include "buffercache.h" #include <pygobject.h> -#include <glibext/gcodebuffer.h> +#include <glibext/gbuffercache.h> #include "../arch/vmpa.h" @@ -36,6 +36,7 @@ +#if 0 /* Retrouve une ligne au sein d'un tampon avec une adresse. */ static PyObject *py_code_buffer_find_line_by_addr(PyObject *, PyObject *); @@ -60,7 +61,7 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args PyObject *py_vmpa; /* Localisation version Python */ int ret; /* Bilan de lecture des args. */ vmpa2t *addr; /* Adresse visée par l'opérat° */ - GCodeBuffer *buffer; /* Version native */ + GBuffercache *buffer; /* Version native */ GBufferLine *line; /* Ligne trouvée */ ret = PyArg_ParseTuple(args, "O", &py_vmpa); @@ -82,6 +83,7 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args return result; } +#endif /****************************************************************************** @@ -96,38 +98,40 @@ static PyObject *py_code_buffer_find_line_by_addr(PyObject *self, PyObject *args * * ******************************************************************************/ -PyTypeObject *get_python_code_buffer_type(void) +PyTypeObject *get_python_buffer_cache_type(void) { - static PyMethodDef py_code_buffer_methods[] = { + static PyMethodDef py_buffer_cache_methods[] = { +#if 0 { - "find_line_by_addr", (PyCFunction)py_code_buffer_find_line_by_addr, + "find_line_by_addr", (PyCFunction)py_buffer_cache_find_line_by_addr, METH_VARARGS, "find_line_by_addr($self, addr, /)\n--\n\nFind a buffer line with a given address." }, +#endif { NULL } }; - static PyGetSetDef py_code_buffer_getseters[] = { + static PyGetSetDef py_buffer_cache_getseters[] = { { NULL } }; - static PyTypeObject py_code_buffer_type = { + static PyTypeObject py_buffer_cache_type = { PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "pychrysalide.glibext.CodeBuffer", + .tp_name = "pychrysalide.glibext.Buffercache", .tp_basicsize = sizeof(PyGObject), .tp_flags = Py_TPFLAGS_DEFAULT, .tp_doc = "PyChrysalide code buffer", - .tp_methods = py_code_buffer_methods, - .tp_getset = py_code_buffer_getseters, + .tp_methods = py_buffer_cache_methods, + .tp_getset = py_buffer_cache_getseters, }; - return &py_code_buffer_type; + return &py_buffer_cache_type; } @@ -136,7 +140,7 @@ PyTypeObject *get_python_code_buffer_type(void) * * * Paramètres : module = module dont la définition est à compléter. * * * -* Description : Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. * +* Description : Prend en charge l'objet 'pychrysalide.glibext.BufferCache'. * * * * Retour : Bilan de l'opération. * * * @@ -144,16 +148,16 @@ PyTypeObject *get_python_code_buffer_type(void) * * ******************************************************************************/ -bool register_python_code_buffer(PyObject *module) +bool register_python_buffer_cache(PyObject *module) { - PyTypeObject *py_code_buffer_type; /* Type Python 'CodeBuffer' */ + PyTypeObject *py_buffer_cache_type; /* Type Python 'BufferCache' */ PyObject *dict; /* Dictionnaire du module */ - py_code_buffer_type = get_python_code_buffer_type(); + py_buffer_cache_type = get_python_buffer_cache_type(); dict = PyModule_GetDict(module); - if (!register_class_for_pygobject(dict, G_TYPE_CODE_BUFFER, py_code_buffer_type, &PyGObject_Type)) + if (!register_class_for_pygobject(dict, G_TYPE_BUFFER_CACHE, py_buffer_cache_type, &PyGObject_Type)) return false; return true; diff --git a/plugins/pychrysa/glibext/codebuffer.h b/plugins/pychrysa/glibext/buffercache.h index e806e36..6476f5f 100644 --- a/plugins/pychrysa/glibext/codebuffer.h +++ b/plugins/pychrysa/glibext/buffercache.h @@ -1,6 +1,6 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * codebuffer.h - prototypes pour l'équivalent Python du fichier "glibext/codebuffer.h" + * buffercache.h - prototypes pour l'équivalent Python du fichier "glibext/buffercache.h" * * Copyright (C) 2012 Cyrille Bagard * @@ -22,8 +22,8 @@ */ -#ifndef _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H -#define _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H +#ifndef _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H +#define _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H #include <Python.h> @@ -32,11 +32,11 @@ /* Fournit un accès à une définition de type à diffuser. */ -PyTypeObject *get_python_code_buffer_type(void); +PyTypeObject *get_python_buffer_cache_type(void); /* Prend en charge l'objet 'pychrysalide.glibext.CodeBuffer'. */ -bool register_python_code_buffer(PyObject *); +bool register_python_buffer_cache(PyObject *); -#endif /* _PLUGINS_PYCHRYSA_GLIBEXT_CODEBUFFER_H */ +#endif /* _PLUGINS_PYCHRYSA_GLIBEXT_BUFFERCACHE_H */ diff --git a/plugins/pychrysa/glibext/module.c b/plugins/pychrysa/glibext/module.c index 2306c44..847e6d6 100644 --- a/plugins/pychrysa/glibext/module.c +++ b/plugins/pychrysa/glibext/module.c @@ -28,8 +28,8 @@ #include <assert.h> +#include "buffercache.h" #include "bufferline.h" -#include "codebuffer.h" #include "configuration.h" @@ -80,8 +80,8 @@ bool add_glibext_module_to_python_module(PyObject *super) result = true; + result &= register_python_buffer_cache(module); result &= register_python_buffer_line(module); - result &= register_python_code_buffer(module); result &= register_python_config_param(module); result &= register_python_config_param_iterator(module); result &= register_python_generic_config(module); |