-static PyObject *meth__MP_fromstring(PyObject *me,
- PyObject *arg, PyObject *kw)
-{
- int r = 0;
- char *p;
- Py_ssize_t len;
- PyObject *z = 0;
- mp *zz;
- mptext_stringctx sc;
- static const char *const kwlist[] = { "class", "x", "radix", 0 };
-
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|i:fromstring",
- KWLIST, &me, &p, &len, &r))
- goto end;
- if (!good_radix_p(r, 1)) VALERR("bad radix");
- sc.buf = p; sc.lim = p + len;
- if ((zz = mp_read(MP_NEW, r, &mptext_stringops, &sc)) == 0)
- VALERR("bad integer");
- z = Py_BuildValue("(Ns#)", mp_pywrap(zz),
- sc.buf, (Py_ssize_t)(sc.lim - sc.buf));
-end:
- return (z);
-}
-
-static PyObject *meth__MP_factorial(PyObject *me, PyObject *arg)
-{
- unsigned long i;
- mp *x;
- if (!PyArg_ParseTuple(arg, "OO&:factorial", &me, convulong, &i))
- return (0);
- x = mp_factorial(i);
- return mp_pywrap(x);
-}
-
-static PyObject *meth__MP_fibonacci(PyObject *me, PyObject *arg)
-{
- long i;
- mp *x;
- if (!PyArg_ParseTuple(arg, "Ol:fibonacci", &me, &i)) return (0);
- x = mp_fibonacci(i);
- return mp_pywrap(x);
-}
-
-#define LOADOP(pre, py, name) \
- static PyObject *meth__##py##_##name(PyObject *me, PyObject *arg) \
- { \
- char *p; \
- Py_ssize_t len; \
- if (!PyArg_ParseTuple(arg, "Os#:" #name, &me, &p, &len)) return (0); \
- return (pre##_pywrap(mp_##name(MP_NEW, p, len))); \
- }
-LOADOP(mp, MP, loadl)
-LOADOP(mp, MP, loadb)
-LOADOP(mp, MP, loadl2c)
-LOADOP(mp, MP, loadb2c)
-LOADOP(gf, GF, loadl)
-LOADOP(gf, GF, loadb)
-#undef LOADOP
-