Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/python/python-wasm/src/extension/hellozigmodule.c
1067 views
1
#include <Python.h>
2
#include <unistd.h>
3
4
extern PyObject *hello(PyObject *self, PyObject *args);
5
extern PyObject *add389(PyObject *self, PyObject *args);
6
extern PyObject *gcd_impl(PyObject *self, PyObject *args);
7
8
static PyMethodDef module_methods[] = {
9
{"hello", _PyCFunction_CAST(hello), METH_VARARGS, "Say hello to you."},
10
{"add389", _PyCFunction_CAST(add389), METH_VARARGS, "Add 389 to a C long."},
11
{"gcd", _PyCFunction_CAST(gcd_impl), METH_VARARGS, "GCD of two C longs"},
12
{NULL, NULL, 0, NULL}};
13
14
static int module_clear(PyObject *module) { return 0; }
15
16
static void module_free(void *module) { module_clear((PyObject *)module); }
17
18
struct PyModuleDef _hellomodule = {
19
.m_name = "hellozig",
20
.m_methods = module_methods,
21
.m_clear = module_clear,
22
.m_free = module_free,
23
};
24
25
PyMODINIT_FUNC PyInit_hellozig(void) { return PyModuleDef_Init(&_hellomodule); }
26