Move C4AulFunc to its own header file

This is necessary since C4Value.h will call a function from C4AulFunc.
Günther Brammer 2012-02-13 18:00:35 +01:00
parent 8091dff419
commit 1e7f32af48
4 changed files with 71 additions and 39 deletions

View File

@ -529,6 +529,7 @@ set(OC_CLONK_SOURCES
src/script/C4AulDefFunc.h
src/script/C4AulExec.cpp
src/script/C4AulExec.h
src/script/C4AulFunc.h
src/script/C4Aul.h
src/script/C4AulLink.cpp
src/script/C4AulParse.cpp

View File

@ -517,6 +517,7 @@ src/script/C4AulDebug.h \
src/script/C4AulDefFunc.h \
src/script/C4AulExec.cpp \
src/script/C4AulExec.h \
src/script/C4AulFunc.h \
src/script/C4Aul.h \
src/script/C4AulLink.cpp \
src/script/C4AulParse.cpp \

View File

@ -29,12 +29,12 @@
#include <C4Id.h>
#include <C4Script.h>
#include <C4StringTable.h>
#include "C4AulFunc.h"
#include <string>
#include <vector>
// consts
#define C4AUL_MAX_Identifier 100 // max length of function identifiers
#define C4AUL_MAX_Par 10 // max number of parameters
// generic C4Aul error class
class C4AulError
@ -205,44 +205,6 @@ struct C4AulScriptContext : public C4AulContext
StdStrBuf ReturnDump(StdStrBuf Dump = StdStrBuf(""));
};
// base function class
class C4AulFunc
{
friend class C4AulScript;
friend class C4AulScriptEngine;
friend class C4AulFuncMap;
friend class C4AulParseState;
friend class C4ScriptHost;
public:
C4AulFunc(C4AulScript *pOwner, const char *pName);
virtual ~C4AulFunc(); // destructor
C4AulScript *Owner; // owner
const char * GetName() const { return Name ? Name->GetCStr() : 0; }
virtual StdStrBuf GetFullName(); // get a fully classified name (C4ID::Name) for debug output
protected:
C4RefCntPointer<C4String> Name; // function name
C4AulFunc *Prev, *Next; // linked list members
C4AulFunc *MapNext; // map member
void AppendToScript(C4AulScript *);
public:
C4AulFunc *OverloadedBy; // function by which this one is overloaded
virtual C4AulScriptFunc *SFunc() { return NULL; } // type check func...
// Wether this function should be visible to players
virtual bool GetPublic() { return false; }
virtual int GetParCount() { return C4AUL_MAX_Par; }
virtual C4V_Type* GetParType() { return 0; }
virtual C4V_Type GetRetType() { return C4V_Any; }
virtual C4Value Exec(C4AulContext *pCallerCtx, C4Value pPars[], bool fPassErrors=false) { return C4Value(); } // execute func (script call)
virtual C4Value Exec(C4PropList * p = NULL, C4AulParSet *pPars = NULL, bool fPassErrors=false); // execute func (engine call)
virtual void UnLink() { OverloadedBy = NULL; }
};
// script function class
class C4AulScriptFunc : public C4AulFunc
{

View File

@ -0,0 +1,68 @@
/*
* OpenClonk, http://www.openclonk.org
*
* Copyright (c) 2001 Sven Eberhardt
* Copyright (c) 2004 Peter Wortmann
* Copyright (c) 2006-2008, 2011-2012 Günther Brammer
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
*
* 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.
*/
#ifndef INC_C4AulFunc
#define INC_C4AulFunc
#include <C4StringTable.h>
#define C4AUL_MAX_Par 10 // max number of parameters
// base function class
class C4AulFunc
{
friend class C4AulScript;
friend class C4AulScriptEngine;
friend class C4AulFuncMap;
friend class C4AulParseState;
friend class C4ScriptHost;
public:
C4AulFunc(C4AulScript *pOwner, const char *pName);
virtual ~C4AulFunc(); // destructor
C4AulScript *Owner; // owner
const char * GetName() const { return Name ? Name->GetCStr() : 0; }
virtual StdStrBuf GetFullName(); // get a fully classified name (C4ID::Name) for debug output
protected:
C4RefCntPointer<C4String> Name; // function name
C4AulFunc *Prev, *Next; // linked list members
C4AulFunc *MapNext; // map member
void AppendToScript(C4AulScript *);
public:
C4AulFunc *OverloadedBy; // function by which this one is overloaded
virtual C4AulScriptFunc *SFunc() { return NULL; } // type check func...
// Wether this function should be visible to players
virtual bool GetPublic() { return false; }
virtual int GetParCount() { return C4AUL_MAX_Par; }
virtual C4V_Type* GetParType() { return 0; }
virtual C4V_Type GetRetType() { return C4V_Any; }
virtual C4Value Exec(C4AulContext *pCallerCtx, C4Value pPars[], bool fPassErrors=false) { return C4Value(); } // execute func (script call)
virtual C4Value Exec(C4PropList * p = NULL, C4AulParSet *pPars = NULL, bool fPassErrors=false); // execute func (engine call)
virtual void UnLink() { OverloadedBy = NULL; }
};
#endif