OpenClonk
C4AulFuncMap Class Reference

#include <C4Aul.h>

Public Member Functions

 C4AulFuncMap ()
 
 ~C4AulFuncMap ()
 
C4AulFuncGetFirstFunc (const char *Name)
 
C4AulFuncGetNextSNFunc (const C4AulFunc *After)
 

Protected Member Functions

void Add (C4AulFunc *func)
 
void Remove (C4AulFunc *func)
 

Friends

class C4AulFunc
 
class C4ScriptHost
 

Detailed Description

Definition at line 68 of file C4Aul.h.

Constructor & Destructor Documentation

◆ C4AulFuncMap()

C4AulFuncMap::C4AulFuncMap ( )

Definition at line 278 of file C4Aul.cpp.

279 {
280  memset(Funcs, 0, sizeof(Funcs));
281 }

◆ ~C4AulFuncMap()

C4AulFuncMap::~C4AulFuncMap ( )

Definition at line 283 of file C4Aul.cpp.

284 {
285  assert(!FuncCnt);
286 }

Member Function Documentation

◆ Add()

void C4AulFuncMap::Add ( C4AulFunc func)
protected

Definition at line 314 of file C4Aul.cpp.

References C4AulFunc::GetName(), and C4AulFunc::MapNext.

Referenced by C4AulFunc::C4AulFunc().

315 {
316  ++FuncCnt;
317  // Get a pointer to the bucket
318  C4AulFunc ** pFunc = &(Funcs[Hash(func->GetName()) % HashSize]);
319  // move the current first to the second position
320  func->MapNext = *pFunc;
321  // Add the func
322  *pFunc = func;
323 }
const char * GetName() const
Definition: C4AulFunc.h:56
C4AulFunc * MapNext
Definition: C4AulFunc.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFirstFunc()

C4AulFunc * C4AulFuncMap::GetFirstFunc ( const char *  Name)

Definition at line 297 of file C4Aul.cpp.

References C4AulFunc::GetName(), C4AulFunc::MapNext, and SEqual().

Referenced by C4AulScriptEngine::GetFirstFunc().

298 {
299  if (!Name) return nullptr;
300  C4AulFunc * Func = Funcs[Hash(Name) % HashSize];
301  while (Func && !SEqual(Name, Func->GetName()))
302  Func = Func->MapNext;
303  return Func;
304 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:93
const char * GetName() const
Definition: C4AulFunc.h:56
C4AulFunc * MapNext
Definition: C4AulFunc.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextSNFunc()

C4AulFunc * C4AulFuncMap::GetNextSNFunc ( const C4AulFunc After)

Definition at line 306 of file C4Aul.cpp.

References C4AulFunc::GetName(), and C4AulFunc::MapNext.

Referenced by C4AulScriptEngine::GetNextSNFunc().

307 {
308  C4AulFunc * Func = After->MapNext;
309  while (Func && After->GetName() != Func->GetName())
310  Func = Func->MapNext;
311  return Func;
312 }
const char * GetName() const
Definition: C4AulFunc.h:56
C4AulFunc * MapNext
Definition: C4AulFunc.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Remove()

void C4AulFuncMap::Remove ( C4AulFunc func)
protected

Definition at line 325 of file C4Aul.cpp.

References C4AulFunc::GetName(), and C4AulFunc::MapNext.

Referenced by C4AulFunc::~C4AulFunc().

326 {
327  C4AulFunc ** pFunc = &Funcs[Hash(func->GetName()) % HashSize];
328  while (*pFunc != func)
329  {
330  pFunc = &((*pFunc)->MapNext);
331  assert(*pFunc); // crash on remove of a not contained func
332  }
333  *pFunc = (*pFunc)->MapNext;
334  --FuncCnt;
335 }
const char * GetName() const
Definition: C4AulFunc.h:56
C4AulFunc * MapNext
Definition: C4AulFunc.h:61
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ C4AulFunc

friend class C4AulFunc
friend

Definition at line 83 of file C4Aul.h.

◆ C4ScriptHost

friend class C4ScriptHost
friend

Definition at line 84 of file C4Aul.h.


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