2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-11-22 06:21:28 -05:00
|
|
|
|
2014-12-15 10:09:17 -05:00
|
|
|
#ifndef SCRIPTFRAME_H
|
|
|
|
|
#define SCRIPTFRAME_H
|
2014-11-22 06:21:28 -05:00
|
|
|
|
2016-08-18 09:45:14 -04:00
|
|
|
#include "base/i2-base.hpp"
|
2014-11-22 06:21:28 -05:00
|
|
|
#include "base/dictionary.hpp"
|
2016-08-12 05:25:36 -04:00
|
|
|
#include "base/array.hpp"
|
2014-12-11 15:12:34 -05:00
|
|
|
#include <boost/thread/tss.hpp>
|
2015-03-29 16:26:07 -04:00
|
|
|
#include <stack>
|
2014-11-22 06:21:28 -05:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
2017-12-31 01:22:16 -05:00
|
|
|
struct ScriptFrame
|
2014-11-22 06:21:28 -05:00
|
|
|
{
|
|
|
|
|
Dictionary::Ptr Locals;
|
2014-12-12 09:19:23 -05:00
|
|
|
Value Self;
|
2015-04-16 02:47:26 -04:00
|
|
|
bool Sandboxed;
|
2016-03-23 03:40:32 -04:00
|
|
|
int Depth;
|
2014-11-22 06:21:28 -05:00
|
|
|
|
2018-01-03 04:19:24 -05:00
|
|
|
ScriptFrame(bool allocLocals);
|
2018-01-04 02:54:18 -05:00
|
|
|
ScriptFrame(bool allocLocals, Value self);
|
2018-01-03 22:25:35 -05:00
|
|
|
~ScriptFrame();
|
2014-11-22 06:21:28 -05:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
void IncreaseStackDepth();
|
|
|
|
|
void DecreaseStackDepth();
|
2016-03-23 03:40:32 -04:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
static ScriptFrame *GetCurrentFrame();
|
2014-12-11 15:12:34 -05:00
|
|
|
|
|
|
|
|
private:
|
2015-03-29 16:26:07 -04:00
|
|
|
static boost::thread_specific_ptr<std::stack<ScriptFrame *> > m_ScriptFrames;
|
2014-12-11 15:12:34 -05:00
|
|
|
|
2017-12-20 07:22:38 -05:00
|
|
|
static void PushFrame(ScriptFrame *frame);
|
2018-01-03 22:25:35 -05:00
|
|
|
static ScriptFrame *PopFrame();
|
2016-08-12 05:42:59 -04:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
void InitializeFrame();
|
2014-11-22 06:21:28 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-12 09:33:02 -05:00
|
|
|
#endif /* SCRIPTFRAME_H */
|