Showing the changes to libraries/script-engine/src/ScriptContext.cpp (1 of 63 files). Show all
Unified · Split
| @@ -0,0 +1,23 @@ | ||
| 1 | +// | |
| 2 | +// ScriptContext.h | |
| 3 | +// libraries/script-engine/src | |
| 4 | +// | |
| 5 | +// Created by Heather Anderson on 12/5/21. | |
| 6 | +// Copyright 2021 Vircadia contributors. | |
| 7 | +// | |
| 8 | +// Distributed under the Apache License, Version 2.0. | |
| 9 | +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | |
| 10 | +// | |
| 11 | + | |
| 12 | +#include "ScriptContext.h" | |
| 13 | + | |
| 14 | +#include "Scriptable.h" | |
| 15 | + | |
| 16 | +ScriptContextGuard::ScriptContextGuard(ScriptContext* context) { | |
| 17 | + _oldContext = Scriptable::context(); | |
| 18 | + Scriptable::setContext(context); | |
| 19 | +} | |
| 20 | + | |
| 21 | +ScriptContextGuard::~ScriptContextGuard() { | |
| 22 | + Scriptable::setContext(_oldContext); | |
| 23 | +} | |