-/*----- Utility macros ----------------------------------------------------*/
-
-#define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0)
-#define RETURN_NONE RETURN_OBJ(Py_None)
-#define RETURN_NOTIMPL RETURN_OBJ(Py_NotImplemented)
-#define RETURN_TRUE RETURN_OBJ(Py_True)
-#define RETURN_FALSE RETURN_OBJ(Py_False)
-#define RETURN_ME RETURN_OBJ(me)
-
-#define EXCERR(exc, str) do { \
- PyErr_SetString(exc, str); \
- goto end; \
-} while (0)
-#define VALERR(str) EXCERR(PyExc_ValueError, str)
-#define TYERR(str) EXCERR(PyExc_TypeError, str)
-#define IXERR(str) EXCERR(PyExc_IndexError, str)
-#define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
-#define SYSERR(str) EXCERR(PyExc_SystemError, str)
-#define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
-#define INDEXERR(idx) do { \
- PyErr_SetObject(PyExc_KeyError, idx); \
- goto end; \
-} while (0)
-#define OSERR(name) do { \
- PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); \
- goto end; \
-} while (0)
-#define PGENERR do { pgenerr(); goto end; } while (0)
-
-#define CONVFUNC(ty, cty, ext) \
- int conv##ty(PyObject *o, void *p) \
- { \
- if (!PyObject_TypeCheck(o, ty##_pytype)) \
- TYERR("wanted a " #ty); \
- *(cty *)p = ext(o); \
- return (1); \
- end: \
- return (0); \
- }
-
-#if PY_VERSION_HEX < 0x02050000 /* Compatibility hack */
-# define ht_name name
-# define ht_type type
-#endif
-
-#define root_pytype 0
-#define type_pytype &PyType_Type
-#define INITTYPE_META(ty, base, meta) do { \
- ty##_pytype_skel.tp_base = base##_pytype; \
- 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); \
- Py_INCREF(_o); \
- PyModule_AddObject(mod, name, _o); \
-} while (0)
-
-#define INSEXC(name, var, base, meth) \
- INSERT(name, var = mkexc(mod, base, name, meth))
-
-#define METH(func, doc) \
- { #func, METHNAME(func), METH_VARARGS, doc },
-#define KWMETH(func, doc) \
- { #func, (PyCFunction)METHNAME(func), \
- METH_VARARGS | METH_KEYWORDS, doc },
-
-#define GET(func, doc) \
- { #func, GETSETNAME(get, func), 0, doc },
-#define GETSET(func, doc) \
- { #func, GETSETNAME(get, func), GETSETNAME(set, func), doc },
-
-#define MEMBER(name, ty, f, doc) \
- { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },