aboutsummaryrefslogtreecommitdiff
path: root/python/nissy_module.c
blob: b627300746b3a1177bc963f7a98826ea1b846043 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#define PY_SSIZE_T_CLEAN
#include <Python.h>

#include "../src/nissy.h"

/* TODO from here */

static PyObject *compose(PyObject *self, PyObject *args) {
	const char *cube, *permutation;
	char result[NISSY_SIZE_B32];

	if (!PyArg_ParseTuple(args, "ss", &cube, &permutation))
		return NULL;

	nissy_compose(cube, permutation, result);
	return PyUnicode_FromString(result);
}

static PyMethodDef NissyMethods[] = {
	{ "compose", compose, METH_VARARGS, "Compose two cubes." },
	{ NULL, NULL, 0, NULL }
};

static struct PyModuleDef nissy_python_module = {
	PyModuleDef_HEAD_INIT,
	"nissy",
	NULL,
	-1,
	NissyMethods
};

PyMODINIT_FUNC PyInit_nissy_python_module(void) {
	return PyModule_Create(&nissy_python_module);
}

Generated with cgit - Back to sebastiano.tronto.net