forked from Mirrors/openclonk
Move the global proplist from a member of ScriptEngine to an ancestor
While at it, denumerate the global proplist. Not that it contains anything to denumerate, but someday it might?liquid_container
parent
6f98fb2e66
commit
87689d9f49
|
@ -44,7 +44,7 @@ const char *C4AulError::what() const noexcept
|
|||
/*--- C4AulScriptEngine ---*/
|
||||
|
||||
C4AulScriptEngine::C4AulScriptEngine():
|
||||
GlobalPropList(C4PropList::NewStatic(NULL, NULL, ::Strings.RegString("Global"))),
|
||||
C4PropListStaticMember(NULL, NULL, ::Strings.RegString("Global")),
|
||||
warnCnt(0), errCnt(0), lineCnt(0)
|
||||
{
|
||||
GlobalNamedNames.Reset();
|
||||
|
@ -54,12 +54,7 @@ C4AulScriptEngine::C4AulScriptEngine():
|
|||
GlobalConsts.Reset();
|
||||
GlobalConsts.SetNameList(&GlobalConstNames);
|
||||
Child0 = ChildL = NULL;
|
||||
RegisterGlobalConstant("Global", GlobalPropList);
|
||||
}
|
||||
|
||||
C4PropListStatic * C4AulScriptEngine::GetPropList()
|
||||
{
|
||||
return GlobalPropList._getPropList()->IsStatic();
|
||||
RegisterGlobalConstant("Global", C4VPropList(this));
|
||||
}
|
||||
|
||||
C4AulScriptEngine::~C4AulScriptEngine()
|
||||
|
@ -77,7 +72,7 @@ void C4AulScriptEngine::Clear()
|
|||
if (Child0->Delete()) delete Child0;
|
||||
else Child0->Unreg();
|
||||
// clear own stuff
|
||||
GlobalPropList._getPropList()->Clear();
|
||||
C4PropListStaticMember::Clear();
|
||||
// reset values
|
||||
warnCnt = errCnt = lineCnt = 0;
|
||||
// resetting name lists will reset all data lists, too
|
||||
|
@ -86,7 +81,7 @@ void C4AulScriptEngine::Clear()
|
|||
GlobalConstNames.Reset();
|
||||
GlobalConsts.Reset();
|
||||
GlobalConsts.SetNameList(&GlobalConstNames);
|
||||
RegisterGlobalConstant("Global", GlobalPropList);
|
||||
RegisterGlobalConstant("Global", C4VPropList(this));
|
||||
GlobalNamed.Reset();
|
||||
GlobalNamed.SetNameList(&GlobalNamedNames);
|
||||
UserFiles.clear();
|
||||
|
@ -114,12 +109,12 @@ bool C4AulScriptEngine::GetGlobalConstant(const char *szName, C4Value *pTargetVa
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4AulScriptEngine::Denumerate(C4ValueNumbers * numbers)
|
||||
void C4AulScriptEngine::Denumerate(C4ValueNumbers * numbers)
|
||||
{
|
||||
GlobalNamed.Denumerate(numbers);
|
||||
// runtime data only: don't denumerate consts
|
||||
GameScript.ScenPropList.Denumerate(numbers);
|
||||
return true;
|
||||
C4PropListStaticMember::Denumerate(numbers);
|
||||
}
|
||||
|
||||
void C4AulScriptEngine::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers)
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
};
|
||||
|
||||
// holds all C4AulScripts
|
||||
class C4AulScriptEngine
|
||||
class C4AulScriptEngine: public C4PropListStaticMember
|
||||
{
|
||||
protected:
|
||||
C4AulFuncMap FuncLookUp;
|
||||
|
@ -101,7 +101,6 @@ protected:
|
|||
{ return FuncLookUp.GetFirstFunc(Name); }
|
||||
C4AulFunc * GetNextSNFunc(const C4AulFunc * After)
|
||||
{ return FuncLookUp.GetNextSNFunc(After); }
|
||||
C4Value GlobalPropList;
|
||||
C4ScriptHost *Child0, *ChildL; // tree structure
|
||||
|
||||
// all open user files
|
||||
|
@ -127,9 +126,7 @@ public:
|
|||
void Clear(); // clear data
|
||||
void Link(C4DefList *rDefs); // link and parse all scripts
|
||||
void ReLink(C4DefList *rDefs); // unlink, link and parse all scripts
|
||||
C4PropListStatic * GetPropList();
|
||||
C4Value Call(const char * k, C4AulParSet *pPars=0, bool fPassErrors=false)
|
||||
{ return GetPropList()->Call(k, pPars, fPassErrors); }
|
||||
C4PropListStatic * GetPropList() { return this; }
|
||||
bool ReloadScript(const char *szScript, const char *szLanguage); // search script and reload, if found
|
||||
|
||||
// For the list of functions in the PropertyDlg
|
||||
|
@ -138,7 +135,7 @@ public:
|
|||
void RegisterGlobalConstant(const char *szName, const C4Value &rValue); // creates a new constants or overwrites an old one
|
||||
bool GetGlobalConstant(const char *szName, C4Value *pTargetValue); // check if a constant exists; assign value to pTargetValue if not NULL
|
||||
|
||||
bool Denumerate(C4ValueNumbers *);
|
||||
void Denumerate(C4ValueNumbers *);
|
||||
void UnLink(); // called when a script is being reloaded (clears string table)
|
||||
|
||||
// Compile scenario script data (without strings and constants)
|
||||
|
|
Loading…
Reference in New Issue