* 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.
* 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.
* 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.
* 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.
o = PyObject_New(pfilt_pyobj, pfilt_pytype);
o->f = *f;
o->st = pfilt_step(f, 0);
o = PyObject_New(pfilt_pyobj, pfilt_pytype);
o->f = *f;
o->st = pfilt_step(f, 0);
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &xobj))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &xobj))
- if (mp_tolong_checked(PFILT_F(me)->m, &l)) goto end;
- rc = PyInt_FromLong(l);
-end:
+ if (!mp_tolong_checked(PFILT_F(me)->m, &l, 0)) rc = PyInt_FromLong(l);
+ else rc = mp_topylong(PFILT_F(me)->m);
static PyTypeObject pfilt_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject pfilt_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmp, &x))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmp, &x))
goto end;
if (!MP_POSP(x) || MP_EVENP(x)) VALERR("must be positive and odd");
o = (rabin_pyobj *)ty->tp_alloc(ty, 0);
goto end;
if (!MP_POSP(x) || MP_EVENP(x)) VALERR("must be positive and odd");
o = (rabin_pyobj *)ty->tp_alloc(ty, 0);
static PyTypeObject rabin_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject rabin_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyObject *pgevent_pywrap(pgen_event *ev)
{
pgevent_pyobj *o = PyObject_New(pgevent_pyobj, pgevent_pytype);
static PyObject *pgevent_pywrap(pgen_event *ev)
{
pgevent_pyobj *o = PyObject_New(pgevent_pyobj, pgevent_pytype);
-static void pgevent_kill(PyObject *me) { PGEVENT_EV(me) = 0; }
-static void pgevent_pydealloc(PyObject *me) { FREEOBJ(me); }
+static void pgevent_kill(PyObject *me)
+{
+ pgevent_pyobj *ev = (pgevent_pyobj *)me;
+
+ ev->ev = 0;
+ if (ev->r) GRAND_R(ev->r) = 0;
+}
+
+static void pgevent_pydealloc(PyObject *me)
+{
+ pgevent_pyobj *ev = (pgevent_pyobj *)me;
+ if (ev->r) Py_DECREF(ev->r);
+ FREEOBJ(me);
+}
{ PGEVENT_CHECK(me); return (PyInt_FromLong(PGEVENT_EV(me)->tests)); }
static PyObject *peget_rng(PyObject *me, void *hunoz)
{ PGEVENT_CHECK(me); return (PyInt_FromLong(PGEVENT_EV(me)->tests)); }
static PyObject *peget_rng(PyObject *me, void *hunoz)
- { PGEVENT_CHECK(me); return (grand_pywrap(PGEVENT_EV(me)->r, 0)); }
+{
+ pgevent_pyobj *ev = (pgevent_pyobj *)me;
+
+ PGEVENT_CHECK(me);
+ if (!ev->r) ev->r = grand_pywrap(ev->ev->r, 0);
+ Py_INCREF(ev->r); return ((PyObject *)ev->r);
+}
static PyTypeObject pgevent_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject pgevent_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- char *meth[] = {
- "pg_abort", "pg_done", "pg_begin", "pg_try", "pg_fail", "pg_pass"
- };
+ static const char *const meth[] =
+ { "pg_abort", "pg_done", "pg_begin", "pg_try", "pg_fail", "pg_pass" };
- if ((rc = PyObject_CallMethod(py, meth[rq], "(O)", pyev)) == 0)
+ if ((rc = PyObject_CallMethod(py, (/*unconst*/ char *)meth[rq],
+ "(O)", pyev)) == 0)
static PyTypeObject pgev_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject pgev_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmpw, &s))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmpw, &s))
static PyGetSetDef pgstep_pygetset[] = {
#define GETSETNAME(op, name) ps##op##_##name
static PyGetSetDef pgstep_pygetset[] = {
#define GETSETNAME(op, name) ps##op##_##name
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgstep_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgstep_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &o) ||
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &o) ||
(fobj = pfilt_pymake(pfilt_pytype, o)) == 0)
goto end;
rc = (pgjump_pyobj *)ty->tp_alloc(ty, 0);
(fobj = pfilt_pymake(pfilt_pytype, o)) == 0)
goto end;
rc = (pgjump_pyobj *)ty->tp_alloc(ty, 0);
static PyGetSetDef pgjump_pygetset[] = {
#define GETSETNAME(op, name) pj##op##_##name
static PyGetSetDef pgjump_pygetset[] = {
#define GETSETNAME(op, name) pj##op##_##name
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgjump_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgjump_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", kwlist)) goto end;
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST)) goto end;
static PyTypeObject pgtest_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
static PyTypeObject pgtest_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
rabin tc;
pgev step = { 0 }, test = { 0 }, evt = { 0 };
unsigned nsteps = 0, ntests = 0;
rabin tc;
pgev step = { 0 }, test = { 0 }, evt = { 0 };
unsigned nsteps = 0, ntests = 0;
- char *kwlist[] = { "start", "name", "stepper", "tester", "event",
- "nsteps", "ntests", 0 };
+ static const char *const kwlist[] =
+ { "start", "name", "stepper", "tester", "event", "nsteps", "ntests", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&O&O&:pgen", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&O&O&:pgen", KWLIST,
convmp, &x, &p, convpgev, &step,
convpgev, &test, convpgev, &evt,
convuint, &nsteps, convuint, &ntests))
convmp, &x, &p, convpgev, &step,
convpgev, &test, convpgev, &evt,
convuint, &nsteps, convuint, &ntests))
- char *kwlist[] = { "nbits", "name", "event", "rng", "nsteps", 0 };
+ static const char *const kwlist[] =
+ { "nbits", "name", "event", "rng", "nsteps", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", KWLIST,
convuint, &nbits, &name,
convpgev, &evt, convgrand, &r,
convuint, &n))
convuint, &nbits, &name,
convpgev, &evt, convgrand, &r,
convuint, &n))
- char *kwlist[] = { "nbits", "name", "event", "rng", "nsteps", 0 };
+ static const char *const kwlist[] =
+ { "nbits", "name", "event", "rng", "nsteps", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", KWLIST,
convuint, &nbits, &name,
convpgev, &evt, convgrand, &r,
convuint, &n))
convuint, &nbits, &name,
convpgev, &evt, convgrand, &r,
convuint, &n))
- char *kwlist[] = { "pbits", "qbits", "name", "event", "ievent",
- "rng", "nsteps", 0 };
+ static const char *const kwlist[] =
+ { "pbits", "qbits", "name", "event", "ievent", "rng", "nsteps", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|sO&O&O&O&:limlee", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|sO&O&O&O&:limlee", KWLIST,
convuint, &pl, convuint, &ql,
&p, convpgev, &oe, convpgev, &ie,
convgrand, &r, convuint, &on))
convuint, &pl, convuint, &ql,
&p, convpgev, &oe, convpgev, &ie,
convgrand, &r, convuint, &on))
nsteps = 0, ntests = RabinMiller.iters(START.nbits)]) -> P")
KWMETH(strongprime_setup, "\
strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
nsteps = 0, ntests = RabinMiller.iters(START.nbits)]) -> P")
KWMETH(strongprime_setup, "\
strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
-strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
- rng = rand, nsteps = 0]) -> P")
+strongprime(NBITS, [name = 'p', event = pgen_nullev,\n\
+ rng = rand, nsteps = 0]) -> P")
KWMETH(limlee, "\
limlee(PBITS, QBITS, [name = 'p', event = pgen_nullev,\n\
ievent = pgen_nullev, rng = rand, nsteps = 0]) -> (P, [Q, ...])")
KWMETH(limlee, "\
limlee(PBITS, QBITS, [name = 'p', event = pgen_nullev,\n\
ievent = pgen_nullev, rng = rand, nsteps = 0]) -> (P, [Q, ...])")