2007-01-25 23:39:12 +01:00
|
|
|
/**
|
2007-03-22 22:50:20 +01:00
|
|
|
* vim: set ts=4 :
|
2007-01-25 23:39:12 +01:00
|
|
|
* ================================================================
|
2007-08-01 04:12:47 +02:00
|
|
|
* SourcePawn
|
|
|
|
* Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
|
2007-01-25 23:39:12 +01:00
|
|
|
* ================================================================
|
|
|
|
*
|
2007-08-01 04:12:47 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License,
|
|
|
|
* version 3.0, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to
|
|
|
|
* link the code of this program (as well as its derivative works) to
|
|
|
|
* "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
|
|
|
|
* Game MODs that run on software by the Valve Corporation. You must
|
|
|
|
* obey the GNU General Public License in all respects for all other
|
|
|
|
* code used. Additionally, AlliedModders LLC grants this exception
|
|
|
|
* to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version
|
|
|
|
* JULY-31-2007), or <http://www.sourcemod.net/license.php>.
|
2007-01-25 23:39:12 +01:00
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
|
|
|
|
2007-01-19 09:22:44 +01:00
|
|
|
#ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
|
|
|
|
|
|
|
|
#include "sm_globals.h"
|
|
|
|
|
|
|
|
struct ParamInfo
|
|
|
|
{
|
|
|
|
int flags; /* Copy-back flags */
|
|
|
|
bool marked; /* Whether this is marked as being used */
|
|
|
|
cell_t local_addr; /* Local address to free */
|
|
|
|
cell_t *phys_addr; /* Physical address of our copy */
|
|
|
|
cell_t *orig_addr; /* Original address to copy back to */
|
|
|
|
ucell_t size; /* Size of array in bytes */
|
2007-03-10 22:02:40 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool is_sz; /* is a string */
|
|
|
|
int sz_flags; /* has sz flags */
|
|
|
|
} str;
|
2007-01-19 09:22:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class CPlugin;
|
|
|
|
|
|
|
|
class CFunction : public IPluginFunction
|
|
|
|
{
|
|
|
|
friend class SourcePawnEngine;
|
|
|
|
public:
|
2007-01-25 07:21:20 +01:00
|
|
|
CFunction(uint32_t code_addr, IPluginContext *pContext);
|
2007-01-19 09:22:44 +01:00
|
|
|
public:
|
|
|
|
virtual int PushCell(cell_t cell);
|
2007-03-07 19:37:41 +01:00
|
|
|
virtual int PushCellByRef(cell_t *cell, int flags);
|
2007-01-19 09:22:44 +01:00
|
|
|
virtual int PushFloat(float number);
|
2007-03-07 19:37:41 +01:00
|
|
|
virtual int PushFloatByRef(float *number, int flags);
|
2007-03-10 22:02:40 +01:00
|
|
|
virtual int PushArray(cell_t *inarray, unsigned int cells, int copyback);
|
2007-01-19 09:22:44 +01:00
|
|
|
virtual int PushString(const char *string);
|
|
|
|
virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
|
|
|
|
virtual int Execute(cell_t *result);
|
|
|
|
virtual void Cancel();
|
|
|
|
virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
|
|
|
|
virtual IPluginContext *GetParentContext();
|
2007-02-16 05:16:31 +01:00
|
|
|
inline bool IsInvalidated()
|
|
|
|
{
|
|
|
|
return m_Invalid;
|
|
|
|
}
|
|
|
|
inline void Invalidate()
|
|
|
|
{
|
|
|
|
m_Invalid = true;
|
|
|
|
}
|
2007-02-22 03:05:50 +01:00
|
|
|
bool IsRunnable();
|
2007-01-19 09:22:44 +01:00
|
|
|
public:
|
2007-01-25 07:21:20 +01:00
|
|
|
void Set(uint32_t code_addr, IPluginContext *plugin);
|
2007-01-19 09:22:44 +01:00
|
|
|
private:
|
|
|
|
int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
|
|
|
|
inline int SetError(int err)
|
|
|
|
{
|
|
|
|
m_errorstate = err;
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
private:
|
2007-01-25 07:21:20 +01:00
|
|
|
uint32_t m_codeaddr;
|
2007-01-19 09:22:44 +01:00
|
|
|
IPluginContext *m_pContext;
|
2007-02-22 03:05:50 +01:00
|
|
|
sp_context_t *m_pCtx;
|
2007-01-19 09:22:44 +01:00
|
|
|
cell_t m_params[SP_MAX_EXEC_PARAMS];
|
|
|
|
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
|
|
|
|
unsigned int m_curparam;
|
|
|
|
int m_errorstate;
|
|
|
|
CFunction *m_pNext;
|
2007-02-16 05:16:31 +01:00
|
|
|
bool m_Invalid;
|
2007-01-19 09:22:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_
|