chiark / gitweb /
algorithms.c: Check whether `setiv' and `bdry' are implemented before calling.
[catacomb-python] / pgen.c
diff --git a/pgen.c b/pgen.c
index cb8d10c93bff59703f9bb1dcb6bda92d8271bcd7..108fa31a5168c19cac5aaa03b59c8752dc6d9da5 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -1,6 +1,4 @@
 /* -*-c-*-
- *
- * $Id$
  *
  * Prime number generation
  *
@@ -122,9 +120,8 @@ static PyObject *pfilt_pyint(PyObject *me)
   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);
 }
 
@@ -199,7 +196,7 @@ static PyNumberMethods pfilt_pynumber = {
 
 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@ */
 
@@ -332,7 +329,7 @@ static PyMethodDef rabin_pymethods[] = {
 
 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@ */
 
@@ -450,7 +447,7 @@ static PyGetSetDef pgevent_pygetset[] = {
 
 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@ */
 
@@ -631,7 +628,7 @@ static PyMethodDef pgev_pymethods[] = {
 
 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@ */
 
@@ -705,7 +702,7 @@ static PyGetSetDef pgstep_pygetset[] = {
 
 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@ */
 
@@ -787,7 +784,7 @@ static PyGetSetDef pgjump_pygetset[] = {
 
 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@ */
 
@@ -848,7 +845,7 @@ end:
 
 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@ */
 
@@ -1037,8 +1034,8 @@ pgen(START, [name = 'p', stepper = PrimeGenStepper(2),\n\
 strongprime_setup(NBITS, [name = 'p', event = pgen_nullev,\n\
                  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, ...])")