OpenClonk
C4AulScriptEngine Class Reference

#include <C4Aul.h>

Inheritance diagram for C4AulScriptEngine:
[legend]
Collaboration diagram for C4AulScriptEngine:
[legend]

Public Member Functions

 C4AulScriptEngine ()
 
 ~C4AulScriptEngine () override
 
void Clear ()
 
void Link (C4DefList *rDefs)
 
void ReLink (C4DefList *rDefs)
 
C4PropListStaticGetPropList ()
 
bool ReloadScript (const char *szScript, const char *szLanguage)
 
std::list< const char * > GetFunctionNames (C4PropList *)
 
void RegisterGlobalConstant (const char *szName, const C4Value &rValue)
 
bool GetGlobalConstant (const char *szName, C4Value *pTargetValue)
 
void Denumerate (C4ValueNumbers *) override
 
void UnLink ()
 
void CompileFunc (StdCompiler *pComp, bool fScenarioSection, C4ValueNumbers *numbers)
 
int32_t CreateUserFile ()
 
void CloseUserFile (int32_t handle)
 
C4AulUserFileGetUserFile (int32_t handle)
 
void RegisterErrorHandler (C4AulErrorHandler *handler)
 
void UnregisterErrorHandler (C4AulErrorHandler *handler)
 
C4AulErrorHandlerGetErrorHandler () const
 
bool Delete () override
 
C4PropListStaticIsStatic () override
 
const class C4PropListStaticIsStatic () const
 
void RefCompileFunc (StdCompiler *pComp, C4ValueNumbers *numbers) const
 
StdStrBuf GetDataString () const
 
const char * GetName () const override
 
const C4PropListStaticGetParent () const
 
C4StringGetParentKeyName ()
 
virtual void SetName (const char *NewName=nullptr)
 
virtual void SetOnFire (bool OnFire)
 
virtual C4Def const * GetDef () const
 
virtual C4DefGetDef ()
 
virtual C4ObjectGetObject ()
 
virtual C4Object const * GetObject () const
 
virtual C4EffectGetEffect ()
 
virtual C4PropListNumberedGetPropListNumbered ()
 
virtual class C4MapScriptLayerGetMapScriptLayer ()
 
virtual class C4MapScriptMapGetMapScriptMap ()
 
C4PropListGetPrototype () const
 
void RemoveCyclicPrototypes ()
 
virtual bool IsNumbered () const
 
virtual bool GetPropertyByS (const C4String *k, C4Value *pResult) const
 
virtual C4ValueArrayGetProperties () const
 
virtual void SetPropertyByS (C4String *k, const C4Value &to)
 
virtual void ResetProperty (C4String *k)
 
bool GetProperty (C4PropertyName k, C4Value *pResult) const
 
C4StringGetPropertyStr (C4PropertyName k) const
 
C4ValueArrayGetPropertyArray (C4PropertyName n) const
 
C4AulFuncGetFunc (C4PropertyName k) const
 
C4AulFuncGetFunc (C4String *k) const
 
C4AulFuncGetFunc (const char *k) const
 
C4StringEnumerateOwnFuncs (C4String *prev=nullptr) const
 
C4Value Call (C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (C4String *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4Value Call (const char *k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
 
C4PropertyName GetPropertyP (C4PropertyName k) const
 
int32_t GetPropertyBool (C4PropertyName n, bool default_val=false) const
 
int32_t GetPropertyInt (C4PropertyName k, int32_t default_val=0) const
 
C4PropListGetPropertyPropList (C4PropertyName k) const
 
bool HasProperty (C4String *k) const
 
void SetProperty (C4PropertyName k, const C4Value &to)
 
void Freeze ()
 
void Thaw ()
 
void ThawRecursively ()
 
bool IsFrozen () const
 
C4PropListStaticFreezeAndMakeStaticRecursively (std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
 
void CompileFunc (StdCompiler *pComp, C4ValueNumbers *)
 
void AppendDataString (StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
 
StdStrBuf ToJSON (int depth=10, bool ignore_reference_parent=false) const
 
std::vector< C4String * > GetSortedLocalProperties (bool add_prototype=true) const
 
std::vector< C4String * > GetSortedLocalProperties (const char *prefix, const C4PropList *ignore_overridden) const
 
std::vector< C4String * > GetUnsortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
std::vector< C4String * > GetSortedProperties (const char *prefix, C4PropList *ignore_parent=nullptr) const
 
bool operator== (const C4PropList &b) const
 
Iterator begin ()
 
Iterator end ()
 

Static Public Member Functions

static C4PropListNew (C4PropList *prototype=nullptr)
 
static C4PropListStaticNewStatic (C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
 

Public Attributes

int warnCnt {0}
 
int errCnt {0}
 
int lineCnt {0}
 
C4ValueMapNames GlobalNamedNames
 
C4ValueMapData GlobalNamed
 
C4ValueMapNames GlobalConstNames
 
C4ValueMapData GlobalConsts
 
C4EffectpGlobalEffects = nullptr
 
int32_t Status {1}
 

Protected Member Functions

C4AulFuncGetFirstFunc (const char *Name)
 
C4AulFuncGetNextSNFunc (const C4AulFunc *After)
 
void ClearRefs ()
 

Protected Attributes

C4AulFuncMap FuncLookUp
 
C4ScriptHostChild0
 
C4ScriptHostChildL
 
std::list< C4AulUserFileUserFiles
 
std::vector< C4ValueOwnedPropLists
 
C4AulErrorHandlerErrorHandler
 
const C4PropListStaticParent
 
C4RefCntPointer< C4StringParentKeyName
 

Friends

class C4AulFunc
 
class C4AulProfiler
 
class C4ScriptHost
 
class C4AulParse
 
class C4AulCompiler
 
class C4AulDebug
 

Detailed Description

Definition at line 113 of file C4Aul.h.

Constructor & Destructor Documentation

◆ C4AulScriptEngine()

C4AulScriptEngine::C4AulScriptEngine ( )

Definition at line 66 of file C4Aul.cpp.

66  :
67  C4PropListStaticMember(nullptr, nullptr, ::Strings.RegString("Global")),
68  ErrorHandler(&DefaultErrorHandler)
69 {
76  Child0 = ChildL = nullptr;
77  RegisterGlobalConstant("Global", C4VPropList(this));
78 }
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:242
C4ScriptHost * ChildL
Definition: C4Aul.h:121
C4ValueMapNames GlobalConstNames
Definition: C4Aul.h:141
C4ValueMapNames GlobalNamedNames
Definition: C4Aul.h:134
C4ValueMapData GlobalConsts
Definition: C4Aul.h:142
C4ScriptHost * Child0
Definition: C4Aul.h:121
C4AulErrorHandler * ErrorHandler
Definition: C4Aul.h:128
C4ValueMapData GlobalNamed
Definition: C4Aul.h:135
void RegisterGlobalConstant(const char *szName, const C4Value &rValue)
Definition: C4Aul.cpp:123
C4PropListStaticMember(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.h:286
C4String * RegString(StdStrBuf String)
void SetNameList(C4ValueMapNames *pnNames)
Definition: C4ValueMap.cpp:78

◆ ~C4AulScriptEngine()

C4AulScriptEngine::~C4AulScriptEngine ( )
override

Definition at line 80 of file C4Aul.cpp.

81 {
82  Clear();
83 }
void Clear()
Definition: C4Aul.cpp:85

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ AppendDataString()

void C4PropList::AppendDataString ( StdStrBuf out,
const char *  delim,
int  depth = 3,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 487 of file C4PropList.cpp.

488 {
489  StdStrBuf & DataString = *out;
490  if (depth <= 0 && Properties.GetSize())
491  {
492  DataString.Append("...");
493  return;
494  }
495  bool has_elements = false;
496  // Append prototype
497  if (prototype)
498  {
499  DataString.Append("Prototype = ");
500  DataString.Append(prototype.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
501  has_elements = true;
502  }
503  // Append other properties
504  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
505  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
506  {
507  if (has_elements) DataString.Append(delim);
508  DataString.Append((*p)->Key->GetData());
509  DataString.Append(" = ");
510  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
511  has_elements = true;
512  }
513 }
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:89
std::list< const T * > GetSortedListOfElementPointers() const
unsigned int GetSize() const
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

References StdStrBuf::Append(), C4PropList::begin(), C4PropList::end(), C4Value::GetDataString(), C4Set< T >::GetSize(), C4Set< T >::GetSortedListOfElementPointers(), and C4PropList::IsStatic().

Referenced by C4Object::GetDataString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

C4PropList::Iterator C4PropList::begin ( )
inherited

Definition at line 995 of file C4PropList.cpp.

996 {
998 
999  if (GetPrototype())
1000  {
1001  iter = GetPrototype()->begin();
1002  }
1003  else
1004  {
1005  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1006  }
1007  iter.Reserve(Properties.GetSize());
1008 
1009  const C4Property * p = Properties.First();
1010  while (p)
1011  {
1012  iter.AddProperty(p);
1013  p = Properties.Next(p);
1014  }
1015 
1016  iter.Init();
1017  return iter;
1018 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:85
Iterator begin()
Definition: C4PropList.cpp:995
T const * Next(T const *p) const
T const * First() const

References C4PropList::begin(), C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::GetSize(), and C4Set< T >::Next().

Referenced by C4PropList::AppendDataString(), C4PropList::begin(), C4ParticleProperties::Set(), and C4PropList::ToJSON().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Call() [1/3]

C4Value C4PropList::Call ( C4PropertyName  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inlineinherited

Definition at line 114 of file C4PropList.h.

115  { return Call(&Strings.P[k], pPars, fPassErrors); }
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:114
C4String P[P_LAST]

References C4StringTable::P, and Strings.

Referenced by C4Command::Acquire(), C4Object::ActivateEntrance(), C4Object::ActivateMenu(), C4Object::AssignDeath(), C4Object::AssignRemoval(), C4Command::Call(), C4GameScriptHost::Call(), C4Effect::CallEffect(), C4Command::CallFailed(), C4Effect::CallStart(), C4Effect::CallStop(), C4Effect::CallTimer(), C4FindObjectFunc::Check(), C4Effect::ClearAll(), C4Object::Collect(), C4SortObjectFunc::CompareGetValue(), C4Object::Contact(), C4GameObjects::CrossCheck(), C4Landscape::P::DigMaterial2Objects(), C4Object::DirectComContents(), C4Object::DoBreath(), C4Object::DoCon(), C4Object::DoDamage(), C4Object::DoEnergy(), C4Object::DoMovement(), C4ObjectMenu::DoRefillInternal(), C4Object::DoSelect(), C4Object::Enter(), C4RoundResults::EvaluateGame(), C4RoundResults::EvaluateGoals(), C4Object::ExecLife(), C4Object::ExecuteCommand(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Object::Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), C4Object::GetValue(), GrabLost(), C4Landscape::Incinerate(), C4Effect::Init(), C4Player::Init(), C4ObjectMenu::IsCloseDenied(), C4Effect::Kill(), C4Object::Lift(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4Object::Promote(), C4Object::Push(), C4Game::SaveData(), C4Object::SetAction(), C4GUI::FrameDecoration::SetByDef(), C4Object::SetCommand(), C4Player::SetObjectCrewStatus(), C4Object::SetOwner(), C4Object::StatusActivate(), C4Command::Transfer(), and C4Object::UnSelect().

Here is the caller graph for this function:

◆ Call() [2/3]

C4Value C4PropList::Call ( C4String k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 797 of file C4PropList.cpp.

798 {
799  if (!Status) return C4Value();
800  C4AulFunc *pFn = GetFunc(k);
801  if (!pFn) return C4Value();
802  return pFn->Exec(this, Pars, fPassErrors);
803 }
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:72
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:109
int32_t Status
Definition: C4PropList.h:173
friend class C4Value
Definition: C4PropList.h:170

References C4PropList::C4Value, C4AulFunc::Exec(), C4PropList::GetFunc(), and C4PropList::Status.

Here is the call graph for this function:

◆ Call() [3/3]

C4Value C4PropList::Call ( const char *  k,
C4AulParSet pPars = nullptr,
bool  fPassErrors = false 
)
inherited

Definition at line 805 of file C4PropList.cpp.

806 {
807  if (!Status) return C4Value();
808  assert(s && s[0]);
809  C4AulFunc *pFn = GetFunc(s);
810  if (!pFn)
811  {
812  if (s[0] != '~')
813  {
814  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
815  if (fPassErrors)
816  throw err;
817  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
818  }
819  return C4Value();
820  }
821  return pFn->Exec(this, Pars, fPassErrors);
822 }
#define s
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
virtual void OnError(const char *msg)=0
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173

References C4PropList::C4Value, C4AulFunc::Exec(), FormatString(), GetErrorHandler(), C4PropList::GetFunc(), C4AulErrorHandler::OnError(), s, ScriptEngine, C4PropList::Status, and C4AulError::what().

Here is the call graph for this function:

◆ Clear()

void C4AulScriptEngine::Clear ( )

Definition at line 85 of file C4Aul.cpp.

86 {
87 #ifndef NOAULDEBUG
88  // stop debugger
89  delete C4AulDebug::GetDebugger();
90 #endif
91  while (Child0)
92  if (Child0->Delete()) delete Child0;
93  else Child0->Unreg();
94  // clear own stuff
96  // reset values
97  warnCnt = errCnt = lineCnt = 0;
98  // resetting name lists will reset all data lists, too
99  // except not...
104  RegisterGlobalConstant("Global", C4VPropList(this));
105  GlobalNamed.Reset();
107  delete pGlobalEffects; pGlobalEffects=nullptr;
108  UserFiles.clear();
109  // Delete all global proplists made static (breaks
110  // cyclic references).
111  for (C4Value& value: OwnedPropLists)
112  {
113  C4PropList* plist = value.getPropList();
114  if (plist)
115  {
116  if (plist->Delete()) delete plist;
117  else plist->Clear();
118  }
119  }
120  OwnedPropLists.clear();
121 }
static C4AulDebug * GetDebugger()
Definition: C4AulDebug.h:31
std::list< C4AulUserFile > UserFiles
Definition: C4Aul.h:125
std::vector< C4Value > OwnedPropLists
Definition: C4Aul.h:126
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
virtual bool Delete()
Definition: C4PropList.h:94
void Clear()
Definition: C4PropList.h:70
virtual bool Delete()
Definition: C4ScriptHost.h:44

References C4VPropList(), Child0, C4PropList::Clear(), C4PropList::Delete(), C4ScriptHost::Delete(), errCnt, C4AulDebug::GetDebugger(), GlobalConstNames, GlobalConsts, GlobalNamed, GlobalNamedNames, lineCnt, OwnedPropLists, pGlobalEffects, RegisterGlobalConstant(), C4ValueMapData::Reset(), C4ValueMapNames::Reset(), C4ValueMapData::SetNameList(), C4ScriptHost::Unreg(), UserFiles, and warnCnt.

Referenced by c4_mapgen_handle_deinit_script_engine(), C4Game::Clear(), and ~C4AulScriptEngine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ClearRefs()

void C4PropList::ClearRefs ( )
inlineprotectedinherited

Definition at line 160 of file C4PropList.h.

160 { for( C4Value * ref: RefSet{Refs}) ref->Set0(); assert(Refs.empty()); }

Referenced by C4Object::AssignRemoval().

Here is the caller graph for this function:

◆ CloseUserFile()

void C4AulScriptEngine::CloseUserFile ( int32_t  handle)

Definition at line 241 of file C4Aul.cpp.

242 {
243  // close user file given by handle
244  for (std::list<C4AulUserFile>::iterator i = UserFiles.begin(); i != UserFiles.end(); ++i)
245  if ((*i).GetHandle() == handle)
246  {
247  UserFiles.erase(i);
248  break;
249  }
250 }

References UserFiles.

Referenced by C4EditCursor::PerformDuplication(), and C4Game::SaveData().

Here is the caller graph for this function:

◆ CompileFunc() [1/2]

void C4AulScriptEngine::CompileFunc ( StdCompiler pComp,
bool  fScenarioSection,
C4ValueNumbers numbers 
)

Definition at line 174 of file C4Aul.cpp.

175 {
176  if (!fScenarioSection)
177  {
178  assert(UserFiles.empty()); // user files must not be kept open
179  C4ValueMapData GlobalNamedDefault;
180  GlobalNamedDefault.SetNameList(&GlobalNamedNames);
181  pComp->Value(mkNamingAdapt(mkParAdapt(GlobalNamed, numbers), "StaticVariables", GlobalNamedDefault));
182  pComp->Value(mkNamingAdapt(mkParAdapt(*GameScript.ScenPropList._getPropList(), numbers), "Scenario"));
183  }
184  if (pComp->isDeserializer() && pGlobalEffects)
185  {
186  // loading scenario section or game re-init: Merge effects
187  // Must keep old effects here even if they're dead, because the LoadScenarioSection call typically came from execution of a global effect
188  // and otherwise dead pointers would remain on the stack
189  GlobalEffectsMergeCompileFunc(pComp, pGlobalEffects, "Effects", this, numbers);
190  GlobalEffectsMergeCompileFunc(pComp, GameScript.pScenarioEffects, "ScenarioEffects", GameScript.ScenPropList._getPropList(), numbers);
191  }
192  else
193  {
194  // Otherwise, just compile effects
195  pComp->Value(mkParAdapt(mkNamingPtrAdapt(pGlobalEffects, "Effects"), this, numbers));
197  }
198  pComp->Value(mkNamingAdapt(*numbers, "Values"));
199 }
C4GameScriptHost GameScript
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:636
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:166
C4Value ScenPropList
Definition: C4ScriptHost.h:164
C4PropList * _getPropList() const
Definition: C4Value.h:129
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References C4Value::_getPropList(), GameScript, GlobalNamed, GlobalNamedNames, StdCompiler::isDeserializer(), mkNamingAdapt(), mkParAdapt(), pGlobalEffects, C4GameScriptHost::ScenPropList, C4ValueMapData::SetNameList(), UserFiles, and StdCompiler::Value().

Here is the call graph for this function:

◆ CompileFunc() [2/2]

void C4PropList::CompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
)
inherited

Definition at line 366 of file C4PropList.cpp.

367 {
368  bool oldFormat = false;
369  // constant proplists are not serialized to savegames, but recreated from the game data instead
370  assert(!constant);
371  if (pComp->isDeserializer() && pComp->hasNaming())
372  {
373  // backwards compat to savegames and scenarios before 5.5
374  try
375  {
376  pComp->Value(constant);
377  oldFormat = true;
378  }
379  catch (StdCompiler::NotFoundException *pEx)
380  {
381  delete pEx;
382  pComp->Value(mkParAdapt(prototype, numbers));
383  }
384  }
385  else
386  pComp->Value(mkParAdapt(prototype, numbers));
388  pComp->Value(mkParAdapt(Properties, numbers));
389  if (oldFormat)
390  {
391  if (Properties.Has(&::Strings.P[P_Prototype]))
392  {
393  prototype = Properties.Get(&::Strings.P[P_Prototype]).Value;
394  Properties.Remove(&::Strings.P[P_Prototype]);
395  }
396  }
397 }
@ P_Prototype
C4Value Value
Definition: C4PropList.h:54
T & Get(H e) const
bool Has(H e) const
void Remove(H e)
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
virtual bool hasNaming()
Definition: StdCompiler.h:58

References C4Set< T >::Get(), C4Set< T >::Has(), StdCompiler::hasNaming(), StdCompiler::isDeserializer(), mkParAdapt(), C4StringTable::P, P_Prototype, C4Set< T >::Remove(), StdCompiler::SEP_SEP2, StdCompiler::Separator(), Strings, StdCompiler::Value(), and C4Property::Value.

Referenced by C4PropListNumbered::CompileFunc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateUserFile()

int32_t C4AulScriptEngine::CreateUserFile ( )

Definition at line 228 of file C4Aul.cpp.

229 {
230  // create new file and return handle
231  // find empty handle
232  int32_t last_handle = 1;
233  for (std::list<C4AulUserFile>::const_iterator i = UserFiles.begin(); i != UserFiles.end(); ++i)
234  if ((*i).GetHandle() >= last_handle)
235  last_handle = (*i).GetHandle()+1;
236  // Create new user file
237  UserFiles.emplace_back(last_handle);
238  return last_handle;
239 }

References UserFiles.

Referenced by C4EditCursor::PerformDuplication(), and C4Game::SaveData().

Here is the caller graph for this function:

◆ Delete()

bool C4PropListStaticMember::Delete ( )
inlineoverridevirtualinherited

Reimplemented from C4PropListStatic.

Definition at line 288 of file C4PropList.h.

288 { return false; }

◆ Denumerate()

void C4AulScriptEngine::Denumerate ( C4ValueNumbers numbers)
overridevirtual

Reimplemented from C4PropList.

Definition at line 145 of file C4Aul.cpp.

146 {
147  GlobalNamed.Denumerate(numbers);
148  // runtime data only: don't denumerate consts
149  GameScript.Denumerate(numbers);
152 }
void Denumerate(C4ValueNumbers *) override
Definition: C4Effect.cpp:176
void Denumerate(C4ValueNumbers *numbers)
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:321
void Denumerate(C4ValueNumbers *)
Definition: C4ValueMap.cpp:254

References C4PropList::Denumerate(), C4ValueMapData::Denumerate(), C4Effect::Denumerate(), C4GameScriptHost::Denumerate(), GameScript, GlobalNamed, and pGlobalEffects.

Here is the call graph for this function:

◆ end()

Iterator C4PropList::end ( )
inlineinherited

Definition at line 211 of file C4PropList.h.

211 { return Iterator(); }

Referenced by C4PropList::AppendDataString(), C4ParticleProperties::Set(), and C4PropList::ToJSON().

Here is the caller graph for this function:

◆ EnumerateOwnFuncs()

C4String * C4PropList::EnumerateOwnFuncs ( C4String prev = nullptr) const
inherited

Definition at line 928 of file C4PropList.cpp.

929 {
930  const C4Property * p = prev ? Properties.Next(&Properties.Get(prev)) : Properties.First();
931  while (p)
932  {
933  if (p->Value.getFunction())
934  return p->Key;
935  p = Properties.Next(p);
936  }
937  return nullptr;
938 }
C4String * Key
Definition: C4PropList.h:53
C4AulFunc * getFunction() const
Definition: C4Value.h:119

References C4Set< T >::First(), C4Set< T >::Get(), C4Value::getFunction(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

Here is the call graph for this function:

◆ Freeze()

void C4PropList::Freeze ( )
inlineinherited

Definition at line 132 of file C4PropList.h.

132 { constant = true; }

Referenced by C4PropList::FreezeAndMakeStaticRecursively().

Here is the caller graph for this function:

◆ FreezeAndMakeStaticRecursively()

C4PropListStatic * C4PropList::FreezeAndMakeStaticRecursively ( std::vector< C4Value > *  prop_lists,
const C4PropListStatic parent = nullptr,
C4String key = nullptr 
)
inherited

Definition at line 279 of file C4PropList.cpp.

280 {
281  Freeze();
282  // Already static?
283  C4PropListStatic *this_static = IsStatic();
284  if (!this_static)
285  {
286  // Make self static by creating a copy and replacing all references
287  this_static = NewStatic(GetPrototype(), parent, key);
288  this_static->Properties.Swap(&Properties); // grab properties
289  this_static->Status = Status;
290  RefSet pre_freeze_refs{Refs}; // copy to avoid iterator validity headaches
291  C4Value holder = C4VPropList(this); // add another reference to prevent premature deletion
292  for (C4Value * ref : pre_freeze_refs)
293  ref->SetPropList(this_static);
294  // store reference
295  if (prop_lists)
296  prop_lists->push_back(C4VPropList(this_static));
297  // "this" should be deleted as holder goes out of scope
298  }
299  // Iterate over sorted list of elements to make static
300  // Must iterate over sorted list because the order must be defined, just in case it's a network game
301  // and a non-static child proplist is available through different paths it should still get the same name
302  auto prop_names = this_static->GetSortedLocalProperties(false);
303  for (auto prop_name : prop_names)
304  {
305  C4Value child_val;
306  this_static->GetPropertyByS(prop_name, &child_val);
307  C4PropList *child_proplist = child_val.getPropList();
308  if (child_proplist)
309  {
310  // Avoid infinite recursion: Only freeze into unfrozen children and "true" static children
311  C4PropListStatic *child_static = child_proplist->IsStatic();
312  if (!child_static || (child_static->GetParent() == this_static && child_static->GetParentKeyName() == prop_name))
313  {
314  child_proplist->FreezeAndMakeStaticRecursively(prop_lists, this_static, prop_name);
315  }
316  }
317  }
318  return this_static;
319 }
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:726
C4PropListStatic * FreezeAndMakeStaticRecursively(std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
Definition: C4PropList.cpp:279
std::vector< C4String * > GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:545
void Freeze()
Definition: C4PropList.h:132
static C4PropListStatic * NewStatic(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.cpp:46
C4String * GetParentKeyName()
Definition: C4PropList.h:276
const C4PropListStatic * GetParent() const
Definition: C4PropList.h:275
C4PropList * getPropList() const
Definition: C4Value.h:116

References C4VPropList(), C4PropList::Freeze(), C4PropList::FreezeAndMakeStaticRecursively(), C4PropListStatic::GetParent(), C4PropListStatic::GetParentKeyName(), C4PropList::GetPropertyByS(), C4Value::getPropList(), C4PropList::GetPrototype(), C4PropList::GetSortedLocalProperties(), C4PropList::IsStatic(), C4PropList::NewStatic(), and C4PropList::Status.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and Link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDataString()

StdStrBuf C4PropListStatic::GetDataString ( ) const
inherited

Definition at line 229 of file C4PropList.cpp.

230 {
231  StdStrBuf r;
232  if (Parent)
233  {
234  r.Take(Parent->GetDataString());
235  r.AppendChar('.');
236  }
237  assert(ParentKeyName);
238  if (ParentKeyName)
240  return r;
241 }
C4RefCntPointer< C4String > ParentKeyName
Definition: C4PropList.h:279
StdStrBuf GetDataString() const
Definition: C4PropList.cpp:229
const C4PropListStatic * Parent
Definition: C4PropList.h:278
StdStrBuf GetData() const
Definition: C4StringTable.h:50
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Take(char *pnData)
Definition: StdBuf.h:457

References StdStrBuf::Append(), StdStrBuf::AppendChar(), C4String::GetData(), C4PropListStatic::GetDataString(), C4PropListStatic::Parent, C4PropListStatic::ParentKeyName, and StdStrBuf::Take().

Referenced by C4PropertyPath::C4PropertyPath(), C4PropListStatic::GetDataString(), C4AulFunc::GetFullName(), C4DefScriptHost::Parse(), and C4AulScriptContext::ReturnDump().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDef() [1/2]

C4Def * C4PropList::GetDef ( )
virtualinherited

Reimplemented in C4Def.

Definition at line 648 of file C4PropList.cpp.

649 {
650  if (GetPrototype()) return GetPrototype()->GetDef();
651  return nullptr;
652 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:654

References C4PropList::GetDef(), and C4PropList::GetPrototype().

Here is the call graph for this function:

◆ GetDef() [2/2]

C4Def const * C4PropList::GetDef ( ) const
virtualinherited

Reimplemented in C4Def.

Definition at line 654 of file C4PropList.cpp.

655 {
656  if (GetPrototype()) return GetPrototype()->GetDef();
657  return nullptr;
658 }

References C4PropList::GetDef(), and C4PropList::GetPrototype().

Referenced by C4Value::_getDef(), ConstructionCheck(), C4Game::CreateObject(), C4Game::CreateObjectConstruction(), C4AulExec::DirectExec(), C4GameMessage::Draw(), C4Game::DrawPropListSpecImage(), C4AulExec::FnTranslate(), C4PropList::GetDef(), C4Value::getDef(), C4Object::Init(), C4GameMessage::Init(), C4FindObjectDef::IsImpossible(), C4PropList::operator==(), C4ScriptHost::Parse(), C4AulParse::Parse_Script(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), and C4ScriptGuiWindowProperty::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEffect()

C4Effect * C4PropList::GetEffect ( )
virtualinherited

Reimplemented in C4Effect.

Definition at line 678 of file C4PropList.cpp.

679 {
680  if (GetPrototype()) return GetPrototype()->GetEffect();
681  return nullptr;
682 }
virtual C4Effect * GetEffect()
Definition: C4PropList.cpp:678

References C4PropList::GetEffect(), and C4PropList::GetPrototype().

Referenced by C4ValueConv< C4Effect * >::_FromC4V(), and C4PropList::GetEffect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetErrorHandler()

C4AulErrorHandler* C4AulScriptEngine::GetErrorHandler ( ) const
inline

Definition at line 173 of file C4Aul.h.

174  {
175  return ErrorHandler;
176  }

Referenced by C4PropList::Call(), C4AulFunc::CheckParTypes(), C4AulExec::DirectExec(), C4ScriptHost::ResolveIncludes(), C4AulCompiler::PreparseAstVisitor::visit(), C4AulCompiler::ConstantResolver::visit(), and C4ScriptHost::Warn().

Here is the caller graph for this function:

◆ GetFirstFunc()

C4AulFunc* C4AulScriptEngine::GetFirstFunc ( const char *  Name)
inlineprotected

Definition at line 117 of file C4Aul.h.

118  { return FuncLookUp.GetFirstFunc(Name); }
C4AulFunc * GetFirstFunc(const char *Name)
Definition: C4Aul.cpp:297
C4AulFuncMap FuncLookUp
Definition: C4Aul.h:116

References C4AulFuncMap::GetFirstFunc().

Here is the call graph for this function:

◆ GetFunc() [1/3]

C4AulFunc* C4PropList::GetFunc ( C4PropertyName  k) const
inlineinherited

◆ GetFunc() [2/3]

C4AulFunc * C4PropList::GetFunc ( C4String k) const
inherited

Definition at line 772 of file C4PropList.cpp.

773 {
774  assert(k);
775  if (Properties.Has(k))
776  {
777  return Properties.Get(k).Value.getFunction();
778  }
779  if (GetPrototype())
780  {
781  return GetPrototype()->GetFunc(k);
782  }
783  return nullptr;
784 }

References C4Set< T >::Get(), C4PropList::GetFunc(), C4Value::getFunction(), C4PropList::GetPrototype(), C4Set< T >::Has(), and C4Property::Value.

Here is the call graph for this function:

◆ GetFunc() [3/3]

C4AulFunc * C4PropList::GetFunc ( const char *  k) const
inherited

Definition at line 786 of file C4PropList.cpp.

787 {
788  assert(s);
789  if (s[0] == '~') ++s;
790  C4String * k = Strings.FindString(s);
791  // this string is entirely unused
792  if (!k)
793  return nullptr;
794  return GetFunc(k);
795 }
C4String * FindString(const char *strString) const

References C4StringTable::FindString(), C4PropList::GetFunc(), s, and Strings.

Here is the call graph for this function:

◆ GetFunctionNames()

std::list< const char * > C4AulScriptEngine::GetFunctionNames ( C4PropList p)

Definition at line 201 of file C4Aul.cpp.

202 {
203  std::list<const char*> functions;
204  std::list<const char*> global_functions;
205  auto sort_alpha = [](const char * const &a, const char * const &b) -> bool { return strcmp(a, b) < 0; };
206  if (!p) p = GetPropList();
207  const C4ValueArray * a = p->GetProperties();
208  for (int i = 0; i < a->GetSize(); ++i)
209  {
210  C4String * key = (*a)[i].getStr();
211  if (!key) continue;
212  C4AulFunc * f = p->GetFunc(key);
213  if (!f) continue;
214  if (!f->GetPublic()) continue;
215  if (!::ScriptEngine.GetPropList()->HasProperty(key))
216  functions.push_back(key->GetCStr());
217  else
218  global_functions.push_back(key->GetCStr());
219  }
220  delete a;
221  functions.sort(sort_alpha);
222  if (!functions.empty() && !global_functions.empty()) functions.push_back(nullptr); // separator
223  global_functions.sort(sort_alpha);
224  functions.splice(functions.end(), global_functions);
225  return functions;
226 }
#define a
#define b
virtual bool GetPublic() const
Definition: C4AulFunc.h:68
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:883
bool HasProperty(C4String *k) const
Definition: C4PropList.h:122
const char * GetCStr() const
Definition: C4StringTable.h:49

References a, b, C4String::GetCStr(), C4PropList::GetFunc(), C4PropList::GetProperties(), GetPropList(), C4AulFunc::GetPublic(), C4PropList::HasProperty(), and ScriptEngine.

Referenced by C4Console::GetScriptSuggestions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGlobalConstant()

bool C4AulScriptEngine::GetGlobalConstant ( const char *  szName,
C4Value pTargetValue 
)

Definition at line 133 of file C4Aul.cpp.

134 {
135  // get index of global by name
136  int32_t iConstIndex = GlobalConstNames.GetItemNr(szName);
137  // not found?
138  if (iConstIndex<0) return false;
139  // if it's found, assign the value if desired
140  if (pTargetValue) *pTargetValue = GlobalConsts[iConstIndex];
141  // constant exists
142  return true;
143 }
int32_t GetItemNr(const char *strName) const
Definition: C4ValueMap.cpp:459

References C4ValueMapNames::GetItemNr(), GlobalConstNames, and GlobalConsts.

Referenced by C4Effect::CompileFunc(), C4Value::CompileFunc(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMapScriptLayer()

class C4MapScriptLayer * C4PropList::GetMapScriptLayer ( )
virtualinherited

Reimplemented in C4MapScriptLayer.

Definition at line 660 of file C4PropList.cpp.

661 {
662  if (GetPrototype()) return GetPrototype()->GetMapScriptLayer();
663  return nullptr;
664 }
virtual class C4MapScriptLayer * GetMapScriptLayer()
Definition: C4PropList.cpp:660

References C4PropList::GetMapScriptLayer(), and C4PropList::GetPrototype().

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), and C4PropList::GetMapScriptLayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMapScriptMap()

class C4MapScriptMap * C4PropList::GetMapScriptMap ( )
virtualinherited

Reimplemented in C4MapScriptMap.

Definition at line 666 of file C4PropList.cpp.

667 {
668  if (GetPrototype()) return GetPrototype()->GetMapScriptMap();
669  return nullptr;
670 }
virtual class C4MapScriptMap * GetMapScriptMap()
Definition: C4PropList.cpp:666

References C4PropList::GetMapScriptMap(), and C4PropList::GetPrototype().

Referenced by C4PropList::GetMapScriptMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetName()

const char * C4PropListStatic::GetName ( ) const
overridevirtualinherited

Reimplemented from C4PropList.

Definition at line 243 of file C4PropList.cpp.

244 {
245  const C4String * s = GetPropertyStr(P_Name);
246  if (!s) s = ParentKeyName;
247  if (!s) return "";
248  return s->GetCStr();
249 }
@ P_Name
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:744

References C4PropList::GetPropertyStr(), P_Name, C4PropListStatic::ParentKeyName, and s.

Referenced by C4MainMenu::ActivateGoals(), C4MainMenu::ActivateRules(), C4Object::AssignRemoval(), C4DefGraphicsAdapt::CompileFunc(), ConstructionCheck(), C4ObjectInfoCore::Default(), C4Command::Fail(), C4GameParameters::GetGameGoalString(), C4ObjectList::GetNameList(), C4Def::LoadDefCore(), C4DefScriptHost::Parse(), and C4EditCursor::UpdateStatusBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextSNFunc()

C4AulFunc* C4AulScriptEngine::GetNextSNFunc ( const C4AulFunc After)
inlineprotected

Definition at line 119 of file C4Aul.h.

120  { return FuncLookUp.GetNextSNFunc(After); }
C4AulFunc * GetNextSNFunc(const C4AulFunc *After)
Definition: C4Aul.cpp:306

References C4AulFuncMap::GetNextSNFunc().

Here is the call graph for this function:

◆ GetObject() [1/2]

C4Object * C4PropList::GetObject ( )
virtualinherited

Reimplemented in C4Object.

Definition at line 636 of file C4PropList.cpp.

637 {
638  if (GetPrototype()) return GetPrototype()->GetObject();
639  return nullptr;
640 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:636

References C4PropList::GetObject(), and C4PropList::GetPrototype().

Referenced by C4Value::_getObj(), C4EditCursor::AddToSelection(), C4PropertyPath::C4PropertyPath(), C4ScriptGuiWindowAction::ClearPointers(), C4GameMessage::Draw(), C4ScriptGuiWindowAction::ExecuteCommand(), FnGetEffectsFor(), C4Value::getObj(), C4PropList::GetObject(), C4GameMessage::Init(), Object(), C4EditCursor::RemoveFromSelection(), and C4ScriptGuiWindowProperty::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetObject() [2/2]

C4Object const * C4PropList::GetObject ( ) const
virtualinherited

Reimplemented in C4Object.

Definition at line 642 of file C4PropList.cpp.

643 {
644  if (GetPrototype()) return GetPrototype()->GetObject();
645  return nullptr;
646 }

References C4PropList::GetObject(), and C4PropList::GetPrototype().

Here is the call graph for this function:

◆ GetParent()

const C4PropListStatic* C4PropListStatic::GetParent ( ) const
inlineinherited

Definition at line 275 of file C4PropList.h.

275 { return Parent; }

References C4PropListStatic::Parent.

Referenced by C4ScriptHost::CopyPropList(), C4PropList::FreezeAndMakeStaticRecursively(), and C4Value::ToJSON().

Here is the caller graph for this function:

◆ GetParentKeyName()

C4String* C4PropListStatic::GetParentKeyName ( )
inlineinherited

Definition at line 276 of file C4PropList.h.

276 { return ParentKeyName; }

References C4PropListStatic::ParentKeyName.

Referenced by C4PropList::FreezeAndMakeStaticRecursively().

Here is the caller graph for this function:

◆ GetProperties()

C4ValueArray * C4PropList::GetProperties ( ) const
virtualinherited

Reimplemented in C4Effect, and C4Object.

Definition at line 883 of file C4PropList.cpp.

884 {
885  C4ValueArray * a;
886  int i = 0;
887  const bool hasInheritedProperties = GetPrototype() != nullptr;
888  if (hasInheritedProperties)
889  {
891  i = a->GetSize();
892  a->SetSize(i + Properties.GetSize());
893  }
894  else
895  {
896  a = new C4ValueArray(Properties.GetSize());
897  i = 0;
898  }
899  const C4Property * p = Properties.First();
900  while (p)
901  {
902  C4String *newPropertyName = p->Key;
903  assert(newPropertyName != nullptr && "Proplist key is nullpointer");
904  // Do we need to check for duplicate property names?
905  bool skipProperty = false;
906  if (hasInheritedProperties)
907  {
908  for (size_t j = 0; j < i; ++j)
909  {
910  if ((*a)[j].getStr() != newPropertyName) continue;
911  skipProperty = true;
912  break;
913  }
914  }
915  if (!skipProperty)
916  {
917  (*a)[i++] = C4VString(newPropertyName);
918  assert(((*a)[i - 1].GetType() == C4V_String) && "Proplist key is non-string");
919  }
920  p = Properties.Next(p);
921  }
922  // We might have added less properties than initially intended.
923  if (hasInheritedProperties)
924  a->SetSize(i);
925  return a;
926 }
@ C4V_String
Definition: C4Value.h:29
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:243

References a, C4V_String, C4VString(), C4Set< T >::First(), C4PropList::GetProperties(), C4PropList::GetPrototype(), C4Set< T >::GetSize(), C4Property::Key, and C4Set< T >::Next().

Referenced by C4ScriptGuiWindow::CreateFromPropList(), GetFunctionNames(), C4PropList::GetProperties(), C4Object::GetProperties(), C4Effect::GetProperties(), and C4ScriptGuiWindowProperty::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProperty()

bool C4PropList::GetProperty ( C4PropertyName  k,
C4Value pResult 
) const
inlineinherited

◆ GetPropertyArray()

C4ValueArray * C4PropList::GetPropertyArray ( C4PropertyName  n) const
inherited

Definition at line 758 of file C4PropList.cpp.

759 {
760  C4String * k = &Strings.P[n];
761  if (Properties.Has(k))
762  {
763  return Properties.Get(k).Value.getArray();
764  }
765  if (GetPrototype())
766  {
767  return GetPrototype()->GetPropertyArray(n);
768  }
769  return nullptr;
770 }
C4ValueArray * GetPropertyArray(C4PropertyName n) const
Definition: C4PropList.cpp:758
C4ValueArray * getArray() const
Definition: C4Value.h:118

References C4Set< T >::Get(), C4Value::getArray(), C4PropList::GetPropertyArray(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4EditCursor::DoContextMenu(), C4PropList::GetPropertyArray(), and C4FoWLight::Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyBool()

int32_t C4PropList::GetPropertyBool ( C4PropertyName  n,
bool  default_val = false 
) const
inherited

Definition at line 841 of file C4PropList.cpp.

842 {
843  C4String * k = &Strings.P[n];
844  if (Properties.Has(k))
845  {
846  return Properties.Get(k).Value.getBool();
847  }
848  if (GetPrototype())
849  {
850  return GetPrototype()->GetPropertyBool(n, default_val);
851  }
852  return default_val;
853 }
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:841
bool getBool() const
Definition: C4Value.h:113

References C4Set< T >::Get(), C4Value::getBool(), C4PropList::GetPropertyBool(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4Object::ExecLife(), and C4PropList::GetPropertyBool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyByS()

bool C4PropList::GetPropertyByS ( const C4String k,
C4Value pResult 
) const
virtualinherited

Reimplemented in C4Effect, and C4Object.

Definition at line 726 of file C4PropList.cpp.

727 {
728  if (Properties.Has(k))
729  {
730  *pResult = Properties.Get(k).Value;
731  return true;
732  }
733  else if (k == &Strings.P[P_Prototype])
734  {
735  *pResult = prototype;
736  return true;
737  }
738  else if(GetPrototype())
739  return GetPrototype()->GetPropertyByS(k, pResult);
740  else
741  return false;
742 }

References C4Set< T >::Get(), C4PropList::GetPropertyByS(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, P_Prototype, Strings, and C4Property::Value.

Referenced by C4Value::CompileFunc(), C4ScriptGuiWindow::CreateFromPropList(), C4PropList::FreezeAndMakeStaticRecursively(), C4Def::GetActionByName(), C4DefList::GetAllDefs(), C4PropList::GetProperty(), C4PropList::GetPropertyByS(), C4Object::GetPropertyByS(), C4Effect::GetPropertyByS(), C4Game::GetTranslatedString(), C4ValueArraySortPropertycomp::operator()(), C4ScriptGuiWindowProperty::Set(), C4Object::SetActionByName(), C4PropList::ThawRecursively(), C4ScriptHost::UnlinkOwnedFunctions(), C4GraphicsOverlay::UpdateFacet(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyInt()

int32_t C4PropList::GetPropertyInt ( C4PropertyName  k,
int32_t  default_val = 0 
) const
inherited

Definition at line 855 of file C4PropList.cpp.

856 {
857  C4String * k = &Strings.P[n];
858  if (Properties.Has(k))
859  {
860  return Properties.Get(k).Value.getInt();
861  }
862  if (GetPrototype())
863  {
864  return GetPrototype()->GetPropertyInt(n, default_val);
865  }
866  return default_val;
867 }
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:855
int32_t getInt() const
Definition: C4Value.h:112

References C4Set< T >::Get(), C4Value::getInt(), C4PropList::GetPropertyInt(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MouseControl::ButtonUpDragScript(), C4MapScriptAlgoEllipse::C4MapScriptAlgoEllipse(), C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4MapScriptAlgoOffset::C4MapScriptAlgoOffset(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRect::C4MapScriptAlgoRect(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MapScriptAlgoScale::C4MapScriptAlgoScale(), C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(), C4Object::Contact(), C4Object::ContactAction(), C4Object::DoBreath(), C4Object::DoEnergy(), C4MouseControl::DragNone(), C4Object::Draw(), C4Object::DrawActionFace(), C4Game::DrawPropListSpecImage(), C4Object::DrawTopFace(), C4Command::Enter(), C4Object::ExecLife(), C4Object::ExecMovement(), C4ValueProviderAction::Execute(), C4Command::Exit(), C4Command::FlightControl(), C4SoundModifierList::Get(), C4SoundModifier::GetBoolProp(), C4SoundModifier::GetFloatProp(), C4Def::GetPlane(), C4PropList::GetPropertyInt(), C4Object::GetSolidMaskPlane(), C4Object::Init(), C4Object::IsVisible(), C4Command::MoveTo(), ObjectActionThrow(), ObjectComDrop(), ObjectComJump(), C4Game::PlaceAnimal(), C4Game::PlaceVegetation(), C4Object::Push(), C4Command::Put(), C4Object::ResetProperty(), C4Object::SetAction(), C4Object::SetDir(), C4Object::SetOCF(), C4Object::SetPhase(), C4Object::SideBounds(), C4Command::Throw(), C4Object::UpdateActionFace(), C4MouseControl::UpdateCursorTarget(), C4GraphicsOverlay::UpdateFacet(), C4Object::UpdateFlipDir(), C4Object::UpdateOCF(), and C4Object::VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyP()

C4PropertyName C4PropList::GetPropertyP ( C4PropertyName  k) const
inherited

Definition at line 824 of file C4PropList.cpp.

825 {
826  C4String * k = &Strings.P[n];
827  if (Properties.Has(k))
828  {
829  C4String * v = Properties.Get(k).Value.getStr();
830  if (v >= &Strings.P[0] && v < &Strings.P[P_LAST])
831  return C4PropertyName(v - &Strings.P[0]);
832  return P_LAST;
833  }
834  if (GetPrototype())
835  {
836  return GetPrototype()->GetPropertyP(n);
837  }
838  return P_LAST;
839 }
C4PropertyName
@ P_LAST
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:824
C4String * getStr() const
Definition: C4Value.h:117

References C4Set< T >::Get(), C4PropList::GetPropertyP(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, P_LAST, Strings, and C4Property::Value.

Referenced by C4Object::ContactAction(), C4GameObjects::CrossCheck(), C4Object::ExecMovement(), C4Object::GetProcedure(), C4PropList::GetPropertyP(), ObjectComDrop(), C4Object::SetAction(), C4Object::SideBounds(), and C4Object::VerticalBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyPropList()

C4PropList * C4PropList::GetPropertyPropList ( C4PropertyName  k) const
inherited

Definition at line 869 of file C4PropList.cpp.

870 {
871  C4String * k = &Strings.P[n];
872  if (Properties.Has(k))
873  {
874  return Properties.Get(k).Value.getPropList();
875  }
876  if (GetPrototype())
877  {
878  return GetPrototype()->GetPropertyPropList(n);
879  }
880  return nullptr;
881 }
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:869

References C4Set< T >::Get(), C4PropList::GetPropertyPropList(), C4Value::getPropList(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4MapScriptAlgoLayer::C4MapScriptAlgoLayer(), C4Game::DrawPropListSpecImage(), C4PropList::GetPropertyPropList(), and C4GameMessage::Init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropertyStr()

C4String * C4PropList::GetPropertyStr ( C4PropertyName  k) const
inherited

Definition at line 744 of file C4PropList.cpp.

745 {
746  C4String * k = &Strings.P[n];
747  if (Properties.Has(k))
748  {
749  return Properties.Get(k).Value.getStr();
750  }
751  if (GetPrototype())
752  {
753  return GetPrototype()->GetPropertyStr(n);
754  }
755  return nullptr;
756 }

References C4Set< T >::Get(), C4PropList::GetPropertyStr(), C4PropList::GetPrototype(), C4Value::getStr(), C4Set< T >::Has(), C4StringTable::P, Strings, and C4Property::Value.

Referenced by C4Game::DrawPropListSpecImage(), C4Object::ExecAction(), C4PropList::GetName(), C4PropListStatic::GetName(), C4PropList::GetPropertyStr(), C4Game::GetTranslatedString(), C4Object::SetAction(), C4Object::SetDir(), C4MouseControl::UpdateCursorTarget(), and C4GraphicsOverlay::UpdateFacet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPropList()

◆ GetPropListNumbered()

C4PropListNumbered * C4PropList::GetPropListNumbered ( )
virtualinherited

Reimplemented in C4PropListNumbered.

Definition at line 672 of file C4PropList.cpp.

673 {
674  if (GetPrototype()) return GetPrototype()->GetPropListNumbered();
675  return nullptr;
676 }
virtual C4PropListNumbered * GetPropListNumbered()
Definition: C4PropList.cpp:672

References C4PropList::GetPropListNumbered(), and C4PropList::GetPrototype().

Referenced by C4Effect::CompileFunc(), C4Value::CompileFunc(), C4AulExec::DirectExec(), and C4PropList::GetPropListNumbered().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPrototype()

◆ GetSortedLocalProperties() [1/2]

std::vector< C4String * > C4PropList::GetSortedLocalProperties ( bool  add_prototype = true) const
inherited

Definition at line 545 of file C4PropList.cpp.

546 {
547  // return property list without descending into prototype
548  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
549  std::vector< C4String * > result;
550  result.reserve(sorted_props.size() + add_prototype);
551  if (add_prototype) result.push_back(&::Strings.P[P_Prototype]); // implicit prototype for every prop list
552  for (auto p : sorted_props) result.push_back(p->Key);
553  return result;
554 }

References C4Set< T >::GetSortedListOfElementPointers(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::FreezeAndMakeStaticRecursively(), and C4Game::GetTranslatedString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSortedLocalProperties() [2/2]

std::vector< C4String * > C4PropList::GetSortedLocalProperties ( const char *  prefix,
const C4PropList ignore_overridden 
) const
inherited

Definition at line 556 of file C4PropList.cpp.

557 {
558  // return property list without descending into prototype
559  // ignore properties that have been overridden by proplist given in ignore_overridden or any of its prototypes up to and excluding this
560  std::vector< C4String * > result;
561  for (const C4Property *pp = Properties.First(); pp; pp = Properties.Next(pp))
562  if (pp->Key != &::Strings.P[P_Prototype])
563  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
564  {
565  // Override check
566  const C4PropList *check = ignore_overridden;
567  bool overridden = false;
568  if (check && check != this)
569  {
570  if (check->HasProperty(pp->Key)) { overridden = true; break; }
571  check = check->GetPrototype();
572  }
573  result.push_back(pp->Key);
574  }
575  // Sort
576  std::sort(result.begin(), result.end(), [](const C4String *a, const C4String *b) -> bool
577  {
578  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
579  });
580  return result;
581 }

References a, b, C4Set< T >::First(), C4PropList::GetPrototype(), C4PropList::HasProperty(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

Here is the call graph for this function:

◆ GetSortedProperties()

std::vector< C4String * > C4PropList::GetSortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 601 of file C4PropList.cpp.

602 {
603  struct sort_cmp {
604  bool operator() (const C4String *a, const C4String *b) const
605  {
606  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
607  }
608  };
609  // Return property list with descending into prototype
610  // But do not include Prototype property
611  std::vector< C4String * > result = GetUnsortedProperties(prefix, ignore_parent);
612  // Sort and remove duplicates
613  std::set< C4String *, sort_cmp > result_set(result.begin(), result.end());
614  result.assign(result_set.begin(), result_set.end());
615  return result;
616 }
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:583

References a, b, and C4PropList::GetUnsortedProperties().

Here is the call graph for this function:

◆ GetUnsortedProperties()

std::vector< C4String * > C4PropList::GetUnsortedProperties ( const char *  prefix,
C4PropList ignore_parent = nullptr 
) const
inherited

Definition at line 583 of file C4PropList.cpp.

584 {
585  // Return property list with descending into prototype
586  // But do not include Prototype property
587  std::vector< C4String * > result;
588  const C4PropList *p = this;
589  do
590  {
591  for (const C4Property *pp = p->Properties.First(); pp; pp = p->Properties.Next(pp))
592  if (pp->Key != &::Strings.P[P_Prototype])
593  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
594  result.push_back(pp->Key);
595  p = p->GetPrototype();
596  if (p == ignore_parent) break;
597  } while (p);
598  return result;
599 }

References C4Set< T >::First(), C4PropList::GetPrototype(), C4Set< T >::Next(), C4StringTable::P, P_Prototype, and Strings.

Referenced by C4PropList::GetSortedProperties(), and C4PropList::ThawRecursively().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetUserFile()

C4AulUserFile * C4AulScriptEngine::GetUserFile ( int32_t  handle)

Definition at line 252 of file C4Aul.cpp.

253 {
254  // get user file given by handle
255  for (auto & UserFile : UserFiles)
256  if (UserFile.GetHandle() == handle)
257  {
258  return &UserFile;
259  }
260  // not found
261  return nullptr;
262 }

References UserFiles.

Referenced by C4EditCursor::PerformDuplication(), and C4Game::SaveData().

Here is the caller graph for this function:

◆ HasProperty()

bool C4PropList::HasProperty ( C4String k) const
inlineinherited

Definition at line 122 of file C4PropList.h.

122 { return Properties.Has(k); }

References C4Set< T >::Has().

Referenced by GetFunctionNames(), C4PropList::GetSortedLocalProperties(), C4MapScriptAlgo::GetXYProps(), and C4AulCompiler::ConstantResolver::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsFrozen()

bool C4PropList::IsFrozen ( ) const
inlineinherited

Definition at line 135 of file C4PropList.h.

135 { return constant; }

Referenced by C4PropList::ThawRecursively().

Here is the caller graph for this function:

◆ IsNumbered()

virtual bool C4PropList::IsNumbered ( ) const
inlinevirtualinherited

Reimplemented in C4PropListNumbered.

Definition at line 92 of file C4PropList.h.

92 { return false; }

Referenced by C4Value::Denumerate(), and C4PropList::operator==().

Here is the caller graph for this function:

◆ IsStatic() [1/2]

const class C4PropListStatic* C4PropList::IsStatic ( ) const
inlineinherited

Definition at line 90 of file C4PropList.h.

90 { return const_cast<C4PropList*>(this)->IsStatic(); }

References C4PropList::IsStatic().

Referenced by C4PropList::IsStatic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsStatic() [2/2]

C4PropListStatic* C4PropListStatic::IsStatic ( )
inlineoverridevirtualinherited

Reimplemented from C4PropList.

Definition at line 271 of file C4PropList.h.

271 { return this; }

Referenced by C4AulCompiler::ConstantResolver::visit().

Here is the caller graph for this function:

◆ Link()

void C4AulScriptEngine::Link ( C4DefList rDefs)

Definition at line 165 of file C4AulLink.cpp.

166 {
167  try
168  {
169  // resolve appends
170  for (C4ScriptHost *s = Child0; s; s = s->Next)
171  s->ResolveAppends(rDefs);
172 
173  // resolve includes
174  for (C4ScriptHost *s = Child0; s; s = s->Next)
175  s->ResolveIncludes(rDefs);
176 
177  // parse the scripts to byte code
178  for (C4ScriptHost *s = Child0; s; s = s->Next)
179  s->Parse();
180 
181  if (rDefs)
182  {
183  rDefs->SortByPriority();
184  rDefs->CallEveryDefinition();
185  }
186 
187  // Done modifying the proplists now
188  for (C4ScriptHost *s = Child0; s; s = s->Next)
189  s->GetPropList()->FreezeAndMakeStaticRecursively(&s->ownedPropLists);
190 
192  }
193  catch (C4AulError &err)
194  {
195  // error??! show it!
196  ErrorHandler->OnError(err.what());
197  }
198 
199  // Set name list for globals (FIXME: is this necessary?)
201 }
const char * what() const noexcept override
Definition: C4Aul.cpp:59
void SortByPriority()
Definition: stub-handle.cpp:76
void CallEveryDefinition()
Definition: stub-handle.cpp:77

References C4DefList::CallEveryDefinition(), Child0, ErrorHandler, C4PropList::FreezeAndMakeStaticRecursively(), GetPropList(), GlobalNamed, GlobalNamedNames, C4AulErrorHandler::OnError(), OwnedPropLists, s, ScriptEngine, C4ValueMapData::SetNameList(), C4DefList::SortByPriority(), and C4AulError::what().

Referenced by c4_mapgen_handle_new(), c4_mapgen_handle_new_script(), C4Game::LinkScriptEngine(), and ReLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ New()

C4PropList * C4PropList::New ( C4PropList prototype = nullptr)
staticinherited

Definition at line 40 of file C4PropList.cpp.

41 {
42  C4PropList * r = new C4PropListScript(prototype);
43  return r;
44 }

Referenced by CompileNewFunc(), FnPlaceVegetation(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the caller graph for this function:

◆ NewStatic()

C4PropListStatic * C4PropList::NewStatic ( C4PropList prototype,
const C4PropListStatic parent,
C4String key 
)
staticinherited

Definition at line 46 of file C4PropList.cpp.

47 {
48  return new C4PropListStatic(prototype, parent, key);
49 }

Referenced by C4PropListScen::C4PropListScen(), C4ScriptHost::CopyPropList(), C4PropList::FreezeAndMakeStaticRecursively(), C4ScenarioParameterDefs::RegisterScriptConstants(), and C4AulCompiler::ConstexprEvaluator::visit().

Here is the caller graph for this function:

◆ operator==()

bool C4PropList::operator== ( const C4PropList b) const
inherited

Definition at line 348 of file C4PropList.cpp.

349 {
350  // every numbered proplist has a unique number and is only identical to itself
351  if (this == &b) return true;
352  if (IsNumbered() || b.IsNumbered()) return false;
353  if (Properties.GetSize() != b.Properties.GetSize()) return false;
354  if (GetDef() != b.GetDef()) return false;
355  const C4Property * p = Properties.First();
356  while (p)
357  {
358  const C4Property & bp = b.Properties.Get(p->Key);
359  if (!bp) return false;
360  if (p->Value != bp.Value) return false;
361  p = Properties.Next(p);
362  }
363  return true;
364 }
virtual bool IsNumbered() const
Definition: C4PropList.h:92

References b, C4Set< T >::First(), C4PropList::GetDef(), C4Set< T >::GetSize(), C4PropList::IsNumbered(), C4Property::Key, C4Set< T >::Next(), and C4Property::Value.

Here is the call graph for this function:

◆ RefCompileFunc()

void C4PropListStatic::RefCompileFunc ( StdCompiler pComp,
C4ValueNumbers numbers 
) const
inherited

Definition at line 216 of file C4PropList.cpp.

217 {
218  assert(!pComp->isDeserializer());
219  if (Parent)
220  {
221  Parent->RefCompileFunc(pComp, numbers);
223  }
224  if (!ParentKeyName)
225  pComp->excCorrupt("C4PropListStatic::RefCompileFunc without ParentKeyName");
227 }
void RefCompileFunc(StdCompiler *pComp, C4ValueNumbers *numbers) const
Definition: C4PropList.cpp:216
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249

References StdCompiler::excCorrupt(), C4String::GetData(), StdCompiler::isDeserializer(), mkParAdapt(), C4PropListStatic::Parent, C4PropListStatic::ParentKeyName, StdCompiler::RCT_ID, C4PropListStatic::RefCompileFunc(), StdCompiler::SEP_PART, StdCompiler::Separator(), and StdCompiler::Value().

Referenced by C4Effect::CompileFunc(), C4Value::CompileFunc(), and C4PropListStatic::RefCompileFunc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterErrorHandler()

void C4AulScriptEngine::RegisterErrorHandler ( C4AulErrorHandler handler)

Definition at line 264 of file C4Aul.cpp.

265 {
266  assert(ErrorHandler == &DefaultErrorHandler);
267  ErrorHandler = handler;
268 }

References ErrorHandler.

◆ RegisterGlobalConstant()

void C4AulScriptEngine::RegisterGlobalConstant ( const char *  szName,
const C4Value rValue 
)

Definition at line 123 of file C4Aul.cpp.

124 {
125  // Register name and set value.
126  // AddName returns the index of existing element if the name is assigned already.
127  // That is OK, since it will only change the value of the global ("overload" it).
128  // A warning would be nice here. However, this warning would show up whenever a script
129  // containing globals constants is recompiled.
130  GlobalConsts[GlobalConstNames.AddName(szName)] = rValue;
131 }
int32_t AddName(const char *pnName)
Definition: C4ValueMap.cpp:429

References C4ValueMapNames::AddName(), GlobalConstNames, and GlobalConsts.

Referenced by Clear(), C4PlayerControlDefs::FinalInit(), InitCoreFunctionMap(), C4MapScriptHost::InitFunctionMap(), InitGameFunctionMap(), InitObjectFunctionMap(), C4Game::InitScriptEngine(), C4GameScriptHost::Load(), C4Def::Load(), C4GameScriptHost::LoadData(), and C4ScenarioParameterDefs::RegisterScriptConstants().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReLink()

void C4AulScriptEngine::ReLink ( C4DefList rDefs)

Definition at line 204 of file C4AulLink.cpp.

205 {
206  // unlink scripts
207  UnLink();
208 
209  // unlink defs
210  if (rDefs) rDefs->ResetIncludeDependencies();
211 
212  // re-link
213  Link(rDefs);
214 
215  // display state
216  LogF("C4AulScriptEngine linked - %d line%s, %d warning%s, %d error%s",
217  lineCnt, (lineCnt != 1 ? "s" : ""), warnCnt, (warnCnt != 1 ? "s" : ""), errCnt, (errCnt != 1 ? "s" : ""));
218 
219  // adjust global effects
222 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
void Link(C4DefList *rDefs)
Definition: C4AulLink.cpp:165
void ResetIncludeDependencies()
Definition: stub-handle.cpp:78
void ReAssignAllCallbackFunctions()
Definition: C4Effect.h:129

References errCnt, GameScript, lineCnt, Link(), LogF(), pGlobalEffects, C4GameScriptHost::pScenarioEffects, C4Effect::ReAssignAllCallbackFunctions(), C4DefList::ResetIncludeDependencies(), UnLink(), and warnCnt.

Referenced by C4Game::ReLinkScriptEngine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReloadScript()

bool C4AulScriptEngine::ReloadScript ( const char *  szScript,
const char *  szLanguage 
)

Definition at line 224 of file C4AulLink.cpp.

225 {
226  C4ScriptHost * s;
227  for (s = Child0; s; s = s->Next)
228  if (s->ReloadScript(szScript, szLanguage))
229  break;
230  return !!s;
231 }

References Child0, and s.

Referenced by C4Game::ReloadFile().

Here is the caller graph for this function:

◆ RemoveCyclicPrototypes()

void C4PropList::RemoveCyclicPrototypes ( )
inherited

Definition at line 399 of file C4PropList.cpp.

400 {
401  // clear any cyclic prototype chains
402  // Use prototype.getPropList() instead of GetPrototype() because denumeration might not be completed yet
403  for(C4PropList * it = prototype.getPropList(); it; it = it->prototype.getPropList())
404  if(it == this)
405  {
406  prototype.Set0();
407  }
408 }
void Set0()
Definition: C4Value.h:332

References C4Value::getPropList(), and C4Value::Set0().

Referenced by C4PropList::Denumerate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetProperty()

void C4PropList::ResetProperty ( C4String k)
virtualinherited

Reimplemented in C4Effect, and C4Object.

Definition at line 961 of file C4PropList.cpp.

962 {
963  if (k == &Strings.P[P_Prototype])
964  prototype.Set0();
965  else
966  Properties.Remove(k);
967 }

References C4StringTable::P, P_Prototype, C4Set< T >::Remove(), C4Value::Set0(), and Strings.

Referenced by C4Object::ResetProperty(), C4Effect::ResetProperty(), C4PropList::SetName(), and C4ScriptHost::UnlinkOwnedFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetName()

void C4PropList::SetName ( const char *  NewName = nullptr)
virtualinherited

Reimplemented in C4Object.

Definition at line 625 of file C4PropList.cpp.

626 {
627  if (!NewName)
629  else
630  {
631  SetProperty(P_Name, C4VString(NewName));
632  }
633 }
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:961
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:124

References C4VString(), C4StringTable::P, P_Name, C4PropList::ResetProperty(), C4PropList::SetProperty(), and Strings.

Referenced by c4_mapgen_handle_set_map_library(), C4MapScriptHost::InitFunctionMap(), and C4Object::SetName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetOnFire()

virtual void C4PropList::SetOnFire ( bool  OnFire)
inlinevirtualinherited

Reimplemented in C4Object.

Definition at line 73 of file C4PropList.h.

73 { }

Referenced by C4Effect::ClearAll(), C4Effect::Init(), C4Effect::Kill(), C4Effect::TempReaddUpperEffects(), and C4Effect::TempRemoveUpperEffects().

Here is the caller graph for this function:

◆ SetProperty()

void C4PropList::SetProperty ( C4PropertyName  k,
const C4Value to 
)
inlineinherited

Definition at line 124 of file C4PropList.h.

125  { SetPropertyByS(&Strings.P[k], to); }
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:940

References C4StringTable::P, C4PropList::SetPropertyByS(), and Strings.

Referenced by C4Game::AllocateTranslatedString(), C4Effect::C4Effect(), C4Object::ChangeDef(), C4Object::Init(), C4DefScriptHost::Parse(), C4ScriptHost::Preparse(), C4Object::SetAction(), C4PropList::SetName(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnLink(), and C4MapScriptLayer::UpdateSurfaceSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPropertyByS()

void C4PropList::SetPropertyByS ( C4String k,
const C4Value to 
)
virtualinherited

Reimplemented in C4PropListScen, C4Effect, and C4Object.

Definition at line 940 of file C4PropList.cpp.

941 {
942  assert(!constant);
943  if (k == &Strings.P[P_Prototype])
944  {
945  C4PropList * newpt = to.getPropList();
946  for(C4PropList * it = newpt; it; it = it->GetPrototype())
947  if(it == this)
948  throw C4AulExecError("Trying to create cyclic prototype structure");
949  prototype.SetPropList(newpt);
950  }
951  else if (Properties.Has(k))
952  {
953  Properties.Get(k).Value = to;
954  }
955  else
956  {
957  Properties.Add(C4Property(k, to));
958  }
959 }
T * Add(T const &e)
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141

References C4Set< T >::Add(), C4Set< T >::Get(), C4Value::getPropList(), C4PropList::GetPrototype(), C4Set< T >::Has(), C4StringTable::P, P_Prototype, C4Value::SetPropList(), Strings, and C4Property::Value.

Referenced by C4AulDefFunc::C4AulDefFunc(), C4AulEngineFunc< RType, ThisType, ParTypes >::C4AulEngineFunc(), C4PropListScen::C4PropListScen(), C4ScriptHost::CopyPropList(), C4PropList::SetProperty(), C4Object::SetPropertyByS(), C4Effect::SetPropertyByS(), C4PropListScen::SetPropertyByS(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnlinkOwnedFunctions(), C4AulCompiler::PreparseAstVisitor::visit(), C4AulCompiler::ConstexprEvaluator::visit(), and C4AulCompiler::ConstantResolver::visit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Thaw()

void C4PropList::Thaw ( )
inlineinherited

Definition at line 133 of file C4PropList.h.

133 { constant = false; }

Referenced by C4PropList::ThawRecursively(), and C4ScriptHost::UnlinkOwnedFunctions().

Here is the caller graph for this function:

◆ ThawRecursively()

void C4PropList::ThawRecursively ( )
inherited

Definition at line 259 of file C4PropList.cpp.

260 {
261  //thaw self and all owned properties
262  Thaw();
263  //C4PropListStatic *s = IsStatic();
264  //if (s) LogF("Thaw: %s", s->GetDataString().getData());
265  auto prop_names = GetUnsortedProperties(nullptr, ::ScriptEngine.GetPropList());
266  for (auto prop_name : prop_names)
267  {
268  C4Value child_val;
269  GetPropertyByS(prop_name, &child_val);
270  //LogF(" %s=%s", prop_name->GetCStr(), child_val.GetDataString(1).getData());
271  C4PropList *child_proplist = child_val.getPropList();
272  if (child_proplist && child_proplist->IsFrozen())
273  {
274  child_proplist->ThawRecursively();
275  }
276  }
277 }
bool IsFrozen() const
Definition: C4PropList.h:135
void Thaw()
Definition: C4PropList.h:133
void ThawRecursively()
Definition: C4PropList.cpp:259

References C4PropList::GetPropertyByS(), GetPropList(), C4Value::getPropList(), C4PropList::GetUnsortedProperties(), C4PropList::IsFrozen(), ScriptEngine, C4PropList::Thaw(), and C4PropList::ThawRecursively().

Referenced by C4PropList::ThawRecursively(), and UnLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToJSON()

StdStrBuf C4PropList::ToJSON ( int  depth = 10,
bool  ignore_reference_parent = false 
) const
inherited

Definition at line 515 of file C4PropList.cpp.

516 {
517  if (depth <= 0 && Properties.GetSize())
518  {
519  throw new C4JSONSerializationError("maximum depth reached");
520  }
521  StdStrBuf DataString;
522  DataString = "{";
523  bool has_elements = false;
524  // Append prototype
525  if (prototype)
526  {
527  DataString.Append("Prototype:");
528  DataString.Append(prototype.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
529  has_elements = true;
530  }
531  // Append other properties
532  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
533  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
534  {
535  if (has_elements) DataString.Append(",");
536  DataString.Append(C4Value((*p)->Key).ToJSON());
537  DataString.Append(":");
538  DataString.Append((*p)->Value.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
539  has_elements = true;
540  }
541  DataString.Append("}");
542  return DataString;
543 }
StdStrBuf ToJSON(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:189

References StdStrBuf::Append(), C4PropList::begin(), C4PropList::C4Value, C4PropList::end(), C4Set< T >::GetSize(), C4Set< T >::GetSortedListOfElementPointers(), C4PropList::IsStatic(), and C4Value::ToJSON().

Referenced by C4Value::ToJSON().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnLink()

void C4AulScriptEngine::UnLink ( )

Definition at line 148 of file C4AulLink.cpp.

149 {
150  warnCnt = errCnt = lineCnt = 0;
151 
152  // Make everything writeable
154  for (C4ScriptHost *s = Child0; s; s = s->Next)
155  s->GetPropList()->ThawRecursively();
156 
157  // unlink scripts
158  for (C4ScriptHost *s = Child0; s; s = s->Next)
159  s->UnLink();
160  // Do not clear global variables and constants, because they are registered by the
161  // preparser or other parts. Note that keeping those fields means that you cannot delete a global
162  // variable or constant at runtime by removing it from the script.
163 }

References Child0, errCnt, GetPropList(), lineCnt, s, C4PropList::ThawRecursively(), and warnCnt.

Referenced by ReLink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnregisterErrorHandler()

void C4AulScriptEngine::UnregisterErrorHandler ( C4AulErrorHandler handler)

Definition at line 270 of file C4Aul.cpp.

271 {
272  assert(ErrorHandler == handler);
273  ErrorHandler = &DefaultErrorHandler;
274 }

References ErrorHandler.

Referenced by C4AulErrorHandler::~C4AulErrorHandler().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4AulCompiler

friend class C4AulCompiler
friend

Definition at line 182 of file C4Aul.h.

◆ C4AulDebug

friend class C4AulDebug
friend

Definition at line 183 of file C4Aul.h.

◆ C4AulFunc

friend class C4AulFunc
friend

Definition at line 178 of file C4Aul.h.

◆ C4AulParse

friend class C4AulParse
friend

Definition at line 181 of file C4Aul.h.

◆ C4AulProfiler

friend class C4AulProfiler
friend

Definition at line 179 of file C4Aul.h.

◆ C4ScriptHost

friend class C4ScriptHost
friend

Definition at line 180 of file C4Aul.h.

Member Data Documentation

◆ Child0

C4ScriptHost* C4AulScriptEngine::Child0
protected

Definition at line 121 of file C4Aul.h.

Referenced by Clear(), Link(), C4ScriptHost::Reg2List(), ReloadScript(), UnLink(), and C4ScriptHost::Unreg().

◆ ChildL

C4ScriptHost * C4AulScriptEngine::ChildL
protected

Definition at line 121 of file C4Aul.h.

Referenced by C4ScriptHost::Reg2List(), and C4ScriptHost::Unreg().

◆ errCnt

int C4AulScriptEngine::errCnt {0}

Definition at line 131 of file C4Aul.h.

Referenced by Clear(), C4Game::LinkScriptEngine(), C4AulParse::Parse_Script(), ReLink(), and UnLink().

◆ ErrorHandler

◆ FuncLookUp

C4AulFuncMap C4AulScriptEngine::FuncLookUp
protected

Definition at line 116 of file C4Aul.h.

Referenced by C4AulFunc::C4AulFunc(), and C4AulFunc::~C4AulFunc().

◆ GlobalConstNames

C4ValueMapNames C4AulScriptEngine::GlobalConstNames

Definition at line 141 of file C4Aul.h.

Referenced by Clear(), GetGlobalConstant(), and RegisterGlobalConstant().

◆ GlobalConsts

C4ValueMapData C4AulScriptEngine::GlobalConsts

Definition at line 142 of file C4Aul.h.

Referenced by Clear(), GetGlobalConstant(), and RegisterGlobalConstant().

◆ GlobalNamed

C4ValueMapData C4AulScriptEngine::GlobalNamed

Definition at line 135 of file C4Aul.h.

Referenced by Clear(), CompileFunc(), Denumerate(), and Link().

◆ GlobalNamedNames

C4ValueMapNames C4AulScriptEngine::GlobalNamedNames

Definition at line 134 of file C4Aul.h.

Referenced by Clear(), CompileFunc(), and Link().

◆ lineCnt

int C4AulScriptEngine::lineCnt {0}

Definition at line 132 of file C4Aul.h.

Referenced by Clear(), C4Game::LinkScriptEngine(), C4ScriptHost::Parse(), ReLink(), and UnLink().

◆ OwnedPropLists

std::vector<C4Value> C4AulScriptEngine::OwnedPropLists
protected

Definition at line 126 of file C4Aul.h.

Referenced by Clear(), and Link().

◆ Parent

const C4PropListStatic* C4PropListStatic::Parent
protectedinherited

◆ ParentKeyName

◆ pGlobalEffects

◆ Status

int32_t C4PropList::Status {1}
inherited

Definition at line 173 of file C4PropList.h.

Referenced by C4Command::Acquire(), C4Command::Activate(), C4GameObjects::Add(), C4ObjectList::Add(), C4FoW::Add(), C4EditCursor::AddToSelection(), C4Object::AssignDeath(), C4ObjectList::AssignInfo(), C4Object::AssignRemoval(), C4Object::At(), C4PropList::Call(), C4Game::CastObjects(), C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Effect::ClearAll(), C4ObjectList::ClearInfo(), C4Object::Collect(), C4ObjectList::CompileFunc(), C4Object::CompileFunc(), C4GameObjects::CrossCheck(), C4ObjectList::DeleteObjects(), C4ObjectList::Denumerate(), C4Landscape::P::DigMaterial2Objects(), C4Object::DirectComContents(), C4Effect::DoDamage(), C4Object::Draw(), C4Game::DrawCrewOverheadText(), C4Object::DrawSelectMark(), C4Object::DrawTopFace(), C4EditCursor::EMMoveObject(), C4Object::Enter(), C4Object::Execute(), C4SoundInstance::Execute(), C4Effect::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4ObjectList::Find(), C4FindObject::Find(), C4ObjectList::FindOther(), C4GameObjects::FixObjectOrder(), C4PropList::FreezeAndMakeStaticRecursively(), C4Object::GetArea(), C4EditCursor::GetCurrentSelectionPosition(), C4Object::GetEntranceArea(), C4Object::GetInfoString(), C4ObjectList::GetListID(), C4Object::GetMomentum(), C4ObjectList::GetObject(), C4Object::GrabInfo(), GrabLost(), C4GameObjects::GRBroadcast(), C4Effect::Init(), C4GameMessage::Init(), C4Object::IsMoveableBySolidMask(), C4GraphicsOverlay::IsValid(), C4Object::Lift(), C4Player::MakeCrewMember(), C4ObjectList::MassCount(), C4Object::MenuCommand(), C4GameMessageList::New(), C4Game::NewObject(), ObjectComGrab(), ObjectComUnGrab(), C4ObjectList::ObjectCount(), C4EditCursor::PerformDuplicationLegacy(), C4Landscape::P::PostFreeShape(), C4GameObjects::PostLoad(), C4Object::Push(), C4GameObjects::Remove(), C4EditCursor::RemoveFromSelection(), C4AulScriptContext::ReturnDump(), C4GameObjects::SafeObjectPointer(), C4Object::SetAction(), C4Object::SetGraphics(), C4GameObjects::SetOCF(), C4Object::SetOCF(), C4Object::StatusActivate(), C4Object::StatusDeactivate(), C4Effect::TempReaddUpperEffects(), C4Effect::TempRemoveUpperEffects(), C4ObjectList::UpdateFaces(), C4ObjectList::UpdateGraphics(), C4Object::UpdateOCF(), C4Object::UpdatePos(), C4Object::UpdateSolidMask(), C4GameObjects::UpdateSolidMasks(), C4ObjectList::ValidateOwners(), and C4ObjectList::Write().

◆ UserFiles

std::list<C4AulUserFile> C4AulScriptEngine::UserFiles
protected

Definition at line 125 of file C4Aul.h.

Referenced by Clear(), CloseUserFile(), CompileFunc(), CreateUserFile(), and GetUserFile().

◆ warnCnt

int C4AulScriptEngine::warnCnt {0}

Definition at line 131 of file C4Aul.h.

Referenced by Clear(), C4Game::LinkScriptEngine(), ReLink(), and UnLink().


The documentation for this class was generated from the following files: