X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/620169aef06f74c9a8574e28b5482061e81a7389..54fd7594ee5df9dbc9745d98adaa01a5ed43b6e4:/catacomb-python.h?ds=sidebyside diff --git a/catacomb-python.h b/catacomb-python.h index c3b120d..e74e048 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -70,6 +70,7 @@ PUBLIC_SYMBOLS; #include #include #include +#include #include #include @@ -81,6 +82,7 @@ PUBLIC_SYMBOLS; #include #include +#include #include #include #include @@ -150,7 +152,7 @@ extern PyObject *mexp_common(PyObject *, PyObject *, size_t, PyObject *(*id)(PyObject *), int (*fill)(void *, PyObject *, PyObject *, PyObject *), - PyObject *(*exp)(PyObject *, void *, int), + PyObject *(*exp)(PyObject *, void *, size_t), void (*drop)(void *)); /*----- Bytestrings -------------------------------------------------------*/ @@ -158,6 +160,27 @@ extern PyObject *mexp_common(PyObject *, PyObject *, size_t, PyObject *bytestring_pywrap(const void *, size_t); PyObject *bytestring_pywrapbuf(buf *); +/*----- Buffers -----------------------------------------------------------*/ + +typedef struct buf_pyobj { + PyObject_HEAD + buf b; + PyObject *sub; + unsigned lk; +} buf_pyobj; + +extern PyTypeObject *rbuf_pytype, *wbuf_pytype; +#define RBUF_PYCHECK(o) PyObject_TypeCheck((o), rbuf_pytype) +#define WBUF_PYCHECK(o) PyObject_TypeCheck((o), wbuf_pytype) +#define BUF_B(o) (&((buf_pyobj *)(o))->b) +#define BUF_SUB(o) (((buf_pyobj *)(o))->sub) +#define BUF_LK(o) (((buf_pyobj *)(o))->lk) + +extern PyObject *buferr; +#define BUFERR(str) do { PyErr_SetString(buferr, str); goto end; } while (0) + +extern int ensurebuf(PyObject *, size_t); + /*----- Multiprecision arithmetic -----------------------------------------*/ typedef struct mp_pyobj { @@ -174,8 +197,10 @@ extern PyTypeObject *gf_pytype; extern mp *mp_frompylong(PyObject *); extern PyObject *mp_topylong(mp *); extern mp *tomp(PyObject *); +extern mp *implicitmp(PyObject *); extern mp *getmp(PyObject *); extern int convmp(PyObject *, void *); +extern mp *implicitgf(PyObject *); extern mp *getgf(PyObject *); extern int convgf(PyObject *, void *); extern PyObject *mp_pywrap(mp *);