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
 
struct  C4ValueConv< T >
 
class  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

◆ C4Void

class C4Void

Definition at line 44 of file C4AulDefFunc.h.

◆ C4ValueConv

struct C4ValueConv

template<typename T>
struct C4ValueConv< T >

Definition at line 45 of file C4AulDefFunc.h.

◆ ThisImpl

struct ThisImpl

template<typename ThisType>
struct ThisImpl< ThisType >

Definition at line 95 of file C4AulDefFunc.h.

◆ C4ScriptConstDef

struct C4ScriptConstDef

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

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

261 {
262  new C4AulEngineFunc<RType, ThisType, ParTypes...>(Parent, Name, pFunc, Public);
263 }
Here is the caller graph for this function:

◆ FnGetEffectsFor()

C4Effect** FnGetEffectsFor ( C4PropList pTarget)

Definition at line 51 of file C4GameScript.cpp.

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

Referenced by Object().

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
C4PropList * getPropList() const
Definition: C4Value.h:116
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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FnStringFormat()

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

Definition at line 30 of file C4Script.cpp.

Referenced by Object().

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 }
C4String * getStr() const
Definition: C4Value.h:117
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
size_t SLen(const char *sptr)
Definition: Standard.h:74
const char * GetCStr() const
Definition: C4StringTable.h:49
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
Here is the caller graph for this function:

◆ Object()

C4Object* Object ( C4PropList _this)
inline

Definition at line 34 of file C4AulDefFunc.h.

References FnGetEffectsFor(), FnStringFormat(), and C4PropList::GetObject().

Referenced by C4ValueProviderX::ClearPointers(), C4ValueProviderY::ClearPointers(), C4ValueProviderR::ClearPointers(), C4ValueProviderAbsX::ClearPointers(), C4ValueProviderAbsY::ClearPointers(), C4ValueProviderDist::ClearPointers(), C4ValueProviderXDir::ClearPointers(), C4ValueProviderYDir::ClearPointers(), C4ValueProviderRDir::ClearPointers(), C4ValueProviderAbsRDir::ClearPointers(), C4ValueProviderCosR::ClearPointers(), C4ValueProviderSinR::ClearPointers(), C4ValueProviderCosV::ClearPointers(), C4ValueProviderSinV::ClearPointers(), C4ValueProviderAction::ClearPointers(), C4ValueProviderX::DenumeratePointers(), C4ValueProviderY::DenumeratePointers(), C4ValueProviderR::DenumeratePointers(), C4ValueProviderAbsX::DenumeratePointers(), C4ValueProviderAbsY::DenumeratePointers(), C4ValueProviderDist::DenumeratePointers(), C4ValueProviderXDir::DenumeratePointers(), C4ValueProviderYDir::DenumeratePointers(), C4ValueProviderRDir::DenumeratePointers(), C4ValueProviderAbsRDir::DenumeratePointers(), C4ValueProviderCosR::DenumeratePointers(), C4ValueProviderSinR::DenumeratePointers(), C4ValueProviderCosV::DenumeratePointers(), C4ValueProviderSinV::DenumeratePointers(), C4ValueProviderAction::DenumeratePointers(), FnPlaceVegetation(), 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:

◆ String()

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: