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