forked from Mirrors/openclonk
Wrap C4AulFunc::Name in C4AulFunc::GetName()
parent
725f0e0f5a
commit
0cd46a2ebc
|
@ -433,7 +433,7 @@ void C4Console::UpdateInputCtrl()
|
|||
{
|
||||
ClearInput();
|
||||
// add global and standard functions
|
||||
std::list <char*> functions = ::ScriptEngine.GetFunctionNames(&::GameScript);
|
||||
std::list <const char*> functions = ::ScriptEngine.GetFunctionNames(&::GameScript);
|
||||
SetInputFunctions(functions);
|
||||
}
|
||||
|
||||
|
|
|
@ -850,7 +850,7 @@ void C4ConsoleGUI::ClearInput()
|
|||
gtk_list_store_clear(store);
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::SetInputFunctions(std::list<char*>& functions)
|
||||
void C4ConsoleGUI::SetInputFunctions(std::list<const char*>& functions)
|
||||
{
|
||||
if(state->txtScript == NULL) return;
|
||||
|
||||
|
@ -858,9 +858,9 @@ void C4ConsoleGUI::SetInputFunctions(std::list<char*>& functions)
|
|||
GtkListStore* store = GTK_LIST_STORE(gtk_entry_completion_get_model(completion));
|
||||
GtkTreeIter iter;
|
||||
g_assert(store);
|
||||
for (std::list<char*>::iterator it(functions.begin()); it != functions.end(); ++it)
|
||||
for (std::list<const char*>::iterator it(functions.begin()); it != functions.end(); ++it)
|
||||
{
|
||||
char* fn = *it;
|
||||
const char* fn = *it;
|
||||
if (!fn) continue;
|
||||
gtk_list_store_append(store, &iter);
|
||||
gtk_list_store_set(store, &iter, 0, fn, -1);
|
||||
|
@ -1018,7 +1018,7 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
if (PropertyDlgObject == rSelection.GetObject()) return;
|
||||
PropertyDlgObject = rSelection.GetObject();
|
||||
|
||||
std::list<char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject ? &PropertyDlgObject->Def->Script : 0);
|
||||
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject ? &PropertyDlgObject->Def->Script : 0);
|
||||
GtkEntryCompletion* completion = gtk_entry_get_completion(GTK_ENTRY(state->propertydlg_entry));
|
||||
GtkListStore* store;
|
||||
|
||||
|
@ -1044,9 +1044,9 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
GtkTreeIter iter;
|
||||
gtk_list_store_clear(store);
|
||||
|
||||
for (std::list<char*>::iterator it(functions.begin()); it != functions.end(); it++)
|
||||
for (std::list<const char*>::iterator it(functions.begin()); it != functions.end(); it++)
|
||||
{
|
||||
char* fn = *it;
|
||||
const char* fn = *it;
|
||||
if (fn)
|
||||
{
|
||||
gtk_list_store_append(store, &iter);
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
void AddNetMenuItemForPlayer(int32_t index, StdStrBuf &text);
|
||||
void ClearInput();
|
||||
void ClearPlayerMenu();
|
||||
void SetInputFunctions(std::list<char*> &functions);
|
||||
void SetInputFunctions(std::list<const char*> &functions);
|
||||
|
||||
C4Window* CreateConsoleWindow(C4AbstractApp *application);
|
||||
void Out(const char* message);
|
||||
|
|
|
@ -892,12 +892,11 @@ void C4ConsoleGUI::PropertyDlgClose()
|
|||
::ClearDlg(state->hPropertyDlg);
|
||||
}
|
||||
|
||||
static void SetComboItems(HWND hCombo, std::list<char*> &items)
|
||||
static void SetComboItems(HWND hCombo, std::list<const char*> &items)
|
||||
{
|
||||
for (std::list<char*>::iterator it = items.begin(); it != items.end(); it++)
|
||||
for (std::list<const char*>::iterator it = items.begin(); it != items.end(); it++)
|
||||
{
|
||||
char *item = *it;
|
||||
if (!item)
|
||||
if (!*it)
|
||||
SendMessage(hCombo,CB_INSERTSTRING,0,(LPARAM)L"----------");
|
||||
else
|
||||
SendMessage(hCombo,CB_ADDSTRING,0,GetWideLPARAM(*it));
|
||||
|
@ -916,7 +915,7 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
if (PropertyDlgObject == rSelection.GetObject()) return;
|
||||
PropertyDlgObject = rSelection.GetObject();
|
||||
|
||||
std::list<char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject ? &PropertyDlgObject->Def->Script : 0);
|
||||
std::list<const char *> functions = ::ScriptEngine.GetFunctionNames(PropertyDlgObject ? &PropertyDlgObject->Def->Script : 0);
|
||||
HWND hCombo = GetDlgItem(state->hPropertyDlg, IDC_COMBOINPUT);
|
||||
wchar_t szLastText[500+1];
|
||||
// Remember old window text
|
||||
|
@ -930,7 +929,7 @@ void C4ConsoleGUI::PropertyDlgUpdate(C4ObjectList &rSelection)
|
|||
SetWindowTextW(hCombo, szLastText);
|
||||
}
|
||||
|
||||
void C4ConsoleGUI::SetInputFunctions(std::list<char*> &functions)
|
||||
void C4ConsoleGUI::SetInputFunctions(std::list<const char*> &functions)
|
||||
{
|
||||
SetComboItems(GetDlgItem(hWindow,IDC_COMBOINPUT), functions);
|
||||
}
|
||||
|
|
|
@ -191,8 +191,6 @@ public:
|
|||
int32_t Count; // number of instanciations
|
||||
C4AulScriptFunc *TimerCall;
|
||||
|
||||
// Currently cannot have script host in frontend because that
|
||||
// would need C4Script, C4AulScript, and all that as well...
|
||||
C4DefScriptHost Script;
|
||||
C4LangStringTable StringTable;
|
||||
|
||||
|
|
|
@ -84,7 +84,8 @@ C4AulFunc::C4AulFunc(C4AulScript *pOwner, const char *pName, bool bAtEnd):
|
|||
// store name
|
||||
SCopy(pName, (char *) &Name, C4AUL_MAX_Identifier);
|
||||
// add to global lookuptable with this name
|
||||
Owner->Engine->FuncLookUp.Add(this, bAtEnd);
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Add(this, bAtEnd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +114,8 @@ C4AulFunc::~C4AulFunc()
|
|||
{
|
||||
if (Owner->Func0 == this) Owner->Func0 = Next;
|
||||
if (Owner->FuncL == this) Owner->FuncL = Prev;
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +147,7 @@ StdStrBuf C4AulScriptFunc::GetFullName()
|
|||
sOwner.Ref("game ");
|
||||
}
|
||||
StdStrBuf sResult;
|
||||
sResult.Format("%s%s", sOwner.getData(), Name);
|
||||
sResult.Format("%s%s", sOwner.getData(), GetName());
|
||||
return sResult;
|
||||
}
|
||||
|
||||
|
@ -238,17 +240,17 @@ C4AulFunc *C4AulScript::GetOverloadedFunc(C4AulFunc *ByFunc)
|
|||
if (f) f = f->Prev; else f = FuncL;
|
||||
while (f)
|
||||
{
|
||||
if (SEqual(ByFunc->Name, f->Name)) break;
|
||||
if (SEqual(ByFunc->GetName(), f->GetName())) break;
|
||||
f = f->Prev;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
C4AulFunc * f2 = Engine ? Engine->GetFunc(ByFunc->Name, this, ByFunc) : NULL;
|
||||
C4AulFunc * f2 = Engine ? Engine->GetFunc(ByFunc->GetName(), this, ByFunc) : NULL;
|
||||
assert (f == f2);
|
||||
#endif
|
||||
// nothing found? then search owner, if existant
|
||||
if (!f && Owner)
|
||||
{
|
||||
if ((f = Owner->GetFuncRecursive(ByFunc->Name)))
|
||||
if ((f = Owner->GetFuncRecursive(ByFunc->GetName())))
|
||||
// just found the global link?
|
||||
if (ByFunc && f->LinkedTo == ByFunc)
|
||||
f = Owner->GetOverloadedFunc(f);
|
||||
|
@ -473,14 +475,14 @@ void C4AulScriptEngine::CompileFunc(StdCompiler *pComp, C4ValueNumbers * numbers
|
|||
pComp->Value(mkNamingAdapt(mkParAdapt(GlobalNamed, numbers), "StaticVariables", GlobalNamedDefault));
|
||||
}
|
||||
|
||||
std::list<char*> C4AulScriptEngine::GetFunctionNames(C4AulScript * script)
|
||||
std::list<const char*> C4AulScriptEngine::GetFunctionNames(C4AulScript * script)
|
||||
{
|
||||
std::list<char*> functions;
|
||||
std::list<const char*> functions;
|
||||
for (C4AulFunc *pFn = Func0; pFn; pFn = pFn->Next)
|
||||
{
|
||||
if (pFn->GetPublic())
|
||||
{
|
||||
functions.push_back(pFn->Name);
|
||||
functions.push_back(pFn->GetName());
|
||||
}
|
||||
}
|
||||
// Add object or scenario script functions
|
||||
|
@ -499,10 +501,10 @@ std::list<char*> C4AulScriptEngine::GetFunctionNames(C4AulScript * script)
|
|||
{
|
||||
// Insert divider if necessary
|
||||
if (!divider)
|
||||
functions.push_back(static_cast<char*>(0));
|
||||
functions.push_back(0);
|
||||
divider = true;
|
||||
// Add function
|
||||
functions.push_back(pRef->Name);
|
||||
functions.push_back(pRef->GetName());
|
||||
}
|
||||
}
|
||||
f = f->Prev;
|
||||
|
@ -537,7 +539,7 @@ C4AulFunc * C4AulFuncMap::GetFirstFunc(const char * Name)
|
|||
{
|
||||
if (!Name) return NULL;
|
||||
C4AulFunc * Func = Funcs[Hash(Name) % Capacity];
|
||||
while (Func && !SEqual(Name, Func->Name))
|
||||
while (Func && !SEqual(Name, Func->GetName()))
|
||||
Func = Func->MapNext;
|
||||
return Func;
|
||||
}
|
||||
|
@ -545,7 +547,7 @@ C4AulFunc * C4AulFuncMap::GetFirstFunc(const char * Name)
|
|||
C4AulFunc * C4AulFuncMap::GetNextSNFunc(const C4AulFunc * After)
|
||||
{
|
||||
C4AulFunc * Func = After->MapNext;
|
||||
while (Func && !SEqual(After->Name, Func->Name))
|
||||
while (Func && !SEqual(After->GetName(), Func->GetName()))
|
||||
Func = Func->MapNext;
|
||||
return Func;
|
||||
}
|
||||
|
@ -561,7 +563,7 @@ C4AulFunc * C4AulFuncMap::GetFunc(const char * Name, const C4AulScript * Owner,
|
|||
if (Func)
|
||||
Func = Func->MapNext;
|
||||
}
|
||||
while (Func && (Func->Owner != Owner || !SEqual(Name, Func->Name)))
|
||||
while (Func && (Func->Owner != Owner || !SEqual(Name, Func->GetName())))
|
||||
Func = Func->MapNext;
|
||||
return Func;
|
||||
}
|
||||
|
@ -578,7 +580,7 @@ void C4AulFuncMap::Add(C4AulFunc * func, bool bAtStart)
|
|||
while (Funcs[i])
|
||||
{
|
||||
// Get a pointer to the bucket
|
||||
C4AulFunc ** pNFunc = &(NFuncs[Hash(Funcs[i]->Name) % NCapacity]);
|
||||
C4AulFunc ** pNFunc = &(NFuncs[Hash(Funcs[i]->GetName()) % NCapacity]);
|
||||
// get a pointer to the end of the linked list
|
||||
while (*pNFunc) pNFunc = &((*pNFunc)->MapNext);
|
||||
// Move the func over
|
||||
|
@ -594,7 +596,7 @@ void C4AulFuncMap::Add(C4AulFunc * func, bool bAtStart)
|
|||
Funcs = NFuncs;
|
||||
}
|
||||
// Get a pointer to the bucket
|
||||
C4AulFunc ** pFunc = &(Funcs[Hash(func->Name) % Capacity]);
|
||||
C4AulFunc ** pFunc = &(Funcs[Hash(func->GetName()) % Capacity]);
|
||||
if (bAtStart)
|
||||
{
|
||||
// move the current first to the second position
|
||||
|
@ -614,7 +616,7 @@ void C4AulFuncMap::Add(C4AulFunc * func, bool bAtStart)
|
|||
|
||||
void C4AulFuncMap::Remove(C4AulFunc * func)
|
||||
{
|
||||
C4AulFunc ** pFunc = &Funcs[Hash(func->Name) % Capacity];
|
||||
C4AulFunc ** pFunc = &Funcs[Hash(func->GetName()) % Capacity];
|
||||
while (*pFunc != func)
|
||||
{
|
||||
pFunc = &((*pFunc)->MapNext);
|
||||
|
|
|
@ -218,6 +218,7 @@ public:
|
|||
|
||||
C4AulScript *Owner; // owner
|
||||
char Name[C4AUL_MAX_Identifier]; // function name
|
||||
const char * GetName() const { return *Name ? Name : 0; }
|
||||
|
||||
protected:
|
||||
C4AulFunc *Prev, *Next; // linked list members
|
||||
|
@ -497,7 +498,7 @@ public:
|
|||
{ return FuncLookUp.GetNextSNFunc(After); }
|
||||
|
||||
// For the list of functions in the PropertyDlg
|
||||
std::list<char*> GetFunctionNames(C4AulScript *);
|
||||
std::list<const char*> GetFunctionNames(C4AulScript *);
|
||||
|
||||
void RegisterGlobalConstant(const char *szName, const C4Value &rValue); // creates a new constants or overwrites an old one
|
||||
bool GetGlobalConstant(const char *szName, C4Value *pTargetValue); // check if a constant exists; assign value to pTargetValue if not NULL
|
||||
|
|
|
@ -319,7 +319,7 @@ public C4AulDefFuncHelper { \
|
|||
/* Extracts the parameters from C4Values and wraps the return value in a C4Value */ \
|
||||
virtual C4Value Exec(C4AulContext *pContext, C4Value pPars[], bool fPassErrors=false) \
|
||||
{ \
|
||||
if (!pContext->Obj) throw new NeedObjectContext(Name); \
|
||||
if (!pContext->Obj) throw new NeedObjectContext(GetName()); \
|
||||
return C4ValueConv<RType>::ToC4V(pFunc(static_cast<C4AulObjectContext*>(pContext) LIST(N, CONV_FROM_C4V))); \
|
||||
} \
|
||||
protected: \
|
||||
|
|
|
@ -46,11 +46,11 @@ StdStrBuf C4AulScriptContext::ReturnDump(StdStrBuf Dump)
|
|||
{
|
||||
if (!Func)
|
||||
return StdStrBuf("");
|
||||
bool fDirectExec = !*Func->Name;
|
||||
bool fDirectExec = !Func->GetName();
|
||||
if (!fDirectExec)
|
||||
{
|
||||
// Function name
|
||||
Dump.Append(Func->Name);
|
||||
Dump.Append(Func->GetName());
|
||||
// Parameters
|
||||
Dump.AppendChar('(');
|
||||
int iNullPars = 0;
|
||||
|
@ -589,7 +589,7 @@ C4Value C4AulExec::Exec(C4AulBCC *pCPos, bool fPassErrors)
|
|||
{
|
||||
StdStrBuf Buf("T");
|
||||
Buf.AppendChars('>', ContextStackSize() - iTraceStart);
|
||||
LogF("%s%s returned %s", Buf.getData(), pCurCtx->Func->Name, pCurVal->GetDataString().getData());
|
||||
LogF("%s%s returned %s", Buf.getData(), pCurCtx->Func->GetName(), pCurVal->GetDataString().getData());
|
||||
}
|
||||
|
||||
#ifndef NOAULDEBUG
|
||||
|
@ -817,7 +817,7 @@ C4AulBCC *C4AulExec::Call(C4AulFunc *pFunc, C4Value *pReturn, C4Value *pPars, C4
|
|||
if (!pPars[i].CheckParConversion(pTypes[i]))
|
||||
throw new C4AulExecError(pCurCtx->Obj,
|
||||
FormatString("call to \"%s\" parameter %d: passed %s, but expected %s",
|
||||
pFunc->Name, i + 1, pPars[i].GetTypeName(), GetC4VName(pTypes[i])
|
||||
pFunc->GetName(), i + 1, pPars[i].GetTypeName(), GetC4VName(pTypes[i])
|
||||
).getData());
|
||||
|
||||
// Script function?
|
||||
|
|
|
@ -127,7 +127,7 @@ void C4AulScript::AppendTo(C4AulScript &Scr, bool bHighPrio)
|
|||
{
|
||||
// append: create copy
|
||||
// (if high priority, insert at end, otherwise at the beginning)
|
||||
C4AulScriptFunc *sfc = new C4AulScriptFunc(&Scr, sf->Name, bHighPrio);
|
||||
C4AulScriptFunc *sfc = new C4AulScriptFunc(&Scr, sf->GetName(), bHighPrio);
|
||||
sfc->CopyBody(*sf);
|
||||
// link the copy to a local function
|
||||
if (sf->LinkedTo)
|
||||
|
|
|
@ -260,10 +260,10 @@ C4AulParseError::C4AulParseError(C4AulParseState * state, const char *pMsg, cons
|
|||
Warn ? "WARNING" : "ERROR",
|
||||
pMsg,
|
||||
pIdtf ? pIdtf : "");
|
||||
if (state->Fn && *(state->Fn->Name))
|
||||
if (state->Fn && state->Fn->GetName())
|
||||
{
|
||||
// Show function name
|
||||
sMessage.AppendFormat(" (in %s", state->Fn->Name);
|
||||
sMessage.AppendFormat(" (in %s", state->Fn->GetName());
|
||||
|
||||
// Exact position
|
||||
if (state->Fn->pOrgScript && state->SPos)
|
||||
|
@ -2273,8 +2273,8 @@ void C4AulParseState::Parse_Expression(int iParentPrio)
|
|||
Warn("using deprecated function ", Idtf);
|
||||
Shift();
|
||||
// Function parameters for all functions except "this", which can be used without
|
||||
if (!SEqual(FoundFn->Name, C4AUL_this) || TokenType == ATT_BOPEN)
|
||||
Parse_Params(FoundFn->GetParCount(), FoundFn->Name, FoundFn);
|
||||
if (!SEqual(FoundFn->GetName(), C4AUL_this) || TokenType == ATT_BOPEN)
|
||||
Parse_Params(FoundFn->GetParCount(), FoundFn->GetName(), FoundFn);
|
||||
else
|
||||
AddBCC(AB_STACK, FoundFn->GetParCount());
|
||||
AddBCC(AB_FUNC, (intptr_t) FoundFn);
|
||||
|
@ -3004,7 +3004,7 @@ bool C4AulScript::Parse()
|
|||
}
|
||||
if (!Fn)
|
||||
continue;
|
||||
fprintf(stderr, "%s:\n", Fn->Name);
|
||||
fprintf(stderr, "%s:\n", Fn->GetName());
|
||||
for (C4AulBCC *pBCC = Fn->GetCode();; pBCC++)
|
||||
{
|
||||
C4AulBCCType eType = pBCC->bccType;
|
||||
|
@ -3012,7 +3012,7 @@ bool C4AulScript::Parse()
|
|||
switch (eType)
|
||||
{
|
||||
case AB_FUNC:
|
||||
fprintf(stderr, "\t%s\n", pBCC->Par.f->Name); break;
|
||||
fprintf(stderr, "\t%s\n", pBCC->Par.f->GetName()); break;
|
||||
case AB_CALL: case AB_CALLFS: case AB_LOCALN: case AB_PROP:
|
||||
fprintf(stderr, "\t%s\n", pBCC->Par.s->GetCStr()); break;
|
||||
case AB_STRING:
|
||||
|
|
|
@ -475,16 +475,16 @@ static bool FnLocateFunc(C4AulContext *cthr, C4String *funcname, C4Object *pObj,
|
|||
C4AulScriptFunc *pSFunc = pFunc->SFunc();
|
||||
if (!pSFunc)
|
||||
{
|
||||
LogF("%s%s (engine)", szPrefix, pFunc->Name);
|
||||
LogF("%s%s (engine)", szPrefix, pFunc->GetName());
|
||||
}
|
||||
else if (!pSFunc->pOrgScript)
|
||||
{
|
||||
LogF("%s%s (no owner)", szPrefix, pSFunc->Name);
|
||||
LogF("%s%s (no owner)", szPrefix, pSFunc->GetName());
|
||||
}
|
||||
else
|
||||
{
|
||||
int32_t iLine = SGetLine(pSFunc->pOrgScript->GetScript(), pSFunc->Script);
|
||||
LogF("%s%s (%s:%d)", szPrefix, pFunc->Name, pSFunc->pOrgScript->ScriptName.getData(), (int)iLine);
|
||||
LogF("%s%s (%s:%d)", szPrefix, pFunc->GetName(), pSFunc->pOrgScript->ScriptName.getData(), (int)iLine);
|
||||
}
|
||||
// next func in overload chain
|
||||
pFunc = pSFunc ? pSFunc->OwnerOverloaded : NULL;
|
||||
|
|
Loading…
Reference in New Issue