X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/blobdiff_plain/dce47d5020064fb1fc0c58db165d72c7ffd10835..87fa2d560608d1b07c715357dc524e0d9eb3286c:/pyke.h diff --git a/pyke.h b/pyke.h index b91b48d..e200c09 100644 --- a/pyke.h +++ b/pyke.h @@ -269,6 +269,20 @@ extern PyTypeObject *inittype(PyTypeObject */*skel*/, #define MEMBER(name, ty, f, doc) \ { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc }, +/* Wrappers for filling in pointers in a `PyTypeObject' structure, (a) + * following Pyke naming convention, and (b) stripping `const' from the types + * without losing type safety. + */ +#define UNCONST_TYPE_SLOT(type, suffix, op, ty) \ + CONVERT_CAREFULLY(type *, const type *, op ty##_py##suffix) +#define PYGETSET(ty) UNCONST_TYPE_SLOT(PyGetSetDef, getset, NOTHING, ty) +#define PYMETHODS(ty) UNCONST_TYPE_SLOT(PyMethodDef, methods, NOTHING, ty) +#define PYMEMBERS(ty) UNCONST_TYPE_SLOT(PyMemberDef, members, NOTHING, ty) +#define PYNUMBER(ty) UNCONST_TYPE_SLOT(PyNumberMethods, number, &, ty) +#define PYSEQUENCE(ty) UNCONST_TYPE_SLOT(PySequenceMethods, sequence, &, ty) +#define PYMAPPING(ty) UNCONST_TYPE_SLOT(PyMappingMethods, mapping, &, ty) +#define PYBUFFER(ty) UNCONST_TYPE_SLOT(PyBufferProcs, buffer, &, ty) + /*----- Populating modules ------------------------------------------------*/ extern PyObject *modname; @@ -278,7 +292,7 @@ extern PyObject *home_module; /* The overall module object. */ extern PyObject *mkexc(PyObject */*mod*/, PyObject */*base*/, - const char */*name*/, PyMethodDef */*methods*/); + const char */*name*/, const PyMethodDef */*methods*/); /* Make and return an exception class called NAME, which will end up in * module MOD (though it is not added at this time). The new class is a * subclass of BASE. Attach the METHODS to it. @@ -376,8 +390,8 @@ GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL) /* Mapping protocol implementation. */ extern Py_ssize_t gmap_pysize(PyObject *); /* for `mp_length' */ -extern PySequenceMethods gmap_pysequence; /* for `tp_as_sequence' */ -extern PyMethodDef gmap_pymethods[]; /* all the standard methods */ +extern const PySequenceMethods gmap_pysequence; /* for `tp_as_sequence' */ +extern const PyMethodDef gmap_pymethods[]; /* all the standard methods */ /*----- That's all, folks -------------------------------------------------*/