X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/c90f712e989f2ee557842c18fdb9a4df469c1859..a539ffb8538158c1dc7eeb4ad5264a6e995496b6:/bytestring.c diff --git a/bytestring.c b/bytestring.c index 2468ea2..3bf1b25 100644 --- a/bytestring.c +++ b/bytestring.c @@ -96,11 +96,11 @@ end: return (0); } -static PyObject *meth__ByteString_zero(PyObject *me, PyObject *arg) +static PyObject *bymeth_zero(PyObject *me, PyObject *arg) { size_t sz; PyObject *rc = 0; - if (!PyArg_ParseTuple(arg, "OO&:zero", &me, convszt, &sz)) goto end; + if (!PyArg_ParseTuple(arg, "O&:zero", convszt, &sz)) goto end; rc = bytestring_pywrap(0, sz); memset(PyString_AS_STRING(rc), 0, sz); end: @@ -265,6 +265,13 @@ BINOP(xor, ^) } UNOP(not, ~) +static const PyMethodDef bytestring_pymethods[] = { +#define METHNAME(name) bymeth_##name + SMTH (zero, "zero(N) -> 0000...00") +#undef METHNAME + { 0 } +}; + static const PyNumberMethods bytestring_pynumber = { 0, /* @nb_add@ */ 0, /* @nb_subtract@ */ @@ -310,7 +317,7 @@ static const PyMappingMethods bytestring_pymapping = { 0, /* @mp_ass_subscript@ */ }; -static PyTypeObject bytestring_pytype_skel = { +static const PyTypeObject bytestring_pytype_skel = { PyObject_HEAD_INIT(0) 0, /* Header */ "ByteString", /* @tp_name@ */ 0, /* @tp_basicsize@ */ @@ -344,7 +351,7 @@ static PyTypeObject bytestring_pytype_skel = { 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ - 0, /* @tp_methods@ */ + PYMETHODS(bytestring), /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ 0, /* @tp_base@ */ @@ -364,7 +371,6 @@ static PyTypeObject bytestring_pytype_skel = { static const PyMethodDef methods[] = { #define METHNAME(func) meth_##func METH (ctstreq, "ctstreq(S, T) -> BOOL") - METH (_ByteString_zero, "zero(N) -> 0000...00") #undef METHNAME { 0 } };