mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-30 04:23:23 +08:00
33 lines
463 B
C++
33 lines
463 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;
|
|
};
|
|
|
|
} |