2014-11-22 12:21:28 +01:00
|
|
|
/******************************************************************************
|
2014-12-11 21:12:34 +01:00
|
|
|
* Icinga 2 *
|
2018-10-18 09:27:04 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
2014-12-11 21:12:34 +01:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
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 */
|