X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/2a28a112d346a36bc2b5e4918d8ce26d8321a855..ab5212e53b51e516f086e20b66c121d966967a9a:/group.c diff --git a/group.c b/group.c index 1c869a4..1f733a0 100644 --- a/group.c +++ b/group.c @@ -1,13 +1,11 @@ /* -*-c-*- - * - * $Id$ * * Abstract group inteface * * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the Python interface to Catacomb. * @@ -15,12 +13,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * Catacomb/Python is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Catacomb/Python; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -227,11 +225,11 @@ static PyObject *namedgroups(const pentry *pp, int *ne) } c = PyInt_FromLong(i); found: - PyDict_SetItemString(d, (/*unconst*/ char *)pp[i].name, c); + PyDict_SetItemString(d, (/*unconst*/ char *)p, c); Py_DECREF(c); } *ne = i; - return (d); + return (d); } static PyObject *meth__groupn(PyObject *me, PyObject *arg, @@ -269,7 +267,7 @@ static PyObject *meth__parse(PyObject *me, PyObject *arg, PyTypeObject *ty, if (parse(&qd, &gp)) SYNERR(qd.e); rc = fginfo_pywrap(&gp, ty); end: - return (rc); + return (rc); } static PyObject *meth__DHInfo_parse(PyObject *me, PyObject *arg) @@ -468,7 +466,7 @@ group *group_copy(group *g) gb.p = gc->r.p; gb.q = gc->g.r; g = group_binary(&gb); - MP_DROP(gb.g); + MP_DROP(gb.g); } else if (strcmp(G_NAME(g), "ec") == 0) { gctx_ec *gc = (gctx_ec *)g; ec_info ei; @@ -534,17 +532,17 @@ static PyObject *group_dopywrap(PyTypeObject *ty, group *g) { group_pyobj *gobj = newtype(ty, 0, g->ops->name); gobj->g = g; - gobj->ty.type.tp_basicsize = sizeof(ge_pyobj); - gobj->ty.type.tp_base = ge_pytype; + gobj->ty.ht_type.tp_basicsize = sizeof(ge_pyobj); + gobj->ty.ht_type.tp_base = ge_pytype; Py_INCREF(group_pytype); - gobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_HEAPTYPE); - gobj->ty.type.tp_alloc = PyType_GenericAlloc; - gobj->ty.type.tp_free = 0; - gobj->ty.type.tp_new = ge_pynew; - PyType_Ready(&gobj->ty.type); + gobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_HEAPTYPE); + gobj->ty.ht_type.tp_alloc = PyType_GenericAlloc; + gobj->ty.ht_type.tp_free = 0; + gobj->ty.ht_type.tp_new = ge_pynew; + PyType_Ready(&gobj->ty.ht_type); return ((PyObject *)gobj); } @@ -784,13 +782,13 @@ static PyObject *gmeth_mexp(PyObject *me, PyObject *arg) gmexp_id, gmexp_fill, gmexp_exp, gmexp_drop)); } -static PyObject *gmeth_check(PyObject *me, PyObject *arg, PyObject *kw) +static PyObject *gmeth_checkgroup(PyObject *me, PyObject *arg, PyObject *kw) { char *kwlist[] = { "rng", 0 }; grand *r = &rand_global; const char *p; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:check", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:checkgroup", kwlist, convgrand, &r)) goto end; if ((p = G_CHECK(GROUP_G(me), r)) != 0) @@ -1051,7 +1049,7 @@ static PyMethodDef group_pymethods[] = { #define METHNAME(name) gmeth_##name METH (mexp, "\ G.mexp([(X0, N0), (X1, N1), ...]) -> X0^N0 X1^N1 ...") - KWMETH(check, "G.check(rand = random): check group is good") + KWMETH(checkgroup, "G.checkgroup(rand = random): check group is good") #undef METHNAME { 0 } }; @@ -1350,10 +1348,10 @@ static PyMethodDef methods[] = { METH (_BinDHInfo__groupn, 0) KWMETH(_DHInfo_generate, "\ generate(PBITS, [qbits = 0, event = pgen_nullev,\n\ - rng = rand, nsteps = 0]) -> D") + rng = rand, nsteps = 0]) -> D") KWMETH(_DHInfo_genlimlee, "\ genlimlee(PBITS, QBITS, [event = pgen_nullev, ievent = pgen_nullev,\n\ - rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])") + rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])") KWMETH(_DHInfo_gendsa, "\ gendsa(PBITS, QBITS, SEED, [event = pgen_nullev, nsteps = 0])\n\ -> (D, SEED, COUNT)")