X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/3aa33042dc760937bb9da54c09f7c668f00eb241..6d4db0bf4b67e65708637466d4f0d306ed1dfe53:/algorithms.c?ds=sidebyside diff --git a/algorithms.c b/algorithms.c index a740a71..2113cc5 100644 --- a/algorithms.c +++ b/algorithms.c @@ -231,7 +231,7 @@ static PyMemberDef keyszset_pymembers[] = { }; static PyTypeObject keysz_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZ", /* @tp_name@ */ sizeof(keysz_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -279,7 +279,7 @@ static PyTypeObject keysz_pytype_skel = { }; static PyTypeObject keyszany_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZAny", /* @tp_name@ */ sizeof(keysz_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -327,7 +327,7 @@ static PyTypeObject keyszany_pytype_skel = { }; static PyTypeObject keyszrange_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZRange", /* @tp_name@ */ sizeof(keyszrange_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -376,7 +376,7 @@ sizes, and requires the key length to be a multiple of some value.", }; static PyTypeObject keyszset_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZSet", /* @tp_name@ */ sizeof(keyszset_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -460,19 +460,18 @@ end: PyObject *gccipher_pywrap(gccipher *cc) { - gccipher_pyobj *g = newtype(gccipher_pytype, 0); + gccipher_pyobj *g = newtype(gccipher_pytype, 0, cc->name); g->cc = cc; - g->ty.tp_name = (/*unconst*/ char *)cc->name; - g->ty.tp_basicsize = sizeof(gcipher_pyobj); - g->ty.tp_base = gcipher_pytype; + g->ty.type.tp_basicsize = sizeof(gcipher_pyobj); + g->ty.type.tp_base = gcipher_pytype; Py_INCREF(gcipher_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = 0; - g->ty.tp_new = gcipher_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gcipher_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -591,7 +590,7 @@ static PyMethodDef gcipher_pymethods[] = { }; static PyTypeObject gccipher_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCCipher", /* @tp_name@ */ sizeof(gccipher_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -639,7 +638,7 @@ static PyTypeObject gccipher_pytype_skel = { }; static PyTypeObject gcipher_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCipher", /* @tp_name@ */ sizeof(gcipher_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -705,19 +704,18 @@ end: PyObject *gchash_pywrap(gchash *ch) { - gchash_pyobj *g = newtype(gchash_pytype, 0); + gchash_pyobj *g = newtype(gchash_pytype, 0, ch->name); g->ch = ch; - g->ty.tp_name = (/*unconst*/ char *)ch->name; - g->ty.tp_basicsize = sizeof(ghash_pyobj); - g->ty.tp_base = ghash_pytype; + g->ty.type.tp_basicsize = sizeof(ghash_pyobj); + g->ty.type.tp_base = ghash_pytype; Py_INCREF(ghash_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = 0; - g->ty.tp_new = ghash_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = ghash_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -788,7 +786,7 @@ static PyMethodDef ghash_pymethods[] = { }; static PyTypeObject gchash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCHash", /* @tp_name@ */ sizeof(gchash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -836,7 +834,7 @@ static PyTypeObject gchash_pytype_skel = { }; static PyTypeObject ghash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GHash", /* @tp_name@ */ sizeof(ghash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -922,19 +920,18 @@ static PyObject *gmhash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) PyObject *gcmac_pywrap(gcmac *cm) { - gcmac_pyobj *g = newtype(gcmac_pytype, 0); + gcmac_pyobj *g = newtype(gcmac_pytype, 0, cm->name); g->cm = cm; - g->ty.tp_name = (/*unconst*/ char *)cm->name; - g->ty.tp_basicsize = sizeof(gmac_pyobj); - g->ty.tp_base = gmac_pytype; + g->ty.type.tp_basicsize = sizeof(gmac_pyobj); + g->ty.type.tp_base = gmac_pytype; Py_INCREF(gmac_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = 0; - g->ty.tp_new = gmac_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gmac_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -943,18 +940,18 @@ PyObject *gmac_pywrap(PyObject *cobj, gmac *m, unsigned f) gmac_pyobj *g; if (!cobj) cobj = gcmac_pywrap((/*unconst*/ gcmac *)GM_CLASS(m)); else Py_INCREF(cobj); - g = newtype((PyTypeObject *)cobj, 0); - g->nameobj = PyString_FromFormat("%s(keyed)", m->ops->c->name); - g->ty.tp_name = PyString_AS_STRING(g->nameobj); - g->ty.tp_base = gmhash_pytype; + g = newtype((PyTypeObject *)cobj, 0, 0); + g->ty.name = PyString_FromFormat("%s(keyed)", m->ops->c->name); + g->ty.type.tp_name = PyString_AS_STRING(g->ty.name); + g->ty.type.tp_base = gmhash_pytype; Py_INCREF(gmac_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = 0; - g->ty.tp_new = gmhash_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gmhash_pynew; + PyType_Ready(&g->ty.type); g->m = m; g->f = f; return ((PyObject *)g); @@ -965,7 +962,6 @@ static void gmac_pydealloc(PyObject *me) if (GMAC_F(me) & f_freeme) GM_DESTROY(GMAC_M(me)); Py_DECREF(me->ob_type); - Py_DECREF(GMAC_NAMEOBJ(me)); PyType_Type.tp_dealloc(me); } @@ -988,7 +984,7 @@ static PyGetSetDef gcmac_pygetset[] = { }; static PyTypeObject gcmac_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCMAC", /* @tp_name@ */ sizeof(gchash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1036,7 +1032,7 @@ static PyTypeObject gcmac_pytype_skel = { }; static PyTypeObject gmac_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GMAC", /* @tp_name@ */ sizeof(gmac_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1084,7 +1080,7 @@ static PyTypeObject gmac_pytype_skel = { }; static PyTypeObject gmhash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GMACHash", /* @tp_name@ */ sizeof(ghash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */