Python GC.athlete()

Basic proof of concept for CPP binding using SIP but with
our own type conversion (to avoid overhead of SIP lib/deploy).
Its far from perfect but will serve as a starting point.

.. needed to fixup type conversion in goldencheetah.sip to
   convert returning QString as PyUnicode

.. needed to fixup passing context when multi-threaded

.. needed to fixup Bindings.h/cpp to offer new API
This commit is contained in:
Mark Liversedge
2017-12-04 15:17:19 +00:00
parent 6d9731e1ed
commit db3d119f7d
13 changed files with 206 additions and 29 deletions

View File

@@ -103,7 +103,7 @@ PythonEmbed::PythonEmbed(const bool verbose, const bool interactive) : verbose(v
}
// run on called thread
void PythonEmbed::runline(QString line)
void PythonEmbed::runline(Context *context, QString line)
{
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
@@ -116,6 +116,9 @@ void PythonEmbed::runline(QString line)
threadid = PyLong_AsLong(ident);
Py_DECREF(ident);
// add to the thread/context map
contexts.insert(threadid, context);
// run and generate errors etc
messages.clear();
PyRun_SimpleString(line.toStdString().c_str());