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

struct C4ValueConv

template<typename T>
struct C4ValueConv< T >

Definition at line 46 of file C4AulDefFunc.h.

struct ThisImpl

template<typename ThisType>
struct ThisImpl< ThisType >

Definition at line 96 of file C4AulDefFunc.h.

struct C4ScriptConstDef

Definition at line 267 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 261 of file C4AulDefFunc.h.

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

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

Here is the caller graph for this function:

C4Effect** FnGetEffectsFor ( C4PropList pTarget)

Definition at line 53 of file C4GameScript.cpp.

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

54 {
55  if (pTarget)
56  {
57  if (pTarget == ScriptEngine.GetPropList())
59  if (pTarget == GameScript.ScenPropList.getPropList())
61  C4Object * Obj = pTarget->GetObject();
62  if (!Obj)
63  throw C4AulExecError("Effect target has to be an object");
64  return &Obj->pEffects;
65  }
67 }
C4PropListStatic * GetPropList()
Definition: C4Aul.h:153
C4GameScriptHost GameScript
C4AulScriptEngine ScriptEngine
Definition: C4Globals.cpp:43
virtual C4Object * GetObject()
Definition: C4PropList.cpp:644
C4Value ScenPropList
Definition: C4ScriptHost.h:163
C4Effect * pScenarioEffects
Definition: C4ScriptHost.h:165
C4Effect * pGlobalEffects
Definition: C4Aul.h:146
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 31 of file C4Script.cpp.

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

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

Here is the call graph for this function:

C4Object* Object ( C4PropList _this)
inline

Definition at line 35 of file C4AulDefFunc.h.

References C4PropList::GetObject().

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

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

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

References C4StringTable::RegString(), and Strings.

Referenced by C4LangStringTable::ReplaceStrings().

32 {
33  return str ? ::Strings.RegString(str) : nullptr;
34 }
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: