2018-05-23 11:23:49 +00:00
|
|
|
#include <Python.h>
|
2018-06-14 18:19:08 +00:00
|
|
|
#include <emscripten.h>
|
2018-05-23 11:23:49 +00:00
|
|
|
|
|
|
|
#include "hiwire.h"
|
|
|
|
#include "js2python.h"
|
|
|
|
#include "jsimport.h"
|
|
|
|
#include "jsproxy.h"
|
|
|
|
#include "pyimport.h"
|
|
|
|
#include "pyproxy.h"
|
|
|
|
#include "python2js.h"
|
|
|
|
#include "runpython.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
TODO: This is a workaround for a weird emscripten compiler bug. The
|
|
|
|
matplotlib/_qhull.so extension makes function pointer calls with these
|
|
|
|
signatures, but since nothing with that signature exists in the MAIN_MODULE,
|
|
|
|
it can't link the SIDE_MODULE. Creating these dummy functions here seems to
|
|
|
|
work around the problem.
|
|
|
|
*/
|
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
void
|
|
|
|
__foo(double x)
|
|
|
|
{}
|
2018-05-23 11:23:49 +00:00
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
void
|
|
|
|
__foo2(double x, double y)
|
|
|
|
{}
|
2018-05-23 11:23:49 +00:00
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
void
|
|
|
|
__foo3(double x, double y, double z)
|
|
|
|
{}
|
2018-05-23 11:23:49 +00:00
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
void
|
|
|
|
__foo4(int a, double b, int c, int d, int e)
|
|
|
|
{}
|
2018-05-23 11:23:49 +00:00
|
|
|
|
|
|
|
/* END WORKAROUND */
|
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
2018-05-23 11:23:49 +00:00
|
|
|
hiwire_setup();
|
|
|
|
|
2018-06-13 18:06:58 +00:00
|
|
|
setenv("PYTHONDONTWRITEBYTECODE", "1", 0);
|
2018-05-23 11:23:49 +00:00
|
|
|
setenv("PYTHONHOME", "/", 0);
|
|
|
|
|
|
|
|
Py_InitializeEx(0);
|
|
|
|
|
2018-06-14 18:19:08 +00:00
|
|
|
if (js2python_init() || JsImport_init() || JsProxy_init() ||
|
|
|
|
pyimport_init() || pyproxy_init() || python2js_init() ||
|
2018-07-17 17:54:42 +00:00
|
|
|
runpython_init_js() || runpython_init_py()) {
|
2018-05-23 11:23:49 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Python initialization complete\n");
|
|
|
|
|
|
|
|
emscripten_exit_with_live_runtime();
|
|
|
|
return 0;
|
|
|
|
}
|