X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/b06387d238f78afd7e74a1420e925b97120b9c48..917dbf4b50d8fb81d7f899b3397ced4537699255:/catacomb-python.h diff --git a/catacomb-python.h b/catacomb-python.h index 9d86e57..490862b 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -33,13 +33,12 @@ /*----- Header files ------------------------------------------------------*/ +#define PY_SSIZE_T_CLEAN + #include #include #include -#undef ULLONG_MAX -#undef ULONG_LONG_MAX - #include #include #include @@ -47,6 +46,7 @@ #include #include +#include #include #include @@ -65,9 +65,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include @@ -86,6 +89,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -128,7 +135,6 @@ #define VALERR(str) EXCERR(PyExc_ValueError, str) #define TYERR(str) EXCERR(PyExc_TypeError, str) #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str) -#define SYNERR(str) EXCERR(PyExc_SyntaxError, str) #define SYSERR(str) EXCERR(PyExc_SystemError, str) #define NIERR(str) EXCERR(PyExc_NotImplementedError, str) #define INDEXERR(idx) do { \ @@ -159,10 +165,11 @@ #define root_pytype 0 #define type_pytype &PyType_Type -#define INITTYPE(ty, base) do { \ +#define INITTYPE_META(ty, base, meta) do { \ ty##_pytype_skel.tp_base = base##_pytype; \ - ty##_pytype = inittype(&ty##_pytype_skel); \ + ty##_pytype = inittype(&ty##_pytype_skel, meta##_pytype); \ } while (0) +#define INITTYPE(ty, base) INITTYPE_META(ty, base, type) #define INSERT(name, ob) do { \ PyObject *_o = (PyObject *)(ob); \ @@ -188,11 +195,11 @@ { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc }, #define MODULES(_) \ + _(util) \ _(bytestring) _(buffer) \ _(rand) _(algorithms) _(pubkey) _(pgen) \ _(mp) _(field) _(ec) _(group) \ - _(passphrase) _(share) _(key) \ - _(util) + _(passphrase) _(share) _(key) #define DOMODINIT(m) m##_pyinit(); #define DOMODINSERT(m) m##_pyinsert(mod); #define INIT_MODULES do { MODULES(DOMODINIT) } while (0) @@ -239,15 +246,18 @@ extern int convulong(PyObject *, void *); DOUINTSZ(DECL_CONVU_) extern int convmpw(PyObject *, void *); extern int convuint(PyObject *, void *); +extern int convk64(PyObject *, void *); extern int convszt(PyObject *, void *); extern int convbool(PyObject *, void *); extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *); extern PyObject *getbool(int); extern PyObject *getulong(unsigned long); +extern PyObject *getk64(kludge64); extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *); -extern PyObject * mkexc(PyObject *, PyObject *, const char *, PyMethodDef *); -extern PyTypeObject *inittype(PyTypeObject *); +extern PyObject *mkexc(PyObject *, PyObject *, const char *, PyMethodDef *); +extern void typeready(PyTypeObject *); +extern PyTypeObject *inittype(PyTypeObject *, PyTypeObject *); extern void addmethods(const PyMethodDef *); extern PyMethodDef *donemethods(void); @@ -282,7 +292,7 @@ extern PyMethodDef *donemethods(void); GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL) #define GMAP_ROMETHODS GMAP_DOROMETHODS(GMAP_METH, GMAP_KWMETH) #define GMAP_METHODS GMAP_DOMETHODS(GMAP_METH, GMAP_KWMETH) -extern int gmap_pysize(PyObject *); +extern Py_ssize_t gmap_pysize(PyObject *); extern PySequenceMethods gmap_pysequence; extern PyMethodDef gmap_pymethods[]; @@ -314,10 +324,11 @@ extern mp *getgf(PyObject *); extern int convgf(PyObject *, void *); extern PyObject *mp_pywrap(mp *); extern PyObject *gf_pywrap(mp *); +extern long mphash(mp *); extern mp *mp_frompyobject(PyObject *, int); extern PyObject *mp_topystring(mp *, int, const char *, const char *, const char *); -extern int mp_tolong_checked(mp *, long *); +extern int mp_tolong_checked(mp *, long *, int); /*----- Abstract fields ---------------------------------------------------*/