OpenClonk
C4AulDefFunc.h File Reference
#include "script/C4Aul.h"
#include "object/C4Def.h"
#include "object/C4DefList.h"
#include "script/C4Effect.h"
Include dependency graph for C4AulDefFunc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  C4Void
 
class  Nillable< T >
 
class  NeedObjectContext
 
class  NeedNonGlobalContext
 
struct  ThisImpl< C4Object >
 
struct  ThisImpl< C4PropList >
 
struct  ExecImpl< RType, ThisType, ParTypes >
 
struct  ExecImpl< void, ThisType, ParTypes... >
 
struct  C4ValueConv< Nillable< T > >
 
struct  C4ValueConv< void >
 
struct  C4ValueConv< int >
 
struct  C4ValueConv< long >
 
struct  C4ValueConv< bool >
 
struct  C4ValueConv< C4ID >
 
struct  C4ValueConv< C4Object * >
 
struct  C4ValueConv< C4String * >
 
struct  C4ValueConv< C4ValueArray * >
 
struct  C4ValueConv< C4AulFunc * >
 
struct  C4ValueConv< C4PropList * >
 
struct  C4ValueConv< C4Effect * >
 
struct  C4ValueConv< C4Def * >
 
struct  C4ValueConv< const C4Value & >
 
struct  C4ValueConv< C4Value >
 
class  C4AulEngineFunc< RType, ThisType, ParTypes >
 
struct  C4ScriptConstDef
 
struct  C4ScriptFnDef
 
class  C4AulDefFunc
 

Functions

C4StringString (const char *str)
 
C4ObjectObject (C4PropList *_this)
 
StdStrBuf FnStringFormat (C4PropList *_this, C4String *szFormatPar, C4Value *Pars, int ParCount)
 
C4Effect ** FnGetEffectsFor (C4PropList *pTarget)
 
template<typename RType , typename ThisType , typename ... ParTypes>
void AddFunc (C4PropListStatic *Parent, const char *Name, RType(*pFunc)(ThisType *, ParTypes...), bool Public=true)
 

Class Documentation

◆ C4Void

class C4Void

Definition at line 44 of file C4AulDefFunc.h.

◆ C4ScriptConstDef

struct C4ScriptConstDef

Definition at line 267 of file C4AulDefFunc.h.

Class Members
long Data
const char * Identifier
C4V_Type ValType

Function Documentation

◆ AddFunc()

template<typename RType , typename ThisType , typename ... ParTypes>
void AddFunc ( C4PropListStatic Parent,
const char *  Name,
RType(*)(ThisType *, ParTypes...)  pFunc,
bool  Public = true 
)
inline

Definition at line 261 of file C4AulDefFunc.h.

262 {
263  new C4AulEngineFunc<RType, ThisType, ParTypes...>(Parent, Name, pFunc, Public);
264 }

Referenced by C4MapScriptHost::AddEngineFunctions(), C4ScriptLibraryCrypto::CreateFunctions(), InitCoreFunctionMap(), InitGameFunctionMap(), and InitObjectFunctionMap().

Here is the caller graph for this function:

◆ FnGetEffectsFor()

C4Effect** FnGetEffectsFor ( C4PropList pTarget)

Definition at line 72 of file C4GameScript.cpp.

73 {
74  if (target)
75  {
76  if (target == ScriptEngine.GetPropList())
77  {
79  }
80  if (target == GameScript.ScenPropList.getPropList())
81  {
83  }
84  C4Object * obj = target->GetObject();
85  if (!obj)
86  {
87  throw C4AulExecError("Effect target has to be an object");
88  }
89  return &obj->pEffects;
90  }
92 }
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
C4GameScriptHost GameScript
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:166
C4Value ScenPropList
Definition: C4ScriptHost.h:164
C4Effect * pEffects
Definition: C4Object.h:155
C4Object * GetObject() override
Definition: C4Object.h:372
C4PropList * getPropList() const
Definition: C4Value.h:116

References GameScript, C4PropList::GetObject(), C4AulScriptEngine::GetPropList(), C4Value::getPropList(), C4Object::pEffects, C4AulScriptEngine::pGlobalEffects, C4GameScriptHost::pScenarioEffects, C4GameScriptHost::ScenPropList, and ScriptEngine.

Here is the call graph for this function:

◆ FnStringFormat()

StdStrBuf FnStringFormat ( C4PropList _this,
C4String szFormatPar,
C4Value Pars,
int  ParCount 
)

Definition at line 30 of file C4Script.cpp.

31 {
32  int cPar=0;
33 
34  StdStrBuf StringBuf("", false);
35  const char * cpFormat = FnStringPar(szFormatPar);
36  const char * cpType;
37  char szField[20];
38  while (*cpFormat)
39  {
40  // Copy normal stuff
41  while (*cpFormat && (*cpFormat!='%'))
42  StringBuf.AppendChar(*cpFormat++);
43  // Field
44  if (*cpFormat=='%')
45  {
46  // Scan field type
47  for (cpType=cpFormat+1; *cpType && (*cpType == '+' || *cpType == '-' || *cpType == '.' || *cpType == '#' || *cpType == ' ' || Inside(*cpType,'0','9')); cpType++) {}
48  // Copy field
49  SCopy(cpFormat,szField,std::min<unsigned int>(sizeof szField - 1, cpType - cpFormat + 1));
50  // Insert field by type
51  switch (*cpType)
52  {
53  // number
54  case 'd': case 'x': case 'X':
55  {
56  if (cPar >= ParCount) throw C4AulExecError("format placeholder without parameter");
57  StringBuf.AppendFormat(szField, Pars[cPar++].getInt());
58  cpFormat+=SLen(szField);
59  break;
60  }
61  // character
62  case 'c':
63  {
64  if (cPar >= ParCount) throw C4AulExecError("format placeholder without parameter");
65  StringBuf.AppendCharacter(Pars[cPar++].getInt());
66  cpFormat+=SLen(szField);
67  break;
68  }
69  // C4ID
70  case 'i':
71  // C4Value
72  case 'v':
73  {
74  if (cPar >= ParCount) throw C4AulExecError("format placeholder without parameter");
75  StringBuf.Append(static_cast<const StdStrBuf&>(Pars[cPar++].GetDataString(10)));
76  cpFormat+=SLen(szField);
77  break;
78  }
79  // String
80  case 's':
81  {
82  // get string
83  if (cPar >= ParCount) throw C4AulExecError("format placeholder without parameter");
84  const char *szStr = "(null)";
85  if (Pars[cPar].GetData())
86  {
87  C4String * pStr = Pars[cPar].getStr();
88  if (!pStr) throw C4AulExecError("string format placeholder without string");
89  szStr = pStr->GetCStr();
90  }
91  ++cPar;
92  StringBuf.AppendFormat(szField, szStr);
93  cpFormat+=SLen(szField);
94  break;
95  }
96  case '%':
97  StringBuf.AppendChar('%');
98  cpFormat+=SLen(szField);
99  break;
100  // Undefined / Empty
101  default:
102  StringBuf.AppendChar('%');
103  cpFormat++;
104  break;
105  }
106  }
107  }
108  return StringBuf;
109 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
size_t SLen(const char *sptr)
Definition: Standard.h:74
const char * GetCStr() const
Definition: C4StringTable.h:49
C4String * getStr() const
Definition: C4Value.h:117

◆ Object()

C4Object* Object ( C4PropList _this)
inline

Definition at line 34 of file C4AulDefFunc.h.

35 {
36  return _this ? _this->GetObject() : nullptr;
37 }
virtual C4Object * GetObject()
Definition: C4PropList.cpp:636

References C4PropList::GetObject().

Referenced by AssignController(), C4MeshDenumerator::C4MeshDenumerator(), C4MeshDenumerator::GetObject(), GetValidOwner(), MakeAbsCoordinates(), and C4AulCompiler::ConstantResolver::visit().

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

◆ String()

C4String* String ( const char *  str)
inline

Definition at line 30 of file C4AulDefFunc.h.

31 {
32  return str ? ::Strings.RegString(str) : nullptr;
33 }
C4StringTable Strings
Definition: C4Globals.cpp:42
C4String * RegString(StdStrBuf String)

References C4StringTable::RegString(), and Strings.

Referenced by GetTextureName(), C4StringTable::RegString(), and C4LangStringTable::ReplaceStrings().

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