mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00

[0.3.x] added : dbgCommand optional parameter suppressOutput git-svn-id: https://pykd.svn.codeplex.com/svn@89531 9b283d60-5439-405e-af05-b73fd8c4d996
54 lines
774 B
C++
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;
|
|
|
|
|
|
};
|
|
|
|
} |