diff options
Diffstat (limited to 'plugins/pychrysalide/common')
-rw-r--r-- | plugins/pychrysalide/common/Makefile.am | 20 | ||||
-rw-r--r-- | plugins/pychrysalide/common/bits.c | 32 | ||||
-rw-r--r-- | plugins/pychrysalide/common/module.c | 18 |
3 files changed, 44 insertions, 26 deletions
diff --git a/plugins/pychrysalide/common/Makefile.am b/plugins/pychrysalide/common/Makefile.am index b5249b9..199ef43 100644 --- a/plugins/pychrysalide/common/Makefile.am +++ b/plugins/pychrysalide/common/Makefile.am @@ -1,16 +1,20 @@ noinst_LTLIBRARIES = libpychrysacommon.la +# libpychrysacommon_la_SOURCES = \ +# bits.h bits.c \ +# fnv1a.h fnv1a.c \ +# hex.h hex.c \ +# itoa.h itoa.c \ +# leb128.h leb128.c \ +# module.h module.c \ +# packed.h packed.c \ +# pathname.h pathname.c \ +# pearson.h pearson.c + libpychrysacommon_la_SOURCES = \ bits.h bits.c \ - fnv1a.h fnv1a.c \ - hex.h hex.c \ - itoa.h itoa.c \ - leb128.h leb128.c \ - module.h module.c \ - packed.h packed.c \ - pathname.h pathname.c \ - pearson.h pearson.c + module.h module.c libpychrysacommon_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_INTERPRETER_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ -I$(top_srcdir)/src -DNO_IMPORT_PYGOBJECT diff --git a/plugins/pychrysalide/common/bits.c b/plugins/pychrysalide/common/bits.c index a127251..35d6ea4 100644 --- a/plugins/pychrysalide/common/bits.c +++ b/plugins/pychrysalide/common/bits.c @@ -534,27 +534,33 @@ static PyObject *py_bitfield_set_all(PyObject *self, PyObject *args) static PyObject *py_bitfield_reset(PyObject *self, PyObject *args) { - unsigned long first; /* Indice du premier bit testé */ unsigned long count; /* Nombre de bits à analyser */ + unsigned long first; /* Indice du premier bit testé */ int ret; /* Bilan de lecture des args. */ py_bitfield_t *bf; /* Instance à manipuler */ #define BITFIELD_RESET_METHOD PYTHON_METHOD_DEF \ ( \ - reset, "$self, first, count, /", \ + reset, "$self, first, /, count=1", \ METH_VARARGS, py_bitfield, \ "Switch to 0 a part of bits in a bitfield.\n" \ "\n" \ "The area to process starts at bit *first* and has a" \ - " size of *count* bits." \ + " size of *count* bits (only one bit is processed if" \ + " no *size* is provided)." \ ) - ret = PyArg_ParseTuple(args, "kk", &first, &count); + count = 1; + + ret = PyArg_ParseTuple(args, "k|k", &first, &count); if (!ret) return NULL; bf = (py_bitfield_t *)self; - reset_in_bit_field(bf->native, first, count); + if (count == 1) + reset_in_bit_field(bf->native, first); + else + reset_multi_in_bit_field(bf->native, first, count); Py_RETURN_NONE; @@ -576,27 +582,33 @@ static PyObject *py_bitfield_reset(PyObject *self, PyObject *args) static PyObject *py_bitfield_set(PyObject *self, PyObject *args) { - unsigned long first; /* Indice du premier bit testé */ unsigned long count; /* Nombre de bits à analyser */ + unsigned long first; /* Indice du premier bit testé */ int ret; /* Bilan de lecture des args. */ py_bitfield_t *bf; /* Instance à manipuler */ #define BITFIELD_SET_METHOD PYTHON_METHOD_DEF \ ( \ - set, "$self, first, count, /", \ + set, "$self, first, /, count=1", \ METH_VARARGS, py_bitfield, \ "Switch to 1 a part of bits in a bitfield.\n" \ "\n" \ "The area to process starts at bit *first* and has a" \ - " size of *count* bits." \ + " size of *count* bits (only one bit is processed if" \ + " no *size* is provided)." \ ) - ret = PyArg_ParseTuple(args, "kk", &first, &count); + count = 1; + + ret = PyArg_ParseTuple(args, "k|k", &first, &count); if (!ret) return NULL; bf = (py_bitfield_t *)self; - set_in_bit_field(bf->native, first, count); + if (count == 1) + set_in_bit_field(bf->native, first); + else + set_multi_in_bit_field(bf->native, first, count); Py_RETURN_NONE; diff --git a/plugins/pychrysalide/common/module.c b/plugins/pychrysalide/common/module.c index a0042ee..5fc1135 100644 --- a/plugins/pychrysalide/common/module.c +++ b/plugins/pychrysalide/common/module.c @@ -26,13 +26,13 @@ #include "bits.h" -#include "fnv1a.h" -#include "hex.h" -#include "itoa.h" -#include "leb128.h" -#include "packed.h" -#include "pathname.h" -#include "pearson.h" +//#include "fnv1a.h" +//#include "hex.h" +//#include "itoa.h" +//#include "leb128.h" +//#include "packed.h" +//#include "pathname.h" +//#include "pearson.h" #include "../helpers.h" @@ -98,15 +98,17 @@ bool populate_common_module(void) result = true; + /* if (result) result = populate_common_module_with_fnv1a(); if (result) result = populate_common_module_with_hex(); if (result) result = populate_common_module_with_itoa(); if (result) result = populate_common_module_with_leb128(); if (result) result = populate_common_module_with_pathname(); if (result) result = populate_common_module_with_pearson(); + */ if (result) result = ensure_python_bitfield_is_registered(); - if (result) result = ensure_python_packed_buffer_is_registered(); + //if (result) result = ensure_python_packed_buffer_is_registered(); assert(result); |