diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2008-10-19 16:43:28 -0400 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2008-10-19 17:05:11 -0400 |
commit | 909a6207322c67bb865d97e8f921c91c82720ec7 (patch) | |
tree | a584b6a37e19aa77e535576715caef95cbbc50da /src/_counter.c | |
parent | 5eb1932e1dd6c989f55880c78c4f1d0f6729f887 (diff) | |
download | pycrypto-909a6207322c67bb865d97e8f921c91c82720ec7.tar.gz |
Util.Counter: Make the interface more intuitive
- Replace ctr.next() with ctr()
- Replace ctr.get_value() with ctr.next_value()
Diffstat (limited to 'src/_counter.c')
-rw-r--r-- | src/_counter.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/_counter.c b/src/_counter.c index 805345a..59c03cd 100644 --- a/src/_counter.c +++ b/src/_counter.c @@ -135,7 +135,7 @@ CounterObject_dealloc(PCT_CounterObject *self) } static inline PyObject * -_CounterObject_get_value(PCT_CounterObject *self, int little_endian) +_CounterObject_next_value(PCT_CounterObject *self, int little_endian) { unsigned int i, increment; uint8_t *p; @@ -194,19 +194,19 @@ err_out: } static PyObject * -CounterLEObject_get_value(PCT_CounterObject *self, PyObject *args) +CounterLEObject_next_value(PCT_CounterObject *self, PyObject *args) { - return _CounterObject_get_value(self, 1); + return _CounterObject_next_value(self, 1); } static PyObject * -CounterBEObject_get_value(PCT_CounterObject *self, PyObject *args) +CounterBEObject_next_value(PCT_CounterObject *self, PyObject *args) { - return _CounterObject_get_value(self, 0); + return _CounterObject_next_value(self, 0); } static PyObject * -CounterLEObject_next(PCT_CounterObject *self, PyObject *args) +CounterLEObject_call(PCT_CounterObject *self, PyObject *args, PyObject *kwargs) { unsigned int i, tmp, carry; uint8_t *p; @@ -228,7 +228,7 @@ CounterLEObject_next(PCT_CounterObject *self, PyObject *args) } static PyObject * -CounterBEObject_next(PCT_CounterObject *self, PyObject *args) +CounterBEObject_call(PCT_CounterObject *self, PyObject *args, PyObject *kwargs) { unsigned int i, tmp, carry; uint8_t *p; @@ -250,19 +250,15 @@ CounterBEObject_next(PCT_CounterObject *self, PyObject *args) } static PyMethodDef CounterLEObject_methods[] = { - {"next", (PyCFunction)CounterLEObject_next, METH_VARARGS, - "Return the current counter value, then increment it."}, - {"get_value", (PyCFunction)CounterLEObject_get_value, METH_VARARGS, - "Get the numerical value of the counter.\n\nThis is a slow operation.\n"}, + {"next_value", (PyCFunction)CounterLEObject_next_value, METH_VARARGS, + "Get the numerical value of next value of the counter."}, {NULL} /* sentinel */ }; static PyMethodDef CounterBEObject_methods[] = { - {"next", (PyCFunction)CounterBEObject_next, METH_VARARGS, - "Return the current counter value, then increment it."}, - {"get_value", (PyCFunction)CounterBEObject_get_value, METH_VARARGS, - "Get the numerical value of the counter.\n\nThis is a slow operation.\n"}, + {"next_value", (PyCFunction)CounterBEObject_next_value, METH_VARARGS, + "Get the numerical value of next value of the counter."}, {NULL} /* sentinel */ }; @@ -298,7 +294,7 @@ my_CounterLEType = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - 0, /* tp_call */ + (ternaryfunc)CounterLEObject_call, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ @@ -324,7 +320,7 @@ my_CounterBEType = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - 0, /* tp_call */ + (ternaryfunc)CounterBEObject_call, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ |