diff --git a/lib/base/scriptfunction-script.cpp b/lib/base/scriptfunction-script.cpp index 1ba64d666..02e501ed9 100644 --- a/lib/base/scriptfunction-script.cpp +++ b/lib/base/scriptfunction-script.cpp @@ -20,6 +20,7 @@ #include "base/scriptfunction.hpp" #include "base/scriptfunctionwrapper.hpp" #include "base/scriptframe.hpp" +#include "base/objectlock.hpp" #include "base/exception.hpp" using namespace icinga; @@ -37,6 +38,23 @@ static Value ScriptFunctionCall(const std::vector& args) return self->Invoke(uargs); } +static Value ScriptFunctionCallV(const Value& thisArg, const Array::Ptr& args) +{ + ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); + ScriptFunction::Ptr self = static_cast(vframe->Self); + + ScriptFrame uframe(thisArg); + std::vector uargs; + + { + ObjectLock olock(args); + uargs = std::vector(args->Begin(), args->End()); + } + + return self->Invoke(uargs); +} + + Object::Ptr ScriptFunction::GetPrototype(void) { static Dictionary::Ptr prototype; @@ -44,6 +62,7 @@ Object::Ptr ScriptFunction::GetPrototype(void) if (!prototype) { prototype = new Dictionary(); prototype->Set("call", new ScriptFunction(WrapScriptFunction(ScriptFunctionCall))); + prototype->Set("callv", new ScriptFunction(WrapScriptFunction(ScriptFunctionCallV))); } return prototype;