OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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
 
struct  C4ValueConv< T >
 
singleton  Nillable< T >
 
class  NeedObjectContext
 
class  NeedNonGlobalContext
 
struct  ThisImpl< ThisType >
 
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

class C4Void

Definition at line 44 of file C4AulDefFunc.h.

struct C4ValueConv

template<typename T>
struct C4ValueConv< T >

Definition at line 45 of file C4AulDefFunc.h.

struct ThisImpl

template<typename ThisType>
struct ThisImpl< ThisType >

Definition at line 95 of file C4AulDefFunc.h.

struct C4ScriptConstDef

Definition at line 266 of file C4AulDefFunc.h.

Class Members
long Data
const char * Identifier
C4V_Type ValType

Function Documentation

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 260 of file C4AulDefFunc.h.

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

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

Here is the caller graph for this function:

C4Effect** FnGetEffectsFor ( C4PropList pTarget)

Definition at line 51 of file C4GameScript.cpp.

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

52 {
53  if (pTarget)
54  {
55  if (pTarget == ScriptEngine.GetPropList())
57  if (pTarget == GameScript.ScenPropList.getPropList())
59  C4Object * Obj = pTarget->GetObject();
60  if (!Obj)
61  throw C4AulExecError("Effect target has to be an object");
62  return &Obj->pEffects;
63  }
65 }
C4PropListStatic * GetPropList()
Definition: C4Aul.h:151
C4GameScriptHost GameScript
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
virtual C4Object * GetObject()
Definition: C4PropList.cpp:667
C4Value ScenPropList
Definition: C4ScriptHost.h:163
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:165
C4Effect * pGlobalEffects
Definition: C4Aul.h:144
C4PropList * getPropList() const
Definition: C4Value.h:116

Here is the call graph for this function:

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

Definition at line 29 of file C4Script.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendChar(), StdStrBuf::AppendCharacter(), StdStrBuf::AppendFormat(), C4String::GetCStr(), C4Value::getStr(), Inside(), SCopy(), and SLen().

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

Here is the call graph for this function:

C4Object* Object ( C4PropList _this)
inline

Definition at line 34 of file C4AulDefFunc.h.

References C4PropList::GetObject().

Referenced by FnPlaceVegetation(), InitGameFunctionMap(), C4AulCompiler::PreparseAstVisitor::visit(), C4AulCompiler::CodegenAstVisitor::visit(), and C4AulCompiler::ConstantResolver::visit().

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4String* String ( const char *  str)
inline

Definition at line 30 of file C4AulDefFunc.h.

References C4StringTable::RegString(), and Strings.

Referenced by C4LangStringTable::ReplaceStrings().

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

Here is the call graph for this function:

Here is the caller graph for this function: