summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/common/fnv1a.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/common/fnv1a.c')
-rw-r--r--plugins/pychrysalide/common/fnv1a.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/plugins/pychrysalide/common/fnv1a.c b/plugins/pychrysalide/common/fnv1a.c
index c24eb6e..381af78 100644
--- a/plugins/pychrysalide/common/fnv1a.c
+++ b/plugins/pychrysalide/common/fnv1a.c
@@ -36,6 +36,14 @@
+#define FNV1A_DOC \
+ "Python version for Chrysalide of the Fowler-Noll-Vo" \
+ " hash function.\n" \
+ "\n" \
+ "There is no constructor for this class: its methods" \
+ " are static methods only."
+
+
/* Détermine l'empreinte FNV1a d'une chaîne de caractères. */
static PyObject *py_fnv1a_hash(PyObject *, PyObject *);
@@ -61,6 +69,13 @@ static PyObject *py_fnv1a_hash(PyObject *self, PyObject *args)
int ret; /* Bilan de lecture des args. */
fnv64_t value; /* Empreinte calculée */
+#define FNV1A_HASH_METHOD PYTHON_METHOD_DEF \
+( \
+ hash, "str, /", \
+ METH_VARARGS | METH_STATIC, py_fnv1a, \
+ "Compute the FNV-1a hash from a given string." \
+)
+
ret = PyArg_ParseTuple(args, "s", &str);
if (!ret) return NULL;
@@ -88,27 +103,24 @@ static PyObject *py_fnv1a_hash(PyObject *self, PyObject *args)
PyTypeObject *get_python_fnv1a_type(void)
{
static PyMethodDef py_fnv1a_methods[] = {
-
- { "hash", py_fnv1a_hash,
- METH_VARARGS | METH_STATIC,
- "hash(str, /)\n--\n\nCompute the FNV-1a hash from a given string."
- },
+ FNV1A_HASH_METHOD,
{ NULL }
-
};
static PyTypeObject py_fnv1a_type = {
PyVarObject_HEAD_INIT(NULL, 0)
- .tp_name = "pychrysalide.core.fnv1a",
- .tp_basicsize = sizeof(PyObject),
+ .tp_name = "pychrysalide.common.fnv1a",
+ .tp_basicsize = sizeof(PyObject),
+
+ .tp_flags = Py_TPFLAGS_DEFAULT,
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_IS_ABSTRACT,
+ .tp_doc = FNV1A_DOC,
- .tp_doc = "Python version for Chrysalide of the Fowler-Noll-Vo hash function.",
+ .tp_methods = py_fnv1a_methods,
- .tp_methods = py_fnv1a_methods
+ .tp_new = no_python_constructor_allowed,
};
@@ -138,8 +150,6 @@ bool ensure_python_fnv1a_is_registered(void)
if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
{
- //type->tp_new = PyType_GenericNew;
-
if (PyType_Ready(type) != 0)
return false;