diff --git a/plugins/python-renderer/include/python-renderer/gds-render-module.h b/plugins/python-renderer/include/python-renderer/gds-render-module.h index efd8707..dd37a5b 100644 --- a/plugins/python-renderer/include/python-renderer/gds-render-module.h +++ b/plugins/python-renderer/include/python-renderer/gds-render-module.h @@ -31,7 +31,13 @@ * @{ */ +#include +/** + * @brief Set up the gds_render python module + * @return New module reference + */ +PyObject *init_gds_render_module(); /** @} */ diff --git a/plugins/python-renderer/src/gds-render-module.c b/plugins/python-renderer/src/gds-render-module.c index 4749bc4..9f1cf33 100644 --- a/plugins/python-renderer/src/gds-render-module.c +++ b/plugins/python-renderer/src/gds-render-module.c @@ -24,3 +24,30 @@ */ #include + +static PyObject *test(PyObject *self, PyObject *args) +{ + if(!PyArg_ParseTuple(args, ":numargs")) + return NULL; + + return PyLong_FromLong(20UL); +} + +static PyMethodDef gds_render_methods[] = { + {"get_number", test, METH_VARARGS, + "Return the number of arguments received by the process."}, + {NULL, NULL, 0, NULL} +}; + +static PyModuleDef gds_render_module = { + PyModuleDef_HEAD_INIT, "gds_render", NULL, -1, gds_render_methods, + NULL, NULL, NULL, NULL +}; + +PyObject *init_gds_render_module(void) +{ + PyObject *this_module; + + this_module = PyModule_Create(&gds_render_module); + return this_module; +} diff --git a/plugins/python-renderer/src/plugin-main.c b/plugins/python-renderer/src/plugin-main.c index 5dc7bf1..8c6afcd 100644 --- a/plugins/python-renderer/src/plugin-main.c +++ b/plugins/python-renderer/src/plugin-main.c @@ -88,12 +88,20 @@ int FUNC_DECL(EXTERNAL_LIBRARY_INIT_FUNCTION)(const char *params, const char *ve PyObject *p_name; PyObject *p_sys_path; PyObject *p_cwd_string; + PyObject *gds_render_module; char cwd[256]; if (!params || !version) return -1000; printf("Init with params: %s\ngds-render version: %s\n", params, version); + + ret = PyImport_AppendInittab("gds_render", &init_gds_render_module); + if (ret) { + fprintf(stderr, "Registration of gds_render python module failed\n"); + goto return_value; + } + Py_Initialize(); if (!getcwd(cwd, sizeof(cwd))) {