+#define FREEOBJ(obj) \
+ (((PyObject *)(obj))->ob_type->tp_free((PyObject *)(obj)))
+
+#define GEN(func, base) \
+ static PyObject *func(void) \
+ { \
+ PyObject *d = PyDict_New(); \
+ PyObject *o; \
+ int i; \
+ \
+ for (i = 0; g##base##tab[i]; i++) { \
+ o = gc##base##_pywrap((/*unconst*/ gc##base *)g##base##tab[i]); \
+ PyDict_SetItemString(d, \
+ (/*unconst*/ char *)g##base##tab[i]->name, \
+ o); \
+ Py_DECREF(o); \
+ } \
+ return (d); \
+ }
+
+struct nameval { const char *name; unsigned long value; };
+extern void setconstants(PyObject *, const struct nameval *);
+
+extern PyObject *mexp_common(PyObject *, PyObject *, size_t,
+ PyObject *(*id)(PyObject *),
+ int (*fill)(void *, PyObject *,
+ PyObject *, PyObject *),
+ PyObject *(*exp)(PyObject *, void *, int),
+ void (*drop)(void *));
+
+extern int convulong(PyObject *, void *);
+#define DECL_CONVU_(n) extern int convu##n(PyObject *, void *);
+DOUINTSZ(DECL_CONVU_)
+extern int convmpw(PyObject *, void *);
+extern int convuint(PyObject *, void *);
+extern int convszt(PyObject *, void *);
+extern int convbool(PyObject *, void *);
+extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);
+extern PyObject *getbool(int);
+#define DECL_GETU_(n) extern PyObject *getu##n(uint##n);
+DOUINTSZ(DECL_GETU_)
+extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *);
+
+extern PyObject * mkexc(PyObject *, PyObject *, const char *, PyMethodDef *);
+extern PyTypeObject *inittype(PyTypeObject *);
+extern void addmethods(const PyMethodDef *);
+extern PyMethodDef *donemethods(void);
+
+/*----- Mapping methods ---------------------------------------------------*/
+
+#define GMAP_METH(func, doc) { #func, gmapmeth_##func, METH_VARARGS, doc },
+#define GMAP_KWMETH(func, doc) \
+ { #func, (PyCFunction)gmapmeth_##func, METH_VARARGS|METH_KEYWORDS, doc },
+#define GMAP_METHDECL(func, doc) \
+ extern PyObject *gmapmeth_##func(PyObject *, PyObject *);
+#define GMAP_KWMETHDECL(func, doc) \
+ extern PyObject *gmapmeth_##func(PyObject *, PyObject *, PyObject *);
+
+#define GMAP_DOMETHODS(METH, KWMETH) \
+ METH (has_key, "D.has_key(KEY) -> BOOL") \
+ METH (keys, "D.keys() -> LIST") \
+ METH (values, "D.values() -> LIST") \
+ METH (items, "D.items() -> LIST") \
+ METH (iterkeys, "D.iterkeys() -> ITER") \
+ METH (itervalues, "D.itervalues() -> ITER") \
+ METH (iteritems, "D.iteritems() -> ITER") \
+ METH (clear, "D.clear()") \
+ KWMETH(get, "D.get(KEY, [default = None]) -> VALUE") \
+ KWMETH(setdefault, "D.setdefault(K, [default = None]) -> VALUE") \
+ KWMETH(pop, "D.pop(KEY, [default = <error>]) -> VALUE") \
+ METH (popitem, "D.popitem() -> (KEY, VALUE)") \
+ METH (update, "D.update(MAP)")
+
+GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL)
+#define GMAP_METHODS GMAP_DOMETHODS(GMAP_METH, GMAP_KWMETH)
+extern int gmap_pysize(PyObject *);
+extern PySequenceMethods gmap_pysequence;
+extern PyMethodDef gmap_pymethods[];
+