pykd/pykd/pythreadstate.h
SND\kernelnet_cp e4c8bd3ff9 [0.3.x] added : onDebugOutput callback
[0.3.x] added : dbgCommand optional parameter suppressOutput 

git-svn-id: https://pykd.svn.codeplex.com/svn@89531 9b283d60-5439-405e-af05-b73fd8c4d996
2017-11-03 15:24:07 +04:00

54 lines
774 B
C++

#pragma once
#include <Python.h>
namespace pykd {
class AutoRestorePyState
{
public:
AutoRestorePyState()
{
m_state = PyEval_SaveThread();
}
explicit AutoRestorePyState(PyThreadState **state)
{
*state = PyEval_SaveThread();
m_state = *state;
}
~AutoRestorePyState()
{
PyEval_RestoreThread( m_state );
}
private:
PyThreadState* m_state;
};
class AutoSavePythonState
{
public:
explicit AutoSavePythonState(PyThreadState **state) {
PyEval_RestoreThread(*state);
m_state = state;
}
~AutoSavePythonState() {
*m_state = PyEval_SaveThread();
}
private:
PyThreadState** m_state;
};
}