/* -*-c-*-
- *
- * $Id$
*
* Prime number generation
*
* (c) 2005 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of the Python interface to Catacomb.
*
* 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.
o = PyObject_New(pfilt_pyobj, pfilt_pytype);
o->f = *f;
o->st = pfilt_step(f, 0);
- return ((PyObject *)o);
+ return ((PyObject *)o);
}
static PyObject *pfilt_pymake(PyTypeObject *ty, PyObject *xobj)
long l;
PyObject *rc = 0;
- 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);
return (rc);
}
static PyTypeObject pfilt_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeFilter", /* @tp_name@ */
+ "PrimeFilter", /* @tp_name@ */
sizeof(pfilt_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject rabin_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.RabinMiller", /* @tp_name@ */
+ "RabinMiller", /* @tp_name@ */
sizeof(rabin_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
mp *x = 0;
pgen_event *ev = PGEVENT_EV(me);
int rc = -1;
+ if (!x) NIERR("__del__");
PGEVENT_CHECK(me);
if ((x = getmp(xobj)) == 0) goto end;
mp_drop(ev->m);
static PyTypeObject pgevent_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeGenEvent", /* @tp_name@ */
+ "PrimeGenEvent", /* @tp_name@ */
sizeof(pgevent_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
goto end;
else if (l < PGEN_ABORT || l > PGEN_PASS)
VALERR("return code out of range");
- else
+ else
st = l;
end:
if (pyev) {
static PyTypeObject pgev_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeGenBuiltinHandler", /* @tp_name@ */
+ "PrimeGenBuiltinHandler", /* @tp_name@ */
sizeof(pgev_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyGetSetDef pgstep_pygetset[] = {
#define GETSETNAME(op, name) ps##op##_##name
- GET (step, "S.step -> step size for the stepper")
+ GET (step, "S.step -> step size for the stepper")
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgstep_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeGenStepper", /* @tp_name@ */
+ "PrimeGenStepper", /* @tp_name@ */
sizeof(pgstep_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyGetSetDef pgjump_pygetset[] = {
#define GETSETNAME(op, name) pj##op##_##name
- GET (jump, "S.jump -> jump size for the stepper")
+ GET (jump, "S.jump -> jump size for the stepper")
#undef GETSETNAME
{ 0 }
};
static PyTypeObject pgjump_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeGenJumper", /* @tp_name@ */
+ "PrimeGenJumper", /* @tp_name@ */
sizeof(pgjump_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
static PyTypeObject pgtest_pytype_skel = {
PyObject_HEAD_INIT(0) 0, /* Header */
- "catacomb.PrimeGenTester", /* @tp_name@ */
+ "PrimeGenTester", /* @tp_name@ */
sizeof(pgtest_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
end:
mp_drop(r); mp_drop(x);
droppgev(&step); droppgev(&test); droppgev(&evt);
- return (rc);
+ return (rc);
}
static PyObject *meth_strongprime_setup(PyObject *me,
nsteps = 0, ntests = RabinMiller.iters(START.nbits)]) -> P")
KWMETH(strongprime_setup, "\
strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
- rng = rand, nsteps = 0]) -> (START, JUMP)")
+ rng = rand, nsteps = 0]) -> (START, JUMP)")
KWMETH(strongprime, "\
-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, ...])")