diff options
author | saurabhb17 | 2020-02-26 16:40:14 +0530 |
---|---|---|
committer | GitHub | 2020-02-26 16:40:14 +0530 |
commit | 02c614b4e64b68758f223391cb5357b3eec78cac (patch) | |
tree | ad18839d8b4eb1f13419d07878cc4ec4c9b70032 /scripting/python_scripting.h | |
parent | b77f5d9d8097c38159c6f60917995d6af13bbe1c (diff) | |
parent | 07a8c86216b6b1f694b136ec64c281d62941952e (diff) | |
download | KiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.tar.gz KiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.tar.bz2 KiCad-eSim-02c614b4e64b68758f223391cb5357b3eec78cac.zip |
Merge pull request #6 from saurabhb17/master
minor additions
Diffstat (limited to 'scripting/python_scripting.h')
-rw-r--r-- | scripting/python_scripting.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/scripting/python_scripting.h b/scripting/python_scripting.h new file mode 100644 index 0000000..8d0ae17 --- /dev/null +++ b/scripting/python_scripting.h @@ -0,0 +1,62 @@ +#ifndef __PYTHON_SCRIPTING_H +#define __PYTHON_SCRIPTING_H + +// undefs explained here: https://bugzilla.redhat.com/show_bug.cgi?id=427617 + +#ifdef _POSIX_C_SOURCE + #undef _POSIX_C_SOURCE +#endif +#ifdef _XOPEN_SOURCE + #undef _XOPEN_SOURCE +#endif + +#include <Python.h> +#ifndef NO_WXPYTHON_EXTENSION_HEADERS +#ifdef KICAD_SCRIPTING_WXPYTHON + #include <wx/wxPython/wxPython.h> +#endif +#endif + +#include <wx/string.h> +#include <wx/arrstr.h> + +/* Function pcbnewInitPythonScripting + * Initializes the Python engine inside pcbnew + */ + +bool pcbnewInitPythonScripting( const char * aUserPluginsPath ); +void pcbnewFinishPythonScripting(); + + +#ifdef KICAD_SCRIPTING_WXPYTHON + +void RedirectStdio(); +wxWindow* CreatePythonShellWindow( wxWindow* parent ); + +class PyLOCK +{ + wxPyBlock_t b; +public: + + // @todo, find out why these are wxPython specific. We need the GIL regardless. + // Should never assume python will only have one thread calling it. + PyLOCK() { b = wxPyBeginBlockThreads(); } + ~PyLOCK() { wxPyEndBlockThreads( b ); } +}; + + +#else +class PyLOCK +{ + PyGILState_STATE gil_state; +public: + PyLOCK() { gil_state = PyGILState_Ensure(); } + ~PyLOCK() { PyGILState_Release( gil_state ); } +}; + +#endif + +wxArrayString PyArrayStringToWx( PyObject* arr ); +wxString PyErrStringWithTraceback(); + +#endif // __PYTHON_SCRIPTING_H |