core/vm/sp_vm_function.h
changeset 327 e244337a9b38
child 348 b30ce8321295
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/core/vm/sp_vm_function.h	Fri Jan 19 08:22:44 2007 +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 "sm_globals.h"
     1.8 +
     1.9 +struct ParamInfo
    1.10 +{
    1.11 +	int flags;			/* Copy-back flags */
    1.12 +	bool marked;		/* Whether this is marked as being used */
    1.13 +	cell_t local_addr;	/* Local address to free */
    1.14 +	cell_t *phys_addr;	/* Physical address of our copy */
    1.15 +	cell_t *orig_addr;	/* Original address to copy back to */
    1.16 +	ucell_t size;		/* Size of array in bytes */
    1.17 +};
    1.18 +
    1.19 +class CPlugin;
    1.20 +
    1.21 +class CFunction : public IPluginFunction
    1.22 +{
    1.23 +	friend class SourcePawnEngine;
    1.24 +public:
    1.25 +	CFunction(funcid_t funcid, IPluginContext *pContext);
    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 PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback);
    1.32 +	virtual int PushString(const char *string);
    1.33 +	virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
    1.34 +	virtual cell_t *GetAddressOfPushedParam(unsigned int param);
    1.35 +	virtual int Execute(cell_t *result);
    1.36 +	virtual void Cancel();
    1.37 +	virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
    1.38 +	virtual IPluginContext *GetParentContext();
    1.39 +public:
    1.40 +	void Set(funcid_t funcid, IPluginContext *plugin);
    1.41 +private:
    1.42 +	int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
    1.43 +	inline int SetError(int err)
    1.44 +	{
    1.45 +		m_errorstate = err;
    1.46 +		return err;
    1.47 +	}
    1.48 +private:
    1.49 +	funcid_t m_funcid;
    1.50 +	IPluginContext *m_pContext;
    1.51 +	cell_t m_params[SP_MAX_EXEC_PARAMS];
    1.52 +	ParamInfo m_info[SP_MAX_EXEC_PARAMS];
    1.53 +	unsigned int m_curparam;
    1.54 +	int m_errorstate;
    1.55 +	CFunction *m_pNext;
    1.56 +};
    1.57 +
    1.58 +#endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_