mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
- updated ERM library to c++11
This commit is contained in:
@@ -464,8 +464,8 @@ void ERMInterpreter::scanScripts()
|
|||||||
ERMInterpreter::ERMInterpreter()
|
ERMInterpreter::ERMInterpreter()
|
||||||
{
|
{
|
||||||
erm = this;
|
erm = this;
|
||||||
curFunc = NULL;
|
curFunc = nullptr;
|
||||||
curTrigger = NULL;
|
curTrigger = nullptr;
|
||||||
globalEnv = new Environment();
|
globalEnv = new Environment();
|
||||||
topDyn = globalEnv;
|
topDyn = globalEnv;
|
||||||
}
|
}
|
||||||
@@ -496,7 +496,7 @@ void ERMInterpreter::executeTrigger( VERMInterpreter::Trigger & trig, int funNum
|
|||||||
executeLine(lp);
|
executeLine(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
curFunc = NULL;
|
curFunc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ERMInterpreter::isATrigger( const ERM::TLine & line )
|
bool ERMInterpreter::isATrigger( const ERM::TLine & line )
|
||||||
@@ -686,8 +686,8 @@ struct HE_BPerformer : StandardBodyOptionItemVisitor<HEPerformer>
|
|||||||
{}
|
{}
|
||||||
using StandardBodyOptionItemVisitor<HEPerformer>::operator();
|
using StandardBodyOptionItemVisitor<HEPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE;
|
void operator()(TIexp const& cmp) const override;
|
||||||
void operator()(TVarpExp const& cmp) const OVERRIDE;
|
void operator()(TVarpExp const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int opcode>
|
template<int opcode>
|
||||||
@@ -703,8 +703,8 @@ struct HE_CPerformer : StandardBodyOptionItemVisitor<HEPerformer>
|
|||||||
{}
|
{}
|
||||||
using StandardBodyOptionItemVisitor<HEPerformer>::operator();
|
using StandardBodyOptionItemVisitor<HEPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE;
|
void operator()(TIexp const& cmp) const override;
|
||||||
void operator()(TVarpExp const& cmp) const OVERRIDE;
|
void operator()(TVarpExp const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<int opcode>
|
template<int opcode>
|
||||||
@@ -719,7 +719,7 @@ struct HEPerformer : StandardReceiverVisitor<const CGHeroInstance *>
|
|||||||
{}
|
{}
|
||||||
using StandardReceiverVisitor<const CGHeroInstance *>::operator();
|
using StandardReceiverVisitor<const CGHeroInstance *>::operator();
|
||||||
|
|
||||||
void operator()(TNormalBodyOption const& trig) const OVERRIDE
|
void operator()(TNormalBodyOption const& trig) const override
|
||||||
{
|
{
|
||||||
switch(trig.optionCode)
|
switch(trig.optionCode)
|
||||||
{
|
{
|
||||||
@@ -780,7 +780,7 @@ struct IF_MPerformer : StandardBodyOptionItemVisitor<IFPerformer>
|
|||||||
explicit IF_MPerformer(IFPerformer & _owner) : StandardBodyOptionItemVisitor<IFPerformer>(_owner){}
|
explicit IF_MPerformer(IFPerformer & _owner) : StandardBodyOptionItemVisitor<IFPerformer>(_owner){}
|
||||||
using StandardBodyOptionItemVisitor<IFPerformer>::operator();
|
using StandardBodyOptionItemVisitor<IFPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TStringConstant const& cmp) const OVERRIDE;
|
void operator()(TStringConstant const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -802,7 +802,7 @@ struct StringFormatter
|
|||||||
{
|
{
|
||||||
int pos;
|
int pos;
|
||||||
int tokenLength;
|
int tokenLength;
|
||||||
int percentPos;
|
size_t percentPos;
|
||||||
int charsToReplace;
|
int charsToReplace;
|
||||||
std::string &msg;
|
std::string &msg;
|
||||||
|
|
||||||
@@ -821,7 +821,7 @@ struct StringFormatter
|
|||||||
{
|
{
|
||||||
int toAdd = 0;
|
int toAdd = 0;
|
||||||
int numStart = percentPos + 2;
|
int numStart = percentPos + 2;
|
||||||
int numEnd = msg.find_first_not_of("1234567890", numStart);
|
size_t numEnd = msg.find_first_not_of("1234567890", numStart);
|
||||||
|
|
||||||
if(numEnd == std::string::npos)
|
if(numEnd == std::string::npos)
|
||||||
toAdd = msg.size() - numStart;
|
toAdd = msg.size() - numStart;
|
||||||
@@ -887,7 +887,7 @@ struct IFPerformer : StandardReceiverVisitor<TUnusedType>
|
|||||||
using StandardReceiverVisitor<TUnusedType>::operator();
|
using StandardReceiverVisitor<TUnusedType>::operator();
|
||||||
|
|
||||||
|
|
||||||
void operator()(TNormalBodyOption const& trig) const OVERRIDE
|
void operator()(TNormalBodyOption const& trig) const override
|
||||||
{
|
{
|
||||||
std::string message; //to be shown
|
std::string message; //to be shown
|
||||||
switch(trig.optionCode)
|
switch(trig.optionCode)
|
||||||
@@ -932,8 +932,8 @@ struct MA_PPerformer : StandardBodyOptionItemVisitor<MAPerformer>
|
|||||||
explicit MA_PPerformer(MAPerformer & _owner);
|
explicit MA_PPerformer(MAPerformer & _owner);
|
||||||
using StandardBodyOptionItemVisitor<MAPerformer>::operator();
|
using StandardBodyOptionItemVisitor<MAPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE;
|
void operator()(TIexp const& cmp) const override;
|
||||||
void operator()(TVarpExp const& cmp) const OVERRIDE;
|
void operator()(TVarpExp const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MAPerformer : StandardReceiverVisitor<TUnusedType>
|
struct MAPerformer : StandardReceiverVisitor<TUnusedType>
|
||||||
@@ -942,7 +942,7 @@ struct MAPerformer : StandardReceiverVisitor<TUnusedType>
|
|||||||
{}
|
{}
|
||||||
using StandardReceiverVisitor<TUnusedType>::operator();
|
using StandardReceiverVisitor<TUnusedType>::operator();
|
||||||
|
|
||||||
void operator()(TNormalBodyOption const& trig) const OVERRIDE
|
void operator()(TNormalBodyOption const& trig) const override
|
||||||
{
|
{
|
||||||
switch(trig.optionCode)
|
switch(trig.optionCode)
|
||||||
{
|
{
|
||||||
@@ -981,8 +981,8 @@ struct MO_GPerformer : StandardBodyOptionItemVisitor<MOPerformer>
|
|||||||
{}
|
{}
|
||||||
using StandardBodyOptionItemVisitor<MOPerformer>::operator();
|
using StandardBodyOptionItemVisitor<MOPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TVarpExp const& cmp) const OVERRIDE;
|
void operator()(TVarpExp const& cmp) const override;
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE;
|
void operator()(TIexp const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MOPerformer: StandardReceiverVisitor<int3>
|
struct MOPerformer: StandardReceiverVisitor<int3>
|
||||||
@@ -991,7 +991,7 @@ struct MOPerformer: StandardReceiverVisitor<int3>
|
|||||||
{}
|
{}
|
||||||
using StandardReceiverVisitor<int3>::operator();
|
using StandardReceiverVisitor<int3>::operator();
|
||||||
|
|
||||||
void operator()(TNormalBodyOption const& trig) const OVERRIDE
|
void operator()(TNormalBodyOption const& trig) const override
|
||||||
{
|
{
|
||||||
switch(trig.optionCode)
|
switch(trig.optionCode)
|
||||||
{
|
{
|
||||||
@@ -1116,8 +1116,8 @@ struct VR_SPerformer : StandardBodyOptionItemVisitor<VRPerformer>
|
|||||||
explicit VR_SPerformer(VRPerformer & _owner);
|
explicit VR_SPerformer(VRPerformer & _owner);
|
||||||
using StandardBodyOptionItemVisitor<VRPerformer>::operator();
|
using StandardBodyOptionItemVisitor<VRPerformer>::operator();
|
||||||
|
|
||||||
void operator()(TStringConstant const& cmp) const OVERRIDE;
|
void operator()(TStringConstant const& cmp) const override;
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE;
|
void operator()(TIexp const& cmp) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VRPerformer : StandardReceiverVisitor<IexpValStr>
|
struct VRPerformer : StandardReceiverVisitor<IexpValStr>
|
||||||
@@ -1125,7 +1125,7 @@ struct VRPerformer : StandardReceiverVisitor<IexpValStr>
|
|||||||
VRPerformer(ERMInterpreter * _interpr, IexpValStr ident) : StandardReceiverVisitor<IexpValStr>(_interpr, ident)
|
VRPerformer(ERMInterpreter * _interpr, IexpValStr ident) : StandardReceiverVisitor<IexpValStr>(_interpr, ident)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator()(TVRLogic const& trig) const OVERRIDE
|
void operator()(TVRLogic const& trig) const override
|
||||||
{
|
{
|
||||||
int valr = interp->getIexp(trig.var).getInt();
|
int valr = interp->getIexp(trig.var).getInt();
|
||||||
switch (trig.opcode)
|
switch (trig.opcode)
|
||||||
@@ -1144,7 +1144,7 @@ struct VRPerformer : StandardReceiverVisitor<IexpValStr>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(TVRArithmetic const& trig) const OVERRIDE
|
void operator()(TVRArithmetic const& trig) const override
|
||||||
{
|
{
|
||||||
IexpValStr rhs = interp->getIexp(trig.rhs);
|
IexpValStr rhs = interp->getIexp(trig.rhs);
|
||||||
switch (trig.opcode)
|
switch (trig.opcode)
|
||||||
@@ -1169,7 +1169,7 @@ struct VRPerformer : StandardReceiverVisitor<IexpValStr>
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator()(TNormalBodyOption const& trig) const OVERRIDE
|
void operator()(TNormalBodyOption const& trig) const override
|
||||||
{
|
{
|
||||||
switch(trig.optionCode)
|
switch(trig.optionCode)
|
||||||
{
|
{
|
||||||
@@ -1380,7 +1380,7 @@ struct ERMExpDispatch : boost::static_visitor<>
|
|||||||
}
|
}
|
||||||
else if(trig.name == "HE")
|
else if(trig.name == "HE")
|
||||||
{
|
{
|
||||||
const CGHeroInstance * hero = NULL;
|
const CGHeroInstance * hero = nullptr;
|
||||||
if(trig.identifier.is_initialized())
|
if(trig.identifier.is_initialized())
|
||||||
{
|
{
|
||||||
ERM::Tidentifier tid = trig.identifier.get();
|
ERM::Tidentifier tid = trig.identifier.get();
|
||||||
@@ -1754,11 +1754,11 @@ struct LVL3BodyOptionItemVisitor : StandardBodyOptionItemVisitor<IexpValStr>
|
|||||||
{}
|
{}
|
||||||
using StandardBodyOptionItemVisitor<IexpValStr>::operator();
|
using StandardBodyOptionItemVisitor<IexpValStr>::operator();
|
||||||
|
|
||||||
void operator()(TIexp const& cmp) const OVERRIDE
|
void operator()(TIexp const& cmp) const override
|
||||||
{
|
{
|
||||||
owner = erm->getIexp(cmp);
|
owner = erm->getIexp(cmp);
|
||||||
}
|
}
|
||||||
void operator()(TVarpExp const& cmp) const OVERRIDE
|
void operator()(TVarpExp const& cmp) const override
|
||||||
{
|
{
|
||||||
owner = erm->getIexp(cmp);
|
owner = erm->getIexp(cmp);
|
||||||
}
|
}
|
||||||
@@ -2717,7 +2717,7 @@ struct VEvaluator : boost::static_visitor<VOption>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
VOption ERMInterpreter::eval( VOption line, Environment * env /*= NULL*/ )
|
VOption ERMInterpreter::eval( VOption line, Environment * env /*= nullptr*/ )
|
||||||
{
|
{
|
||||||
// if(line.children.isNil())
|
// if(line.children.isNil())
|
||||||
// return;
|
// return;
|
||||||
@@ -2729,7 +2729,7 @@ VOption ERMInterpreter::eval( VOption line, Environment * env /*= NULL*/ )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOptionList ERMInterpreter::evalEach( VermTreeIterator list, Environment * env /*= NULL*/ )
|
VOptionList ERMInterpreter::evalEach( VermTreeIterator list, Environment * env /*= nullptr*/ )
|
||||||
{
|
{
|
||||||
VOptionList ret;
|
VOptionList ret;
|
||||||
for(int g=0; g<list.size(); ++g)
|
for(int g=0; g<list.size(); ++g)
|
||||||
|
@@ -23,7 +23,7 @@ namespace VERMInterpreter
|
|||||||
{
|
{
|
||||||
std::string problem;
|
std::string problem;
|
||||||
public:
|
public:
|
||||||
const char * what() const throw() OVERRIDE
|
const char * what() const throw() override
|
||||||
{
|
{
|
||||||
return problem.c_str();
|
return problem.c_str();
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ namespace VERMInterpreter
|
|||||||
|
|
||||||
int realLineNum;
|
int realLineNum;
|
||||||
|
|
||||||
LinePointer() : file(NULL)
|
LinePointer() : file(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
LinePointer(const FileInfo * finfo, int line, int _realLineNum) : file(finfo), lineNum(line),
|
LinePointer(const FileInfo * finfo, int line, int _realLineNum) : file(finfo), lineNum(line),
|
||||||
@@ -281,7 +281,7 @@ namespace VERMInterpreter
|
|||||||
LinePointer line;
|
LinePointer line;
|
||||||
TriggerLocalVars ermLocalVars;
|
TriggerLocalVars ermLocalVars;
|
||||||
Stack * stack; //where we are stuck at execution
|
Stack * stack; //where we are stuck at execution
|
||||||
Trigger() : stack(NULL)
|
Trigger() : stack(nullptr)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -468,7 +468,7 @@ namespace VERMInterpreter
|
|||||||
Environment * parent;
|
Environment * parent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Environment() : parent(NULL)
|
Environment() : parent(nullptr)
|
||||||
{}
|
{}
|
||||||
void setPatent(Environment * _parent);
|
void setPatent(Environment * _parent);
|
||||||
Environment * getPatent() const;
|
Environment * getPatent() const;
|
||||||
@@ -503,7 +503,7 @@ namespace VERMInterpreter
|
|||||||
public:
|
public:
|
||||||
VermTreeIterator(VOptionList & _parent) : parent(&_parent), state(NORM), basePos(0)
|
VermTreeIterator(VOptionList & _parent) : parent(&_parent), state(NORM), basePos(0)
|
||||||
{}
|
{}
|
||||||
VermTreeIterator() : parent(NULL), state(NORM)
|
VermTreeIterator() : parent(nullptr), state(NORM)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VermTreeIterator & operator=(const VOption & opt);
|
VermTreeIterator & operator=(const VOption & opt);
|
||||||
@@ -818,8 +818,8 @@ class ERMInterpreter : public CScriptingModule
|
|||||||
|
|
||||||
std::string processERMString(std::string ermstring);
|
std::string processERMString(std::string ermstring);
|
||||||
|
|
||||||
VERMInterpreter::VOption eval( VERMInterpreter::VOption line, VERMInterpreter::Environment * env = NULL );
|
VERMInterpreter::VOption eval( VERMInterpreter::VOption line, VERMInterpreter::Environment * env = nullptr );
|
||||||
VERMInterpreter::VOptionList evalEach( VERMInterpreter::VermTreeIterator list, VERMInterpreter::Environment * env = NULL );
|
VERMInterpreter::VOptionList evalEach( VERMInterpreter::VermTreeIterator list, VERMInterpreter::Environment * env = nullptr );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef std::map< int, std::vector<int> > TIDPattern;
|
typedef std::map< int, std::vector<int> > TIDPattern;
|
||||||
@@ -839,13 +839,13 @@ public:
|
|||||||
int getRealLine(const VERMInterpreter::LinePointer &lp);
|
int getRealLine(const VERMInterpreter::LinePointer &lp);
|
||||||
|
|
||||||
//overload CScriptingModule
|
//overload CScriptingModule
|
||||||
virtual void heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start) OVERRIDE;
|
virtual void heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start) override;
|
||||||
virtual void init() OVERRIDE;//sets up environment etc.
|
virtual void init() override;//sets up environment etc.
|
||||||
virtual void executeUserCommand(const std::string &cmd) OVERRIDE;
|
virtual void executeUserCommand(const std::string &cmd) override;
|
||||||
virtual void giveInfoCB(CPrivilagedInfoCallback *cb) OVERRIDE;
|
virtual void giveInfoCB(CPrivilagedInfoCallback *cb) override;
|
||||||
virtual void giveActionCB(IGameEventRealizer *cb) OVERRIDE;
|
virtual void giveActionCB(IGameEventRealizer *cb) override;
|
||||||
|
|
||||||
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE;
|
virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override;
|
||||||
|
|
||||||
const CGObjectInstance *getObjFrom(int3 pos);
|
const CGObjectInstance *getObjFrom(int3 pos);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@@ -1,10 +1,6 @@
|
|||||||
#include "StdInc.h"
|
#include "StdInc.h"
|
||||||
#include "ERMParser.h"
|
#include "ERMParser.h"
|
||||||
|
|
||||||
//To make compilation with older boost versions possible
|
|
||||||
//Don't know exact version - 1.46 works while 1.42 not
|
|
||||||
#if BOOST_VERSION >= 104600
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ERMParser.cpp, part of VCMI engine
|
* ERMParser.cpp, part of VCMI engine
|
||||||
*
|
*
|
||||||
@@ -67,7 +63,7 @@ std::string CERMPreprocessor::retreiveCommandLine()
|
|||||||
getline(line); //reading line
|
getline(line); //reading line
|
||||||
|
|
||||||
|
|
||||||
int dash = line.find_first_of('^');
|
size_t dash = line.find_first_of('^');
|
||||||
bool inTheMiddle = openedBraces || openedString;
|
bool inTheMiddle = openedBraces || openedString;
|
||||||
|
|
||||||
if(!inTheMiddle)
|
if(!inTheMiddle)
|
||||||
@@ -548,9 +544,3 @@ void ERMParser::repairEncoding( char * str, int len ) const
|
|||||||
if(str[g] & 0x80)
|
if(str[g] & 0x80)
|
||||||
str[g] = '|';
|
str[g] = '|';
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
ERMParser::ERMParser(std::string file){}
|
|
||||||
std::vector<LineInfo> ERMParser::parseFile() {std::vector<LineInfo> dummy; return dummy;} //compile fix
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Reference in New Issue
Block a user