summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/common/bits.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/common/bits.c')
-rw-r--r--plugins/pychrysalide/common/bits.c32
1 files changed, 22 insertions, 10 deletions
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;