aboutsummaryrefslogtreecommitdiff
path: root/python/nissy_module.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-12 19:32:20 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-12 19:32:20 +0200
commit17eda4dedb0d70c5a82edf77e9b3aaa1af5bfb19 (patch)
treee6b7257708cadba242006202345f9b7caf094594 /python/nissy_module.c
parentef087c3849cfbe58f4f77e09367d6fbf152e5498 (diff)
downloadnissy-core-17eda4dedb0d70c5a82edf77e9b3aaa1af5bfb19.tar.gz
nissy-core-17eda4dedb0d70c5a82edf77e9b3aaa1af5bfb19.zip
Initial support for Python
Diffstat (limited to '')
-rw-r--r--python/nissy_module.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/python/nissy_module.c b/python/nissy_module.c
new file mode 100644
index 0000000..b627300
--- /dev/null
+++ b/python/nissy_module.c
@@ -0,0 +1,34 @@
1#define PY_SSIZE_T_CLEAN
2#include <Python.h>
3
4#include "../src/nissy.h"
5
6/* TODO from here */
7
8static PyObject *compose(PyObject *self, PyObject *args) {
9 const char *cube, *permutation;
10 char result[NISSY_SIZE_B32];
11
12 if (!PyArg_ParseTuple(args, "ss", &cube, &permutation))
13 return NULL;
14
15 nissy_compose(cube, permutation, result);
16 return PyUnicode_FromString(result);
17}
18
19static PyMethodDef NissyMethods[] = {
20 { "compose", compose, METH_VARARGS, "Compose two cubes." },
21 { NULL, NULL, 0, NULL }
22};
23
24static struct PyModuleDef nissy_python_module = {
25 PyModuleDef_HEAD_INIT,
26 "nissy",
27 NULL,
28 -1,
29 NissyMethods
30};
31
32PyMODINIT_FUNC PyInit_nissy_python_module(void) {
33 return PyModule_Create(&nissy_python_module);
34}

Generated with cgit - Back to sebastiano.tronto.net