From 530caac39b325c67c7bb8a088604a6c63bbf6c05 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 4 Jul 2010 09:59:29 +0200 Subject: [PATCH] merged CompilerScriptContext into base class --- CMakeLists.txt | 1 - apps/openmw/engine.cpp | 4 ++-- apps/openmw/mwscript/compilercontext.hpp | 22 +++++++++++++++++++ .../openmw/mwscript/compilercontextscript.hpp | 22 ------------------- 4 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 apps/openmw/mwscript/compilercontextscript.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 815a3913eb..03f6bea033 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ set(GAMESCRIPT_HEADER apps/openmw/mwscript/locals.hpp apps/openmw/mwscript/scriptmanager.hpp apps/openmw/mwscript/compilercontext.hpp - apps/openmw/mwscript/compilercontextscript.hpp apps/openmw/mwscript/interpretercontext.hpp apps/openmw/mwscript/cellextensions.hpp apps/openmw/mwscript/extensions.hpp) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index f3a68b8c50..17eaaa49b0 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -10,7 +10,7 @@ #include "mwinput/inputmanager.hpp" #include "mwscript/scriptmanager.hpp" -#include "mwscript/compilercontextscript.hpp" +#include "mwscript/compilercontext.hpp" #include "mwscript/interpretercontext.hpp" #include "mwscript/extensions.hpp" @@ -173,7 +173,7 @@ void OMW::Engine::go() MWScript::registerExtensions (mExtensions); - mScriptContext = new MWScript::CompilerContextScript; + mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext->setExtensions (&mExtensions); mScriptManager = new MWScript::ScriptManager (mWorld->getStore(), mVerboseScripts, diff --git a/apps/openmw/mwscript/compilercontext.hpp b/apps/openmw/mwscript/compilercontext.hpp index ef6900ea10..4219bc3b85 100644 --- a/apps/openmw/mwscript/compilercontext.hpp +++ b/apps/openmw/mwscript/compilercontext.hpp @@ -7,6 +7,28 @@ namespace MWScript { class CompilerContext : public Compiler::Context { + public: + + enum Type + { + Type_Full, // global, local, targetted + Type_Dialgoue, + Type_Console + }; + + private: + + Type mType; + + public: + + CompilerContext (Type type) : mType (type) {} + + // Is the compiler allowed to declare local variables? + virtual bool canDeclareLocals() const + { + return mType==Type_Full; + } }; } diff --git a/apps/openmw/mwscript/compilercontextscript.hpp b/apps/openmw/mwscript/compilercontextscript.hpp deleted file mode 100644 index 28e5bff682..0000000000 --- a/apps/openmw/mwscript/compilercontextscript.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef GAME_SCRIPT_COMPILERCONTEXTSCRIPT_H -#define GAME_SCRIPT_COMPILERCONTEXTSCRIPT_H - -#include "compilercontext.hpp" - -namespace MWScript -{ - /// Context for local scripts, global scripts and targetted scripts - - class CompilerContextScript : public CompilerContext - { - public: - - // Is the compiler allowed to declare local variables? - virtual bool canDeclareLocals() const - { - return true; - } - }; -} - -#endif