1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-31 20:45:32 +00:00

Merge pull request #2752 from Assumeru/parsing-errors

Reset errorhandler context
This commit is contained in:
Bret Curtis 2020-04-05 10:03:34 +02:00 committed by GitHub
commit 328c3617b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

View file

@ -171,7 +171,7 @@ namespace MWScript
{
Compiler::Locals locals;
mErrorHandler.setContext(name2 + "[local variables]");
const Compiler::ContextOverride override(mErrorHandler, name2 + "[local variables]");
std::istringstream stream (script->mScriptText);
Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals);

View file

@ -62,4 +62,14 @@ namespace Compiler
}
StreamErrorHandler::StreamErrorHandler() {}
ContextOverride::ContextOverride(StreamErrorHandler& handler, const std::string& context) : mHandler(handler), mContext(handler.mContext)
{
mHandler.setContext(context);
}
ContextOverride::~ContextOverride()
{
mHandler.setContext(mContext);
}
}

View file

@ -7,12 +7,14 @@
namespace Compiler
{
class ContextOverride;
/// \brief Error handler implementation: Write errors into logging stream
class StreamErrorHandler : public ErrorHandler
{
std::string mContext;
friend class ContextOverride;
// not implemented
StreamErrorHandler (const StreamErrorHandler&);
@ -33,6 +35,19 @@ namespace Compiler
StreamErrorHandler ();
///< constructor
};
class ContextOverride
{
StreamErrorHandler& mHandler;
const std::string mContext;
public:
ContextOverride (StreamErrorHandler& handler, const std::string& context);
ContextOverride (const ContextOverride&) = delete;
ContextOverride& operator= (const ContextOverride&) = delete;
~ContextOverride();
};
}
#endif