RETURN_ME;
}
-static PyObject *ghmeth_done(PyObject *me, PyObject *arg)
-{
- ghash *g;
- PyObject *rc;
- if (!PyArg_ParseTuple(arg, ":done")) return (0);
- g = GH_COPY(GHASH_H(me));
- rc = bytestring_pywrap(0, g->ops->c->hashsz);
- GH_DONE(g, PyString_AS_STRING(rc));
- GH_DESTROY(g);
- return (rc);
-}
-
-static PyGetSetDef gchash_pygetset[] = {
-#define GETSETNAME(op, name) gch##op##_##name
- GET (bufsz, "CH.bufsz -> hash buffer size, or zero")
- GET (hashsz, "CH.blksz -> hash output size")
- GET (name, "CH.name -> name of this kind of hash")
-#undef GETSETNAME
- { 0 }
-};
-
#define GHMETH_HASHU_(n, W, w) \
static PyObject *ghmeth_hashu##w(PyObject *me, PyObject *arg) \
{ \
RETURN_ME;
}
+static PyObject *ghmeth_done(PyObject *me, PyObject *arg)
+{
+ ghash *g;
+ PyObject *rc;
+ if (!PyArg_ParseTuple(arg, ":done")) return (0);
+ g = GH_COPY(GHASH_H(me));
+ rc = bytestring_pywrap(0, g->ops->c->hashsz);
+ GH_DONE(g, PyString_AS_STRING(rc));
+ GH_DESTROY(g);
+ return (rc);
+}
+
+static PyGetSetDef gchash_pygetset[] = {
+#define GETSETNAME(op, name) gch##op##_##name
+ GET (bufsz, "CH.bufsz -> hash buffer size, or zero")
+ GET (hashsz, "CH.hashsz -> hash output size")
+ GET (name, "CH.name -> name of this kind of hash")
+#undef GETSETNAME
+ { 0 }
+};
+
static PyMethodDef ghash_pymethods[] = {
#define METHNAME(name) ghmeth_##name
METH (hash, "H.hash(M)")
#define METHU_(n, W, w) METH(hashu##w, "H.hashu" #w "(WORD)")
DOUINTCONV(METHU_)
+#undef METHU_
#define METHBUF_(n, W, w) METH(hashbuf##w, "H.hashbuf" #w "(BYTES)")
DOUINTCONV(METHBUF_)
+#undef METHBUF_
METH (hashstrz, "H.hashstrz(STRING)")
METH (done, "H.done() -> HASH")
#undef METHNAME
if (!cobj) cobj = gcmac_pywrap((/*unconst*/ gcmac *)GM_CLASS(m));
else Py_INCREF(cobj);
g = newtype((PyTypeObject *)cobj, 0, 0);
+ g->ty.ht_type.tp_basicsize = sizeof(ghash_pyobj);
g->ty.ht_name = PyString_FromFormat("%s(keyed)", m->ops->c->name);
g->ty.ht_type.tp_name = PyString_AS_STRING(g->ty.ht_name);
g->ty.ht_type.tp_base = gmhash_pytype;