core/systems/CFunction.h
changeset 177 d29ade52d953
child 183 78488edd8873
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/systems/CFunction.h	Sat Nov 11 11:10:24 2006 +0000
     1.3 @@ -0,0 +1,55 @@
     1.4 +#ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
     1.5 +#define _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
     1.6 +
     1.7 +#include <IPluginFunction.h>
     1.8 +#include "sm_globals.h"
     1.9 +
    1.10 +struct ParamInfo
    1.11 +{
    1.12 +	int flags;			/* Copy-back flags */
    1.13 +	bool marked;		/* Whether this is marked as being used */
    1.14 +	cell_t local_addr;	/* Local address to free */
    1.15 +	cell_t *phys_addr;	/* Physical address of our copy */
    1.16 +	cell_t *orig_addr;	/* Original address to copy back to */
    1.17 +	ucell_t size;		/* Size of array in cells */
    1.18 +};
    1.19 +
    1.20 +class CPlugin;
    1.21 +
    1.22 +class CFunction : public IPluginFunction
    1.23 +{
    1.24 +public:
    1.25 +	CFunction(funcid_t funcid, CPlugin *plugin);
    1.26 +public:
    1.27 +	virtual int PushCell(cell_t cell);
    1.28 +	virtual int PushCellByRef(cell_t *cell, int flags);
    1.29 +	virtual int PushFloat(float number);
    1.30 +	virtual int PushFloatByRef(float *number, int flags);
    1.31 +	virtual int PushCells(cell_t array[], unsigned int numcells, bool each);
    1.32 +	virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback);
    1.33 +	virtual int PushString(const char *string);
    1.34 +	virtual int PushStringByRef(char *string, int flags);
    1.35 +	virtual cell_t *GetAddressOfPushedParam(unsigned int param);
    1.36 +	virtual int Execute(cell_t *result, IFunctionCopybackReader *reader);
    1.37 +	virtual void Cancel();
    1.38 +	virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
    1.39 +	virtual IPlugin *GetParentPlugin();
    1.40 +public:
    1.41 +	void Set(funcid_t funcid, CPlugin *plugin);
    1.42 +private:
    1.43 +	int _PushString(const char *string, int flags);
    1.44 +	inline int SetError(int err)
    1.45 +	{
    1.46 +		m_errorstate = err;
    1.47 +		return err;
    1.48 +	}
    1.49 +private:
    1.50 +	funcid_t m_funcid;
    1.51 +	CPlugin *m_pPlugin;
    1.52 +	cell_t m_params[SP_MAX_EXEC_PARAMS];
    1.53 +	ParamInfo m_info[SP_MAX_EXEC_PARAMS];
    1.54 +	unsigned int m_curparam;
    1.55 +	int m_errorstate;
    1.56 +};
    1.57 +
    1.58 +#endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_