OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PropList Class Reference

#include <C4PropList.h>

Inheritance diagram for C4PropList:
[legend]

Classes

class  Iterator
 

Public Member Functions

void Clear ()
 
virtual const char * GetName () const
 
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 class C4PropListStaticIsStatic ()
 
const class C4PropListStaticIsStatic () const
 
virtual bool IsNumbered () const
 
virtual bool Delete ()
 
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)
 
virtual void Denumerate (C4ValueNumbers *)
 
virtual ~C4PropList ()
 
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

int32_t Status {1}
 

Protected Member Functions

 C4PropList (C4PropList *prototype=nullptr)
 
void ClearRefs ()
 

Friends

class C4Value
 
class C4ScriptHost
 

Detailed Description

Definition at line 63 of file C4PropList.h.

Constructor & Destructor Documentation

C4PropList::~C4PropList ( )
virtual

Definition at line 362 of file C4PropList.cpp.

References C4V_Nil, and C4PropListNumbered::CheckPropList().

363 {
364  while (FirstRef)
365  {
366  // Manually kill references so DelRef doesn't destroy us again
367  FirstRef->Data = nullptr; FirstRef->Type = C4V_Nil;
368  C4Value *ref = FirstRef;
369  FirstRef = FirstRef->NextRef;
370  ref->NextRef = nullptr;
371  }
372 #ifdef _DEBUG
373  assert(PropLists.Has(this));
374  PropLists.Remove(this);
375 #endif
376  assert(!C4PropListNumbered::CheckPropList(this));
377 }
static bool CheckPropList(C4PropList *)
Definition: C4PropList.cpp:80

Here is the call graph for this function:

C4PropList::C4PropList ( C4PropList prototype = nullptr)
protected

Definition at line 275 of file C4PropList.cpp.

275  :
276  prototype(prototype)
277 {
278 #ifdef _DEBUG
279  PropLists.Add(this);
280 #endif
281 }

Member Function Documentation

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

Definition at line 518 of file C4PropList.cpp.

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

Referenced by C4Value::GetDataString(), and C4Object::GetDataString().

519 {
520  StdStrBuf & DataString = *out;
521  if (depth <= 0 && Properties.GetSize())
522  {
523  DataString.Append("...");
524  return;
525  }
526  bool has_elements = false;
527  // Append prototype
528  if (prototype)
529  {
530  DataString.Append("Prototype = ");
531  DataString.Append(prototype.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
532  has_elements = true;
533  }
534  // Append other properties
535  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
536  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
537  {
538  if (has_elements) DataString.Append(delim);
539  DataString.Append((*p)->Key->GetData());
540  DataString.Append(" = ");
541  DataString.Append((*p)->Value.GetDataString(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
542  has_elements = true;
543  }
544 }
std::list< const T * > GetSortedListOfElementPointers() const
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:131
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList::Iterator C4PropList::begin ( )

Definition at line 1003 of file C4PropList.cpp.

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

Referenced by begin(), and C4ParticleProperties::Set().

1004 {
1005  C4PropList::Iterator iter;
1006 
1007  if (GetPrototype())
1008  {
1009  iter = GetPrototype()->begin();
1010  }
1011  else
1012  {
1013  iter.properties = std::make_shared<std::vector<const C4Property*> >();
1014  }
1015  iter.Reserve(Properties.GetSize());
1016 
1017  const C4Property * p = Properties.First();
1018  while (p)
1019  {
1020  iter.AddProperty(p);
1021  p = Properties.Next(p);
1022  }
1023 
1024  iter.Init();
1025  return iter;
1026 }
T const * Next(T const *p) const
unsigned int GetSize() const
Iterator begin()
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 110 of file C4PropList.h.

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::ExecAction(), C4Object::ExecLife(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Object::ExecuteCommand(), C4Object::Exit(), C4Command::Fail(), C4Command::GetTryEnter(), C4Def::GetValue(), C4Object::GetValue(), GrabLost(), C4GameObjects::GRBroadcast(), C4Landscape::Incinerate(), C4Effect::Init(), C4Player::Init(), C4Game::InitGame(), C4ObjectMenu::IsCloseDenied(), C4Effect::Kill(), C4Object::Lift(), C4Player::MakeCrewMember(), C4Game::NewObject(), ObjectActionJump(), ObjectComGrab(), ObjectComPunch(), ObjectComPut(), ObjectComUnGrab(), C4ObjectMenu::OnSelectionChanged(), C4GameObjects::OnSynchronized(), C4EditCursor::PerformDuplication(), C4EditCursor::PerformDuplicationLegacy(), C4Player::PlaceReadyCrew(), 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().

111  { return Call(&Strings.P[k], pPars, fPassErrors); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value Call(C4PropertyName k, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4PropList.h:110

Here is the caller graph for this function:

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

Definition at line 824 of file C4PropList.cpp.

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

825 {
826  if (!Status) return C4Value();
827  C4AulFunc *pFn = GetFunc(k);
828  if (!pFn) return C4Value();
829  return pFn->Exec(this, Pars, fPassErrors);
830 }
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73
int32_t Status
Definition: C4PropList.h:168

Here is the call graph for this function:

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

Definition at line 832 of file C4PropList.cpp.

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

833 {
834  if (!Status) return C4Value();
835  assert(s && s[0]);
836  C4AulFunc *pFn = GetFunc(s);
837  if (!pFn)
838  {
839  if (s[0] != '~')
840  {
841  C4AulExecError err(FormatString("Undefined function: %s", s).getData());
842  if (fPassErrors)
843  throw err;
844  ::ScriptEngine.GetErrorHandler()->OnError(err.what());
845  }
846  return C4Value();
847  }
848  return pFn->Exec(this, Pars, fPassErrors);
849 }
C4AulErrorHandler * GetErrorHandler() const
Definition: C4Aul.h:173
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
friend class C4Value
Definition: C4PropList.h:165
C4Value Exec(C4PropList *p=nullptr, C4AulParSet *pPars=nullptr, bool fPassErrors=false)
Definition: C4AulFunc.h:73
int32_t Status
Definition: C4PropList.h:168
virtual void OnError(const char *msg)=0
#define s
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

void C4PropList::Clear ( )
inline

Definition at line 66 of file C4PropList.h.

References C4Set< T >::Clear(), and C4Value::Set0().

Referenced by C4ExtraScriptHost::Clear(), C4Def::Clear(), C4PropListNumbered::ClearNumberedPropLists(), C4ScriptHost::DeleteOwnedPropLists(), and C4Def::~C4Def().

66 { constant = false; Properties.Clear(); prototype.Set0(); }
void Set0()
Definition: C4Value.h:336
void Clear()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::ClearRefs ( )
inlineprotected

Definition at line 156 of file C4PropList.h.

References C4Value::Set0().

Referenced by C4Object::AssignRemoval().

156 { while (FirstRef) FirstRef->Set0(); }
void Set0()
Definition: C4Value.h:336

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 397 of file C4PropList.cpp.

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, C4Property::Value, and StdCompiler::Value().

Referenced by C4PropListNumbered::CompileFunc().

398 {
399  bool oldFormat = false;
400  // constant proplists are not serialized to savegames, but recreated from the game data instead
401  assert(!constant);
402  if (pComp->isDeserializer() && pComp->hasNaming())
403  {
404  // backwards compat to savegames and scenarios before 5.5
405  try
406  {
407  pComp->Value(constant);
408  oldFormat = true;
409  }
410  catch (StdCompiler::NotFoundException *pEx)
411  {
412  delete pEx;
413  pComp->Value(mkParAdapt(prototype, numbers));
414  }
415  }
416  else
417  pComp->Value(mkParAdapt(prototype, numbers));
419  pComp->Value(mkParAdapt(Properties, numbers));
420  if (oldFormat)
421  {
422  if (Properties.Has(&::Strings.P[P_Prototype]))
423  {
424  prototype = Properties.Get(&::Strings.P[P_Prototype]).Value;
425  Properties.Remove(&::Strings.P[P_Prototype]);
426  }
427  }
428 }
C4String P[P_LAST]
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:119
C4Value Value
Definition: C4PropList.h:55
virtual bool hasNaming()
Definition: StdCompiler.h:58
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
void Value(const T &rStruct)
Definition: StdCompiler.h:161
void Remove(H e)
virtual bool isDeserializer()
Definition: StdCompiler.h:53
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4PropList::Delete ( )
inlinevirtual

Reimplemented in C4PropListStaticMember, C4PropListStatic, C4PropListScript, and C4Def.

Definition at line 90 of file C4PropList.h.

Referenced by C4ScriptHost::DeleteOwnedPropLists().

90 { return false; }

Here is the caller graph for this function:

void C4PropList::Denumerate ( C4ValueNumbers numbers)
virtual

Reimplemented in C4Object, C4AulScriptEngine, and C4Effect.

Definition at line 350 of file C4PropList.cpp.

References C4Value::Denumerate(), C4Set< T >::First(), C4Set< T >::Next(), RemoveCyclicPrototypes(), and C4Property::Value.

Referenced by C4Value::Denumerate(), and C4Object::Denumerate().

351 {
352  const C4Property * p = Properties.First();
353  while (p)
354  {
355  const_cast<C4Value &>(p->Value).Denumerate(numbers);
356  p = Properties.Next(p);
357  }
358  prototype.Denumerate(numbers);
360 }
void RemoveCyclicPrototypes()
Definition: C4PropList.cpp:430
C4Value Value
Definition: C4PropList.h:55
virtual void Denumerate(C4ValueNumbers *)
Definition: C4PropList.cpp:350
void Denumerate(C4ValueNumbers *)
Definition: C4Value.cpp:251
T const * Next(T const *p) const
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

Iterator C4PropList::end ( )
inline

Definition at line 206 of file C4PropList.h.

Referenced by C4ParticleProperties::Set().

206 { return Iterator(); }

Here is the caller graph for this function:

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

Definition at line 936 of file C4PropList.cpp.

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

937 {
938  const C4Property * p = prev ? Properties.Next(&Properties.Get(prev)) : Properties.First();
939  while (p)
940  {
941  if (p->Value.getFunction())
942  return p->Key;
943  p = Properties.Next(p);
944  }
945  return nullptr;
946 }
C4Value Value
Definition: C4PropList.h:55
T & Get(H e) const
T const * Next(T const *p) const
C4String * Key
Definition: C4PropList.h:54
T const * First() const
C4AulFunc * getFunction() const
Definition: C4Value.h:119

Here is the call graph for this function:

void C4PropList::Freeze ( )
inline

Definition at line 128 of file C4PropList.h.

Referenced by FreezeAndMakeStaticRecursively().

128 { constant = true; }

Here is the caller graph for this function:

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

Definition at line 303 of file C4PropList.cpp.

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

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

304 {
305  Freeze();
306  // Already static?
307  C4PropListStatic *this_static = IsStatic();
308  if (!this_static)
309  {
310  // Make self static by creating a copy and replacing all references
311  this_static = NewStatic(GetPrototype(), parent, key);
312  this_static->Properties.Swap(&Properties); // grab properties
313  this_static->Status = Status;
314  C4Value holder = C4VPropList(this);
315  while (FirstRef && FirstRef->NextRef)
316  {
317  C4Value *ref = FirstRef;
318  if (ref == &holder) ref = ref->NextRef;
319  ref->SetPropList(this_static);
320  }
321  // store reference
322  if (prop_lists)
323  {
324  prop_lists->push_back(C4VPropList(this_static));
325  }
326  // "this" should be deleted as holder goes out of scope
327  }
328  // Iterate over sorted list of elements to make static
329  // Must iterate over sorted list because the order must be defined, just in case it's a network game
330  // and a non-static child proplist is available through different paths it should still get the same name
331  auto prop_names = this_static->GetSortedLocalProperties(false);
332  for (auto prop_name : prop_names)
333  {
334  C4Value child_val;
335  this_static->GetPropertyByS(prop_name, &child_val);
336  C4PropList *child_proplist = child_val.getPropList();
337  if (child_proplist)
338  {
339  // Avoid infinite recursion: Only freeze into unfrozen children and "true" static children
340  C4PropListStatic *child_static = child_proplist->IsStatic();
341  if (!child_static || (child_static->GetParent() == this_static && child_static->GetParentKeyName() == prop_name))
342  {
343  child_proplist->FreezeAndMakeStaticRecursively(prop_lists, this_static, prop_name);
344  }
345  }
346  }
347  return this_static;
348 }
C4PropListStatic * FreezeAndMakeStaticRecursively(std::vector< C4Value > *prop_lists, const C4PropListStatic *parent=nullptr, C4String *key=nullptr)
Definition: C4PropList.cpp:303
void Freeze()
Definition: C4PropList.h:128
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
C4String * GetParentKeyName()
Definition: C4PropList.h:271
std::vector< C4String * > GetSortedLocalProperties(bool add_prototype=true) const
Definition: C4PropList.cpp:576
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:753
C4Value C4VPropList(C4PropList *p)
Definition: C4Value.h:245
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
int32_t Status
Definition: C4PropList.h:168
static C4PropListStatic * NewStatic(C4PropList *prototype, const C4PropListStatic *parent, C4String *key)
Definition: C4PropList.cpp:70
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
const C4PropListStatic * GetParent() const
Definition: C4PropList.h:270
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

C4Def const * C4PropList::GetDef ( ) const
virtual

Reimplemented in C4Def.

Definition at line 681 of file C4PropList.cpp.

References GetDef(), and GetPrototype().

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

682 {
683  if (GetPrototype()) return GetPrototype()->GetDef();
684  return nullptr;
685 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:681
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

C4Def * C4PropList::GetDef ( )
virtual

Reimplemented in C4Def.

Definition at line 675 of file C4PropList.cpp.

References GetDef(), and GetPrototype().

676 {
677  if (GetPrototype()) return GetPrototype()->GetDef();
678  return nullptr;
679 }
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:681
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

C4Effect * C4PropList::GetEffect ( )
virtual

Reimplemented in C4Effect.

Definition at line 705 of file C4PropList.cpp.

References GetEffect(), and GetPrototype().

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

706 {
707  if (GetPrototype()) return GetPrototype()->GetEffect();
708  return nullptr;
709 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4Effect * GetEffect()
Definition: C4PropList.cpp:705

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 105 of file C4PropList.h.

References C4StringTable::P, and Strings.

Referenced by C4Effect::AssignCallbackFunctions(), Call(), C4Effect::CallDamage(), C4Value::CompileFunc(), C4ScriptHost::CopyPropList(), C4Effect::DoCall(), GetFunc(), C4Effect::Init(), C4MapScriptHost::InitializeMap(), C4Object::PutAwayUnusedObject(), C4MaterialReaction::ResolveScriptFuncs(), C4MCOverlay::SetField(), C4AulCompiler::PreparseAstVisitor::visit(), and C4AulCompiler::CodegenAstVisitor::visit().

106  { return GetFunc(&Strings.P[k]); }
C4String P[P_LAST]
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4StringTable Strings
Definition: C4Globals.cpp:42

Here is the caller graph for this function:

C4AulFunc * C4PropList::GetFunc ( C4String k) const

Definition at line 799 of file C4PropList.cpp.

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

800 {
801  assert(k);
802  if (Properties.Has(k))
803  {
804  return Properties.Get(k).Value.getFunction();
805  }
806  if (GetPrototype())
807  {
808  return GetPrototype()->GetFunc(k);
809  }
810  return nullptr;
811 }
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
T & Get(H e) const
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4AulFunc * getFunction() const
Definition: C4Value.h:119

Here is the call graph for this function:

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

Definition at line 813 of file C4PropList.cpp.

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

814 {
815  assert(s);
816  if (s[0] == '~') ++s;
817  C4String * k = Strings.FindString(s);
818  // this string is entirely unused
819  if (!k)
820  return nullptr;
821  return GetFunc(k);
822 }
C4String * FindString(const char *strString) const
C4AulFunc * GetFunc(C4PropertyName k) const
Definition: C4PropList.h:105
C4StringTable Strings
Definition: C4Globals.cpp:42
#define s

Here is the call graph for this function:

class C4MapScriptLayer * C4PropList::GetMapScriptLayer ( )
virtual

Reimplemented in C4MapScriptLayer.

Definition at line 687 of file C4PropList.cpp.

References GetMapScriptLayer(), and GetPrototype().

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

688 {
689  if (GetPrototype()) return GetPrototype()->GetMapScriptLayer();
690  return nullptr;
691 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual class C4MapScriptLayer * GetMapScriptLayer()
Definition: C4PropList.cpp:687

Here is the call graph for this function:

Here is the caller graph for this function:

class C4MapScriptMap * C4PropList::GetMapScriptMap ( )
virtual

Reimplemented in C4MapScriptMap.

Definition at line 693 of file C4PropList.cpp.

References GetMapScriptMap(), and GetPrototype().

Referenced by GetMapScriptMap().

694 {
695  if (GetPrototype()) return GetPrototype()->GetMapScriptMap();
696  return nullptr;
697 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual class C4MapScriptMap * GetMapScriptMap()
Definition: C4PropList.cpp:693

Here is the call graph for this function:

Here is the caller graph for this function:

const char * C4PropList::GetName ( ) const
virtual

Reimplemented in C4PropListStatic.

Definition at line 645 of file C4PropList.cpp.

References C4String::GetCStr(), GetPropertyStr(), P_Name, and s.

Referenced by C4Object::ActivateMenu(), C4Effect::AssignCallbackFunctions(), C4Effect::C4Effect(), C4PropertyPath::C4PropertyPath(), C4Object::CanConcatPictureWith(), C4FindObjectAction::Check(), C4Game::CheckObjectEnumeration(), C4Effect::ClearAll(), ConstructionCheck(), C4Effect::DoCall(), C4EditCursor::DoContextMenu(), C4ObjectMenu::DoRefillInternal(), C4Object::Draw(), C4ScriptGuiWindow::Draw(), C4Game::DrawCrewOverheadText(), C4Object::ExecLife(), C4Effect::Get(), C4Effect::GetCount(), C4Object::GetDataString(), C4Object::GetInfoString(), C4Effect::Init(), C4Effect::Kill(), C4Object::Lift(), C4Game::NewObject(), ObjectComDig(), C4Object::Promote(), C4Object::Push(), C4Object::SetAction(), C4Object::SetOCF(), C4Effect::TempRemoveUpperEffects(), C4Object::UpdateOCF(), and C4EditCursor::UpdateStatusBar().

646 {
648  if (!s) return "";
649  return s->GetCStr();
650 }
const char * GetCStr() const
Definition: C4StringTable.h:49
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:771
#define s

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object * C4PropList::GetObject ( )
virtual

Reimplemented in C4Object.

Definition at line 663 of file C4PropList.cpp.

References GetObject(), and GetPrototype().

Referenced by C4Value::_getObj(), C4EditCursor::AddToSelection(), C4PropertyPath::C4PropertyPath(), C4ScriptGuiWindowAction::ClearPointers(), ThisImpl< C4Object >::Conv(), C4GameMessage::Draw(), C4ScriptGuiWindowAction::ExecuteCommand(), FnGetEffectsFor(), C4Value::GetDataString(), C4Value::getObj(), GetObject(), C4GameMessage::Init(), Object(), C4GameObjects::ObjectPointer(), C4EditCursor::RemoveFromSelection(), and C4ScriptGuiWindowProperty::Set().

664 {
665  if (GetPrototype()) return GetPrototype()->GetObject();
666  return nullptr;
667 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:663
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

C4Object const * C4PropList::GetObject ( ) const
virtual

Reimplemented in C4Object.

Definition at line 669 of file C4PropList.cpp.

References GetObject(), and GetPrototype().

670 {
671  if (GetPrototype()) return GetPrototype()->GetObject();
672  return nullptr;
673 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:663
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

C4ValueArray * C4PropList::GetProperties ( ) const
virtual

Reimplemented in C4Object, and C4Effect.

Definition at line 910 of file C4PropList.cpp.

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

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

911 {
912  C4ValueArray * a;
913  int i;
914  if (GetPrototype())
915  {
916  a = GetPrototype()->GetProperties();
917  i = a->GetSize();
918  a->SetSize(i + Properties.GetSize());
919  }
920  else
921  {
922  a = new C4ValueArray(Properties.GetSize());
923  i = 0;
924  }
925  const C4Property * p = Properties.First();
926  while (p)
927  {
928  assert(p->Key != nullptr && "Proplist key is nullpointer");
929  (*a)[i++] = C4VString(p->Key);
930  assert(((*a)[i - 1].GetType() == C4V_String) && "Proplist key is non-string");
931  p = Properties.Next(p);
932  }
933  return a;
934 }
#define a
T const * Next(T const *p) const
unsigned int GetSize() const
virtual C4ValueArray * GetProperties() const
Definition: C4PropList.cpp:910
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
void SetSize(int32_t inSize)
int32_t GetSize() const
Definition: C4ValueArray.h:36
C4String * Key
Definition: C4PropList.h:54
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 101 of file C4PropList.h.

References GetPropertyByS(), C4StringTable::P, and Strings.

Referenced by C4MapScriptAlgoFilter::C4MapScriptAlgoFilter(), C4MapScriptAlgoModifier::C4MapScriptAlgoModifier(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4FindObjectProcedure::Check(), C4DefGraphics::Draw(), C4GraphicsOverlay::Draw(), C4Object::DrawFaceImpl(), C4Object::DrawLine(), C4Object::ExecAction(), C4Object::GetAction(), C4Def::GetActionByName(), C4Object::GetDragImage(), C4Object::GetParallaxity(), C4MapScriptAlgo::GetXYProps(), C4GameMessage::Init(), C4Object::IsVisible(), C4ScriptUniform::Push(), C4Object::SetAction(), C4Object::SetActionByName(), and C4GraphicsOverlay::UpdateFacet().

102  { return GetPropertyByS(&Strings.P[k], pResult); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:753

Here is the call graph for this function:

Here is the caller graph for this function:

C4ValueArray * C4PropList::GetPropertyArray ( C4PropertyName  n) const

Definition at line 785 of file C4PropList.cpp.

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

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

786 {
787  C4String * k = &Strings.P[n];
788  if (Properties.Has(k))
789  {
790  return Properties.Get(k).Value.getArray();
791  }
792  if (GetPrototype())
793  {
794  return GetPrototype()->GetPropertyArray(n);
795  }
796  return nullptr;
797 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4ValueArray * getArray() const
Definition: C4Value.h:118
C4ValueArray * GetPropertyArray(C4PropertyName n) const
Definition: C4PropList.cpp:785

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 868 of file C4PropList.cpp.

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

Referenced by GetPropertyBool().

869 {
870  C4String * k = &Strings.P[n];
871  if (Properties.Has(k))
872  {
873  return Properties.Get(k).Value.getBool();
874  }
875  if (GetPrototype())
876  {
877  return GetPrototype()->GetPropertyBool(n, default_val);
878  }
879  return default_val;
880 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
bool getBool() const
Definition: C4Value.h:113
int32_t GetPropertyBool(C4PropertyName n, bool default_val=false) const
Definition: C4PropList.cpp:868
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in C4Object, and C4Effect.

Definition at line 753 of file C4PropList.cpp.

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

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

754 {
755  if (Properties.Has(k))
756  {
757  *pResult = Properties.Get(k).Value;
758  return true;
759  }
760  else if (k == &Strings.P[P_Prototype])
761  {
762  *pResult = prototype;
763  return true;
764  }
765  else if(GetPrototype())
766  return GetPrototype()->GetPropertyByS(k, pResult);
767  else
768  return false;
769 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:753
C4PropList * GetPrototype() const
Definition: C4PropList.h:81

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 882 of file C4PropList.cpp.

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

Referenced by C4MouseControl::ButtonUpDragScript(), C4MapScriptAlgoEllipsis::C4MapScriptAlgoEllipsis(), C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4MapScriptAlgoOffset::C4MapScriptAlgoOffset(), C4MapScriptAlgoPolygon::C4MapScriptAlgoPolygon(), C4MapScriptAlgoRect::C4MapScriptAlgoRect(), C4MapScriptAlgoRndChecker::C4MapScriptAlgoRndChecker(), C4MapScriptAlgoRotate::C4MapScriptAlgoRotate(), C4MapScriptAlgoScale::C4MapScriptAlgoScale(), C4MapScriptAlgoTurbulence::C4MapScriptAlgoTurbulence(), C4Object::Contact(), C4Object::ContactAction(), C4Object::DoBreath(), C4Object::DoEnergy(), C4Object::DoMovement(), C4MouseControl::DragNone(), C4Object::Draw(), C4Object::DrawActionFace(), C4Game::DrawPropListSpecImage(), C4Object::DrawTopFace(), C4Command::Enter(), C4Object::ExecAction(), C4Object::ExecLife(), C4Object::ExecMovement(), C4ValueProviderAction::Execute(), C4Command::Exit(), C4Command::FlightControl(), FnParAlgo(), C4SoundModifierList::Get(), C4SoundModifier::GetBoolProp(), C4SoundModifier::GetFloatProp(), C4Def::GetPlane(), 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().

883 {
884  C4String * k = &Strings.P[n];
885  if (Properties.Has(k))
886  {
887  return Properties.Get(k).Value.getInt();
888  }
889  if (GetPrototype())
890  {
891  return GetPrototype()->GetPropertyInt(n, default_val);
892  }
893  return default_val;
894 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
int32_t getInt() const
Definition: C4Value.h:112
int32_t GetPropertyInt(C4PropertyName k, int32_t default_val=0) const
Definition: C4PropList.cpp:882

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropertyName C4PropList::GetPropertyP ( C4PropertyName  k) const

Definition at line 851 of file C4PropList.cpp.

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

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

852 {
853  C4String * k = &Strings.P[n];
854  if (Properties.Has(k))
855  {
856  C4String * v = Properties.Get(k).Value.getStr();
857  if (v >= &Strings.P[0] && v < &Strings.P[P_LAST])
858  return C4PropertyName(v - &Strings.P[0]);
859  return P_LAST;
860  }
861  if (GetPrototype())
862  {
863  return GetPrototype()->GetPropertyP(n);
864  }
865  return P_LAST;
866 }
C4PropertyName GetPropertyP(C4PropertyName k) const
Definition: C4PropList.cpp:851
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
C4String * getStr() const
Definition: C4Value.h:117
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4PropertyName

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList * C4PropList::GetPropertyPropList ( C4PropertyName  k) const

Definition at line 896 of file C4PropList.cpp.

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

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

897 {
898  C4String * k = &Strings.P[n];
899  if (Properties.Has(k))
900  {
901  return Properties.Get(k).Value.getPropList();
902  }
903  if (GetPrototype())
904  {
905  return GetPrototype()->GetPropertyPropList(n);
906  }
907  return nullptr;
908 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4PropList * GetPropertyPropList(C4PropertyName k) const
Definition: C4PropList.cpp:896
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

C4String * C4PropList::GetPropertyStr ( C4PropertyName  k) const

Definition at line 771 of file C4PropList.cpp.

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

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

772 {
773  C4String * k = &Strings.P[n];
774  if (Properties.Has(k))
775  {
776  return Properties.Get(k).Value.getStr();
777  }
778  if (GetPrototype())
779  {
780  return GetPrototype()->GetPropertyStr(n);
781  }
782  return nullptr;
783 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
C4String * getStr() const
Definition: C4Value.h:117
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
C4String * GetPropertyStr(C4PropertyName k) const
Definition: C4PropList.cpp:771

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropListNumbered * C4PropList::GetPropListNumbered ( )
virtual

Reimplemented in C4PropListNumbered.

Definition at line 699 of file C4PropList.cpp.

References GetPropListNumbered(), and GetPrototype().

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

700 {
701  if (GetPrototype()) return GetPrototype()->GetPropListNumbered();
702  return nullptr;
703 }
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
virtual C4PropListNumbered * GetPropListNumbered()
Definition: C4PropList.cpp:699

Here is the call graph for this function:

Here is the caller graph for this function:

C4PropList* C4PropList::GetPrototype ( ) const
inline

Definition at line 81 of file C4PropList.h.

References C4Value::_getPropList().

Referenced by begin(), C4FindObjectDef::Check(), FreezeAndMakeStaticRecursively(), GetDef(), GetEffect(), GetFunc(), GetMapScriptLayer(), GetMapScriptMap(), GetObject(), GetProperties(), GetPropertyArray(), GetPropertyBool(), GetPropertyByS(), GetPropertyInt(), GetPropertyP(), GetPropertyPropList(), GetPropertyStr(), GetPropListNumbered(), GetSortedLocalProperties(), GetUnsortedProperties(), C4EditCursor::PerformDuplicationLegacy(), and SetPropertyByS().

81 { return prototype._getPropList(); }
C4PropList * _getPropList() const
Definition: C4Value.h:129

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 576 of file C4PropList.cpp.

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

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

577 {
578  // return property list without descending into prototype
579  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
580  std::vector< C4String * > result;
581  result.reserve(sorted_props.size() + add_prototype);
582  if (add_prototype) result.push_back(&::Strings.P[P_Prototype]); // implicit prototype for every prop list
583  for (auto p : sorted_props) result.push_back(p->Key);
584  return result;
585 }
C4String P[P_LAST]
std::list< const T * > GetSortedListOfElementPointers() const
C4StringTable Strings
Definition: C4Globals.cpp:42

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 587 of file C4PropList.cpp.

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

588 {
589  // return property list without descending into prototype
590  // ignore properties that have been overridden by proplist given in ignore_overridden or any of its prototypes up to and excluding this
591  std::vector< C4String * > result;
592  for (const C4Property *pp = Properties.First(); pp; pp = Properties.Next(pp))
593  if (pp->Key != &::Strings.P[P_Prototype])
594  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
595  {
596  // Override check
597  const C4PropList *check = ignore_overridden;
598  bool overridden = false;
599  if (check && check != this)
600  {
601  if (check->HasProperty(pp->Key)) { overridden = true; break; }
602  check = check->GetPrototype();
603  }
604  result.push_back(pp->Key);
605  }
606  // Sort
607  std::sort(result.begin(), result.end(), [](const C4String *a, const C4String *b) -> bool
608  {
609  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
610  });
611  return result;
612 }
C4String P[P_LAST]
#define b
const char * GetCStr() const
Definition: C4StringTable.h:49
#define a
T const * Next(T const *p) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
bool HasProperty(C4String *k) const
Definition: C4PropList.h:118
T const * First() const

Here is the call graph for this function:

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

Definition at line 632 of file C4PropList.cpp.

References a, b, C4String::GetCStr(), and GetUnsortedProperties().

633 {
634  // Return property list with descending into prototype
635  // But do not include Prototype property
636  std::vector< C4String * > result = GetUnsortedProperties(prefix, ignore_parent);
637  // Sort
638  std::sort(result.begin(), result.end(), [](const C4String *a, const C4String *b) -> bool
639  {
640  return strcmp(a->GetCStr(), b->GetCStr()) < 0;
641  });
642  return result;
643 }
#define b
const char * GetCStr() const
Definition: C4StringTable.h:49
#define a
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614

Here is the call graph for this function:

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

Definition at line 614 of file C4PropList.cpp.

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

Referenced by GetSortedProperties(), and ThawRecursively().

615 {
616  // Return property list with descending into prototype
617  // But do not include Prototype property
618  std::vector< C4String * > result;
619  const C4PropList *p = this;
620  do
621  {
622  for (const C4Property *pp = p->Properties.First(); pp; pp = p->Properties.Next(pp))
623  if (pp->Key != &::Strings.P[P_Prototype])
624  if (!prefix || pp->Key->GetData().BeginsWith(prefix))
625  result.push_back(pp->Key);
626  p = p->GetPrototype();
627  if (p == ignore_parent) break;
628  } while (p);
629  return result;
630 }
C4String P[P_LAST]
T const * Next(T const *p) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
T const * First() const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PropList::HasProperty ( C4String k) const
inline

Definition at line 118 of file C4PropList.h.

References C4Set< T >::Has().

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

118 { return Properties.Has(k); }
bool Has(H e) const

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4PropList::IsFrozen ( ) const
inline

Definition at line 131 of file C4PropList.h.

Referenced by ThawRecursively().

131 { return constant; }

Here is the caller graph for this function:

virtual bool C4PropList::IsNumbered ( ) const
inlinevirtual

Reimplemented in C4PropListNumbered.

Definition at line 88 of file C4PropList.h.

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

88 { return false; }

Here is the caller graph for this function:

virtual class C4PropListStatic* C4PropList::IsStatic ( )
inlinevirtual
const class C4PropListStatic* C4PropList::IsStatic ( ) const
inline

Definition at line 86 of file C4PropList.h.

References IsStatic().

Referenced by IsStatic().

86 { return const_cast<C4PropList*>(this)->IsStatic(); }
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 64 of file C4PropList.cpp.

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

65 {
66  C4PropList * r = new C4PropListScript(prototype);
67  return r;
68 }

Here is the caller graph for this function:

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

Definition at line 70 of file C4PropList.cpp.

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

71 {
72  return new C4PropListStatic(prototype, parent, key);
73 }

Here is the caller graph for this function:

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

Definition at line 379 of file C4PropList.cpp.

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

380 {
381  // every numbered proplist has a unique number and is only identical to itself
382  if (this == &b) return true;
383  if (IsNumbered() || b.IsNumbered()) return false;
384  if (Properties.GetSize() != b.Properties.GetSize()) return false;
385  if (GetDef() != b.GetDef()) return false;
386  const C4Property * p = Properties.First();
387  while (p)
388  {
389  const C4Property & bp = b.Properties.Get(p->Key);
390  if (!bp) return false;
391  if (p->Value != bp.Value) return false;
392  p = Properties.Next(p);
393  }
394  return true;
395 }
C4Value Value
Definition: C4PropList.h:55
virtual C4Def const * GetDef() const
Definition: C4PropList.cpp:681
T & Get(H e) const
T const * Next(T const *p) const
unsigned int GetSize() const
C4String * Key
Definition: C4PropList.h:54
virtual bool IsNumbered() const
Definition: C4PropList.h:88
T const * First() const

Here is the call graph for this function:

void C4PropList::RemoveCyclicPrototypes ( )

Definition at line 430 of file C4PropList.cpp.

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

Referenced by Denumerate().

431 {
432  // clear any cyclic prototype chains
433  // Use prototype.getPropList() instead of GetPrototype() because denumeration might not be completed yet
434  for(C4PropList * it = prototype.getPropList(); it; it = it->prototype.getPropList())
435  if(it == this)
436  {
437  prototype.Set0();
438  }
439 }
void Set0()
Definition: C4Value.h:336
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::ResetProperty ( C4String k)
virtual

Reimplemented in C4Object, and C4Effect.

Definition at line 969 of file C4PropList.cpp.

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

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

970 {
971  if (k == &Strings.P[P_Prototype])
972  prototype.Set0();
973  else
974  Properties.Remove(k);
975 }
C4String P[P_LAST]
void Set0()
Definition: C4Value.h:336
C4StringTable Strings
Definition: C4Globals.cpp:42
void Remove(H e)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in C4Object.

Definition at line 652 of file C4PropList.cpp.

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

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

653 {
654  if (!NewName)
656  else
657  {
658  SetProperty(P_Name, C4VString(NewName));
659  }
660 }
virtual void ResetProperty(C4String *k)
Definition: C4PropList.cpp:969
C4String P[P_LAST]
void SetProperty(C4PropertyName k, const C4Value &to)
Definition: C4PropList.h:120
C4StringTable Strings
Definition: C4Globals.cpp:42
C4Value C4VString(C4String *pStr)
Definition: C4Value.h:246

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4PropList::SetOnFire ( bool  OnFire)
inlinevirtual

Reimplemented in C4Object.

Definition at line 69 of file C4PropList.h.

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

69 { }

Here is the caller graph for this function:

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

Definition at line 120 of file C4PropList.h.

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

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

121  { SetPropertyByS(&Strings.P[k], to); }
C4String P[P_LAST]
C4StringTable Strings
Definition: C4Globals.cpp:42
virtual void SetPropertyByS(C4String *k, const C4Value &to)
Definition: C4PropList.cpp:948

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in C4Object, C4PropListScen, and C4Effect.

Definition at line 948 of file C4PropList.cpp.

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

Referenced by C4AulDefFunc::C4AulDefFunc(), C4PropListScen::C4PropListScen(), C4ScriptHost::CopyPropList(), SetProperty(), C4Effect::SetPropertyByS(), C4PropListScen::SetPropertyByS(), C4Object::SetPropertyByS(), C4ScriptGuiWindowProperty::ToC4Value(), C4ScriptGuiWindow::ToC4Value(), C4ScriptHost::UnlinkOwnedFunctions(), C4AulCompiler::PreparseAstVisitor::visit(), C4AulCompiler::ConstexprEvaluator::visit(), and C4AulCompiler::ConstantResolver::visit().

949 {
950  assert(!constant);
951  if (k == &Strings.P[P_Prototype])
952  {
953  C4PropList * newpt = to.getPropList();
954  for(C4PropList * it = newpt; it; it = it->GetPrototype())
955  if(it == this)
956  throw C4AulExecError("Trying to create cyclic prototype structure");
957  prototype.SetPropList(newpt);
958  }
959  else if (Properties.Has(k))
960  {
961  Properties.Get(k).Value = to;
962  }
963  else
964  {
965  Properties.Add(C4Property(k, to));
966  }
967 }
C4String P[P_LAST]
C4Value Value
Definition: C4PropList.h:55
T * Add(T const &e)
bool Has(H e) const
T & Get(H e) const
C4StringTable Strings
Definition: C4Globals.cpp:42
C4PropList * GetPrototype() const
Definition: C4PropList.h:81
void SetPropList(C4PropList *PropList)
Definition: C4Value.h:141
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4PropList::Thaw ( )
inline

Definition at line 129 of file C4PropList.h.

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

129 { constant = false; }

Here is the caller graph for this function:

void C4PropList::ThawRecursively ( )

Definition at line 283 of file C4PropList.cpp.

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

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

284 {
285  //thaw self and all owned properties
286  Thaw();
288  //if (s) LogF("Thaw: %s", s->GetDataString().getData());
289  auto prop_names = GetUnsortedProperties(nullptr, ::ScriptEngine.GetPropList());
290  for (auto prop_name : prop_names)
291  {
292  C4Value child_val;
293  GetPropertyByS(prop_name, &child_val);
294  //LogF(" %s=%s", prop_name->GetCStr(), child_val.GetDataString(1).getData());
295  C4PropList *child_proplist = child_val.getPropList();
296  if (child_proplist && child_proplist->IsFrozen())
297  {
298  child_proplist->ThawRecursively();
299  }
300  }
301 }
void Thaw()
Definition: C4PropList.h:129
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
Definition: C4PropList.cpp:753
void ThawRecursively()
Definition: C4PropList.cpp:283
bool IsFrozen() const
Definition: C4PropList.h:131
std::vector< C4String * > GetUnsortedProperties(const char *prefix, C4PropList *ignore_parent=nullptr) const
Definition: C4PropList.cpp:614
#define s
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 546 of file C4PropList.cpp.

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

Referenced by C4Value::ToJSON().

547 {
548  if (depth <= 0 && Properties.GetSize())
549  {
550  throw new C4JSONSerializationError("maximum depth reached");
551  }
552  StdStrBuf DataString;
553  DataString = "{";
554  bool has_elements = false;
555  // Append prototype
556  if (prototype)
557  {
558  DataString.Append("Prototype:");
559  DataString.Append(prototype.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
560  has_elements = true;
561  }
562  // Append other properties
563  std::list<const C4Property *> sorted_props = Properties.GetSortedListOfElementPointers();
564  for (std::list<const C4Property *>::const_iterator p = sorted_props.begin(); p != sorted_props.end(); ++p)
565  {
566  if (has_elements) DataString.Append(",");
567  DataString.Append(C4Value((*p)->Key).ToJSON());
568  DataString.Append(":");
569  DataString.Append((*p)->Value.ToJSON(depth - 1, ignore_reference_parent ? IsStatic() : nullptr));
570  has_elements = true;
571  }
572  DataString.Append("}");
573  return DataString;
574 }
std::list< const T * > GetSortedListOfElementPointers() const
friend class C4Value
Definition: C4PropList.h:165
virtual class C4PropListStatic * IsStatic()
Definition: C4PropList.h:85
unsigned int GetSize() const
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
StdStrBuf ToJSON(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
Definition: C4Value.cpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class C4ScriptHost
friend

Definition at line 166 of file C4PropList.h.

Member Data Documentation

int32_t C4PropList::Status {1}

Definition at line 168 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(), Call(), C4Game::CastObjects(), C4ObjectList::CheckCategorySort(), C4ObjectList::CheckSort(), C4Effect::ClearAll(), C4ObjectList::ClearInfo(), C4Object::Collect(), 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::ExecAction(), C4SoundInstance::Execute(), C4Effect::Execute(), C4Object::Execute(), C4ScriptGuiWindowAction::ExecuteCommand(), C4Command::Fail(), C4FindObject::Find(), C4ObjectList::Find(), C4ObjectList::FindOther(), C4GameObjects::FixObjectOrder(), FreezeAndMakeStaticRecursively(), C4Object::GetArea(), C4EditCursor::GetCurrentSelectionPosition(), C4Object::GetEntranceArea(), C4Object::GetInfoString(), C4ObjectList::GetListID(), C4Object::GetMomentum(), C4ObjectList::GetObject(), C4Object::GrabInfo(), GrabLost(), C4GameObjects::GRBroadcast(), C4GameMessage::Init(), C4Effect::Init(), C4Object::IsMoveableBySolidMask(), C4GraphicsOverlay::IsValid(), C4Object::Lift(), C4ObjectList::ListIDCount(), 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().


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