reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
pythontarget.h
Go to the documentation of this file.
1
43#ifndef PYTHON_TARGET_H
44#define PYTHON_TARGET_H
45
46#define PY_SSIZE_T_CLEAN
47
48#include <Python.h>
49#include <structmember.h>
50#include <limits.h>
51#include "python_tag.h"
52#include "python_port.h"
53#include "python_action.h"
54
55#ifdef _MSC_VER
56#ifndef PATH_MAX
57#define PATH_MAX MAX_PATH
58#endif
59#endif
60
61// MODULE_NAME is expected to be defined in the main file of the generated code
62#ifndef MODULE_NAME
63#error "MODULE_NAME is undefined"
64#endif
65
66#define CONCAT(x, y) x##y
67#define GEN_NAME(x, y) CONCAT(x, y)
68#define STRINGIFY(X) #X
69#define TOSTRING(x) STRINGIFY(x)
70
72extern PyObject* globalPythonModule;
73extern PyObject* globalPythonModuleDict;
74extern PyObject* global_pickler;
76
79
88PyObject* py_schedule(PyObject* self, PyObject* args);
89
95PyObject* py_schedule_copy(PyObject* self, PyObject* args);
96
99
103PyObject* py_request_stop(PyObject* self, PyObject* args);
104
111PyObject* py_source_directory(PyObject* self, PyObject* args);
112
119PyObject* py_package_directory(PyObject* self, PyObject* args);
120
123PyObject* py_main(PyObject* self, PyObject* args);
124
127
143PyObject* convert_C_port_to_py(void* port, int width);
144
166PyObject* convert_C_action_to_py(void* action);
167
186PyObject* get_python_function(string module, string class, int instance_id, string func);
187
193PyObject* load_serializer(string package_name);
194
201PyObject* custom_serialize(PyObject* obj, PyObject* custom_serializer);
202
209PyObject* custom_deserialize(PyObject* serialized_pyobject, PyObject* custom_serializer);
210
211/*
212 * The Python runtime will call this function to initialize the module.
213 * The name of this function is dynamically generated to follow
214 * the requirement of PyInit_MODULE_NAME. Since the MODULE_NAME is not
215 * known prior to compile time, the GEN_NAME macro is used.
216 * The generated function will have the name PyInit_MODULE_NAME.
217 * For example for a module named LinguaFrancaFoo, this function
218 * will be called PyInit_LinguaFrancaFoo
219 */
220PyMODINIT_FUNC GEN_NAME(PyInit_, MODULE_NAME)(void);
221
222#endif // PYTHON_TARGET_H
PyObject * convert_C_action_to_py(void *action)
Definition pythontarget.c:510
PyObject * py_request_stop(PyObject *self, PyObject *args)
Definition pythontarget.c:158
#define GEN_NAME(x, y)
Definition pythontarget.h:67
PyObject * py_source_directory(PyObject *self, PyObject *args)
Return the source directory path (where the main .lf file is) as a string.
Definition pythontarget.c:165
PyObject * globalPythonModuleDict
Definition pythontarget.c:55
PyObject * get_python_function(string module, string class, int instance_id, string func)
Definition pythontarget.c:569
environment_t * top_level_environment
Definition pythontarget.c:60
PyObject * global_pickler
Definition pythontarget.c:58
PyObject * py_schedule_copy(PyObject *self, PyObject *args)
Definition pythontarget.c:120
PyObject * load_serializer(string package_name)
Definition pythontarget.c:699
PyObject * convert_C_port_to_py(void *port, int width)
Definition pythontarget.c:446
PyObject * globalPythonModule
Definition pythontarget.c:51
PyObject * custom_deserialize(PyObject *serialized_pyobject, PyObject *custom_serializer)
Definition pythontarget.c:739
PyObject * py_main(PyObject *self, PyObject *args)
Definition pythontarget.c:279
PyObject * py_schedule(PyObject *self, PyObject *args)
Definition pythontarget.c:77
PyObject * custom_serialize(PyObject *obj, PyObject *custom_serializer)
Definition pythontarget.c:724
PyObject * py_package_directory(PyObject *self, PyObject *args)
Return the root project directory path as a string.
Definition pythontarget.c:175
Execution environment. This struct contains information about the execution environment....
Definition environment.h:49