forked from Mirrors/openclonk
Move C4AulFunc implementation to a separate file from C4Aul.cpp
parent
9d30869e87
commit
ba1b896ebc
|
@ -527,6 +527,7 @@ set(OC_CLONK_SOURCES
|
|||
src/script/C4AulDefFunc.h
|
||||
src/script/C4AulExec.cpp
|
||||
src/script/C4AulExec.h
|
||||
src/script/C4AulFunc.cpp
|
||||
src/script/C4AulFunc.h
|
||||
src/script/C4Aul.h
|
||||
src/script/C4AulLink.cpp
|
||||
|
@ -954,6 +955,7 @@ add_executable(c4script
|
|||
src/lib/C4Random.cpp
|
||||
src/script/C4Aul.cpp
|
||||
src/script/C4AulExec.cpp
|
||||
src/script/C4AulFunc.cpp
|
||||
src/script/C4AulLink.cpp
|
||||
src/script/C4AulParse.cpp
|
||||
src/script/C4StringTable.cpp
|
||||
|
|
|
@ -511,6 +511,7 @@ src/script/C4AulDebug.h \
|
|||
src/script/C4AulDefFunc.h \
|
||||
src/script/C4AulExec.cpp \
|
||||
src/script/C4AulExec.h \
|
||||
src/script/C4AulFunc.cpp \
|
||||
src/script/C4AulFunc.h \
|
||||
src/script/C4Aul.h \
|
||||
src/script/C4AulLink.cpp \
|
||||
|
@ -687,6 +688,7 @@ src/lib/C4Real.cpp \
|
|||
src/lib/C4Random.cpp \
|
||||
src/script/C4Aul.cpp \
|
||||
src/script/C4AulExec.cpp \
|
||||
src/script/C4AulFunc.cpp \
|
||||
src/script/C4AulLink.cpp \
|
||||
src/script/C4AulParse.cpp \
|
||||
src/script/C4StringTable.cpp \
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
// C4Aul script engine CP conversion
|
||||
// Miscellaneous script engine bits
|
||||
|
||||
#include <C4Include.h>
|
||||
#include <C4Aul.h>
|
||||
|
@ -44,101 +44,6 @@ void C4AulError::show()
|
|||
DebugLog(sMessage.getData());
|
||||
}
|
||||
|
||||
C4AulFunc::C4AulFunc(C4AulScript *pOwner, const char *pName):
|
||||
iRefCnt(0),
|
||||
Name(pName ? Strings.RegString(pName) : 0),
|
||||
MapNext(NULL),
|
||||
OverloadedBy (NULL)
|
||||
{
|
||||
AppendToScript(pOwner);
|
||||
IncRef(); // see C4AulScript::Clear()
|
||||
}
|
||||
|
||||
void C4AulFunc::AppendToScript(C4AulScript * pOwner)
|
||||
{
|
||||
Owner = pOwner;
|
||||
if ((Prev = Owner->FuncL))
|
||||
{
|
||||
Prev->Next = this;
|
||||
Owner->FuncL = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Owner->Func0 = this;
|
||||
Owner->FuncL = this;
|
||||
}
|
||||
Next = NULL;
|
||||
assert(GetName() || Owner->Temporary);
|
||||
// add to global lookuptable with this name
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Add(this, true);
|
||||
}
|
||||
|
||||
void C4AulFunc::RemoveFromScript()
|
||||
{
|
||||
if (Prev) Prev->Next = Next;
|
||||
if (Next) Next->Prev = Prev;
|
||||
if (Owner->Func0 == this) Owner->Func0 = Next;
|
||||
if (Owner->FuncL == this) Owner->FuncL = Prev;
|
||||
assert(Owner);
|
||||
assert(Owner->Temporary || Name);
|
||||
assert(!Owner->GetPropList() || Owner->GetPropList()->GetFunc(Name) != this);
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
Prev = 0;
|
||||
Next = 0;
|
||||
Owner = 0;
|
||||
}
|
||||
|
||||
C4AulFunc::~C4AulFunc()
|
||||
{
|
||||
// remove from list
|
||||
if (Prev) Prev->Next = Next;
|
||||
if (Next) Next->Prev = Prev;
|
||||
if (Owner)
|
||||
{
|
||||
if (Owner->Func0 == this) Owner->Func0 = Next;
|
||||
if (Owner->FuncL == this) Owner->FuncL = Prev;
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
if (Owner->GetPropList() && Name)
|
||||
{
|
||||
C4Value v;
|
||||
Owner->GetPropList()->GetPropertyByS(Name, &v);
|
||||
assert(v.getFunction() != this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StdStrBuf C4AulFunc::GetFullName()
|
||||
{
|
||||
StdStrBuf r;
|
||||
// "lost" function?
|
||||
if (!Owner)
|
||||
{
|
||||
r.Ref("(unowned) ");
|
||||
}
|
||||
else if (Owner->GetPropList() && Owner->GetPropList()->IsStatic())
|
||||
{
|
||||
r.Take(Owner->GetPropList()->IsStatic()->GetDataString());
|
||||
r.AppendChar('.');
|
||||
}
|
||||
else if (Owner == &GameScript)
|
||||
{
|
||||
r.Ref("Scenario.");
|
||||
}
|
||||
else if (Owner->Engine == Owner)
|
||||
{
|
||||
r.Ref("Global.");
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Ref("(unknown) ");
|
||||
}
|
||||
r.Append(Name->GetData());
|
||||
return r;
|
||||
}
|
||||
|
||||
C4AulScript::C4AulScript()
|
||||
{
|
||||
// not compiled
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2001, 2007 Sven Eberhardt
|
||||
* Copyright (c) 2011-2012 Günther Brammer
|
||||
*
|
||||
* Portions might be copyrighted by other authors who have contributed
|
||||
* to OpenClonk.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
* See isc_license.txt for full license and disclaimer.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
#include <C4Include.h>
|
||||
#include <C4Value.h>
|
||||
#include <C4AulFunc.h>
|
||||
#include <C4Aul.h>
|
||||
#include <C4ScriptHost.h>
|
||||
|
||||
C4AulFunc::C4AulFunc(C4AulScript *pOwner, const char *pName):
|
||||
iRefCnt(0),
|
||||
Name(pName ? Strings.RegString(pName) : 0),
|
||||
MapNext(NULL),
|
||||
OverloadedBy (NULL)
|
||||
{
|
||||
AppendToScript(pOwner);
|
||||
IncRef(); // see C4AulScript::Clear()
|
||||
}
|
||||
|
||||
void C4AulFunc::AppendToScript(C4AulScript * pOwner)
|
||||
{
|
||||
Owner = pOwner;
|
||||
if ((Prev = Owner->FuncL))
|
||||
{
|
||||
Prev->Next = this;
|
||||
Owner->FuncL = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Owner->Func0 = this;
|
||||
Owner->FuncL = this;
|
||||
}
|
||||
Next = NULL;
|
||||
assert(GetName() || Owner->Temporary);
|
||||
// add to global lookuptable with this name
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Add(this, true);
|
||||
}
|
||||
|
||||
void C4AulFunc::RemoveFromScript()
|
||||
{
|
||||
if (Prev) Prev->Next = Next;
|
||||
if (Next) Next->Prev = Prev;
|
||||
if (Owner->Func0 == this) Owner->Func0 = Next;
|
||||
if (Owner->FuncL == this) Owner->FuncL = Prev;
|
||||
assert(Owner);
|
||||
assert(Owner->Temporary || Name);
|
||||
assert(!Owner->GetPropList() || Owner->GetPropList()->GetFunc(Name) != this);
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
Prev = 0;
|
||||
Next = 0;
|
||||
Owner = 0;
|
||||
}
|
||||
|
||||
C4AulFunc::~C4AulFunc()
|
||||
{
|
||||
// remove from list
|
||||
if (Prev) Prev->Next = Next;
|
||||
if (Next) Next->Prev = Prev;
|
||||
if (Owner)
|
||||
{
|
||||
if (Owner->Func0 == this) Owner->Func0 = Next;
|
||||
if (Owner->FuncL == this) Owner->FuncL = Prev;
|
||||
if (GetName())
|
||||
Owner->Engine->FuncLookUp.Remove(this);
|
||||
if (Owner->GetPropList() && Name)
|
||||
{
|
||||
C4Value v;
|
||||
Owner->GetPropList()->GetPropertyByS(Name, &v);
|
||||
assert(v.getFunction() != this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StdStrBuf C4AulFunc::GetFullName()
|
||||
{
|
||||
StdStrBuf r;
|
||||
// "lost" function?
|
||||
if (!Owner)
|
||||
{
|
||||
r.Ref("(unowned) ");
|
||||
}
|
||||
else if (Owner->GetPropList() && Owner->GetPropList()->IsStatic())
|
||||
{
|
||||
r.Take(Owner->GetPropList()->IsStatic()->GetDataString());
|
||||
r.AppendChar('.');
|
||||
}
|
||||
else if (Owner == &GameScript)
|
||||
{
|
||||
r.Ref("Scenario.");
|
||||
}
|
||||
else if (Owner->Engine == Owner)
|
||||
{
|
||||
r.Ref("Global.");
|
||||
}
|
||||
else
|
||||
{
|
||||
r.Ref("(unknown) ");
|
||||
}
|
||||
r.Append(Name->GetData());
|
||||
return r;
|
||||
}
|
Loading…
Reference in New Issue