extern void typeready(PyTypeObject *);
/* The type object is now ready to be used. */
-extern PyTypeObject *inittype(PyTypeObject */*skel*/,
+extern PyTypeObject *inittype(const PyTypeObject */*skel*/,
+ PyTypeObject */*base*/,
PyTypeObject */*meta*/);
/* All-in-one function to construct a working type from a type skeleton
- * SKEL, with metaclass META. The caller is expected to have filled in the
- * direct superclass in SKEL->tp_base.
+ * SKEL, with known base type BASE (null for `object') and metaclass.
*/
/* Alias for built-in types, to fit in with Pyke naming conventions. */
#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); \
+ ty##_pytype = inittype(&ty##_pytype_skel, base##_pytype, meta##_pytype); \
} while (0)
#define INITTYPE(ty, base) INITTYPE_META(ty, base, type)
/* Macros to initialize a type from its skeleton. */
#define GETSET(func, doc) \
{ #func, GETSETNAME(get, func), GETSETNAME(set, func), doc },
-/* Convenience wrapper for filling in `PyMemberDef' tables. Define
+/* Convenience wrappers for filling in `PyMemberDef' tables. Define
* `MEMBERSTRUCT' locally as
*
* #define MEMBERSTRUCT foo_pyobj
*
* around the member table.
*/
-#define MEMBER(name, ty, f, doc) \
- { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },
+#define MEMRNM(name, ty, mem, f, doc) \
+ { #name, ty, offsetof(MEMBERSTRUCT, mem), f, doc },
+#define MEMBER(name, ty, f, doc) MEMRNM(name, ty, name, f, doc)
/* Wrappers for filling in pointers in a `PyTypeObject' structure, (a)
* following Pyke naming convention, and (b) stripping `const' from the types
struct nameval { const char *name; unsigned f; unsigned long value; };
#define CF_SIGNED 1u
extern void setconstants(PyObject *, const struct nameval *);
+#define CONST(x) { #x, (x) >= 0 ? 0 : CF_SIGNED, x }
+#define CONSTFLAG(f, x) { #x, f, x }
#define INSEXC(name, var, base, meth) \
INSERT(name, var = mkexc(mod, base, name, meth))