X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/8ebc32d8616aeac9892d20cebfbdc1b531b29d2c..91e56f0647ff205643debd5cdb93797ea0e8da24:/share.c diff --git a/share.c b/share.c index 342144e..5d54947 100644 --- a/share.c +++ b/share.c @@ -53,7 +53,7 @@ static PyObject *gfsget_threshold(PyObject *me, void *hunoz) static PyObject *gfsget_size(PyObject *me, void *hunoz) { return (PyInt_FromLong(GFSHARE_S(me)->sz)); } -static PyGetSetDef gfshare_pygetset[]= { +static const PyGetSetDef gfshare_pygetset[]= { #define GETSETNAME(op, name) gfs##op##_##name GET (threshold, "S.threshold -> THRESHOLD") GET (size, "S.size -> SECRETSZ") @@ -96,7 +96,7 @@ static PyTypeObject gfshare_pytype_skel = { 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ - gfshare_pygetset, /* @tp_getset@ */ + PYGETSET(gfshare), /* @tp_getset@ */ 0, /* @tp_base@ */ 0, /* @tp_dict@ */ 0, /* @tp_descr_get@ */ @@ -142,7 +142,7 @@ end: return (rc); } -static PyMethodDef gfsharesplit_pymethods[] = { +static const PyMethodDef gfsharesplit_pymethods[] = { #define METHNAME(name) gfsmeth_##name METH (get, "S.get(I) -> SHARE") #undef METHNAME @@ -183,7 +183,7 @@ static PyTypeObject gfsharesplit_pytype_skel = { 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ - gfsharesplit_pymethods, /* @tp_methods@ */ + PYMETHODS(gfsharesplit), /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ 0, /* @tp_base@ */ @@ -241,10 +241,9 @@ end: return (0); } -static PyObject *gfsmeth_combine(PyObject *me, PyObject *arg) +static PyObject *gfsmeth_combine(PyObject *me) { PyObject *rc = 0; - if (!PyArg_ParseTuple(arg, ":combine")) goto end; if (GFSHARE_S(me)->i < GFSHARE_S(me)->t) VALERR("not enough shares yet"); rc = bytestring_pywrap(0, GFSHARE_S(me)->sz); gfshare_combine(GFSHARE_S(me), PyString_AS_STRING(rc)); @@ -252,11 +251,11 @@ end: return (rc); } -static PyMethodDef gfsharejoin_pymethods[] = { +static const PyMethodDef gfsharejoin_pymethods[] = { #define METHNAME(name) gfsmeth_##name METH (addedp, "S.addedp(I) -> BOOL") METH (add, "S.add(I, SHARE) -> REMAIN") - METH (combine, "S.combine() -> SECRET") + NAMETH(combine, "S.combine() -> SECRET") #undef METHNAME { 0 } }; @@ -264,7 +263,7 @@ static PyMethodDef gfsharejoin_pymethods[] = { static PyObject *gfsget_remain(PyObject *me, void *hunoz) { return (PyInt_FromLong(GFSHARE_S(me)->t - GFSHARE_S(me)->i)); } -static PyGetSetDef gfsharejoin_pygetset[]= { +static const PyGetSetDef gfsharejoin_pygetset[]= { #define GETSETNAME(op, name) gfs##op##_##name GET (remain, "S.remain -> REMAIN") #undef GETSETNAME @@ -305,9 +304,9 @@ static PyTypeObject gfsharejoin_pytype_skel = { 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ - gfsharejoin_pymethods, /* @tp_methods@ */ + PYMETHODS(gfsharejoin), /* @tp_methods@ */ 0, /* @tp_members@ */ - gfsharejoin_pygetset, /* @tp_getset@ */ + PYGETSET(gfsharejoin), /* @tp_getset@ */ 0, /* @tp_base@ */ 0, /* @tp_dict@ */ 0, /* @tp_descr_get@ */ @@ -345,7 +344,7 @@ static PyObject *sget_threshold(PyObject *me, void *hunoz) static PyObject *sget_modulus(PyObject *me, void *hunoz) { return (mp_pywrap(SHARE_S(me)->p)); } -static PyGetSetDef share_pygetset[]= { +static const PyGetSetDef share_pygetset[]= { #define GETSETNAME(op, name) s##op##_##name GET (threshold, "S.threshold -> THRESHOLD") GET (modulus, "S.modulus -> MODULUS") @@ -388,7 +387,7 @@ static PyTypeObject share_pytype_skel = { 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ - share_pygetset, /* @tp_getset@ */ + PYGETSET(share), /* @tp_getset@ */ 0, /* @tp_base@ */ 0, /* @tp_dict@ */ 0, /* @tp_descr_get@ */ @@ -439,7 +438,7 @@ end: return (rc); } -static PyMethodDef sharesplit_pymethods[] = { +static const PyMethodDef sharesplit_pymethods[] = { #define METHNAME(name) smeth_##name METH (get, "S.get(I) -> SHARE") #undef METHNAME @@ -480,7 +479,7 @@ static PyTypeObject sharesplit_pytype_skel = { 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ - sharesplit_pymethods, /* @tp_methods@ */ + PYMETHODS(sharesplit), /* @tp_methods@ */ 0, /* @tp_members@ */ 0, /* @tp_getset@ */ 0, /* @tp_base@ */ @@ -541,21 +540,20 @@ end: return (rc); } -static PyObject *smeth_combine(PyObject *me, PyObject *arg) +static PyObject *smeth_combine(PyObject *me) { PyObject *rc = 0; - if (!PyArg_ParseTuple(arg, ":combine")) goto end; if (SHARE_S(me)->i < SHARE_S(me)->t) VALERR("not enough shares yet"); rc = mp_pywrap(share_combine(SHARE_S(me))); end: return (rc); } -static PyMethodDef sharejoin_pymethods[] = { +static const PyMethodDef sharejoin_pymethods[] = { #define METHNAME(name) smeth_##name METH (addedp, "S.addedp(I) -> BOOL") METH (add, "S.add(I, SHARE) -> REMAIN") - METH (combine, "S.combine() -> SECRET") + NAMETH(combine, "S.combine() -> SECRET") #undef METHNAME { 0 } }; @@ -563,7 +561,7 @@ static PyMethodDef sharejoin_pymethods[] = { static PyObject *sget_remain(PyObject *me, void *hunoz) { return (PyInt_FromLong(SHARE_S(me)->t - SHARE_S(me)->i)); } -static PyGetSetDef sharejoin_pygetset[]= { +static const PyGetSetDef sharejoin_pygetset[]= { #define GETSETNAME(op, name) s##op##_##name GET (remain, "S.remain -> REMAIN") #undef GETSETNAME @@ -604,9 +602,9 @@ static PyTypeObject sharejoin_pytype_skel = { 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ 0, /* @tp_iternext@ */ - sharejoin_pymethods, /* @tp_methods@ */ + PYMETHODS(sharejoin), /* @tp_methods@ */ 0, /* @tp_members@ */ - sharejoin_pygetset, /* @tp_getset@ */ + PYGETSET(sharejoin), /* @tp_getset@ */ 0, /* @tp_base@ */ 0, /* @tp_dict@ */ 0, /* @tp_descr_get@ */