core/vm/sp_vm_function.h
author David Anderson <dvander@alliedmods.net>
Fri Jan 19 08:22:44 2007 +0000 (2007-01-19)
changeset 327 e244337a9b38
child 348 b30ce8321295
permissions -rw-r--r--
finished massive reorganization - IPluginFunction is now part of the VM, NOT the plugin system! This is how it should have been in the first place...
     1 #ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
     2 #define _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
     3 
     4 #include "sm_globals.h"
     5 
     6 struct ParamInfo
     7 {
     8 	int flags;			/* Copy-back flags */
     9 	bool marked;		/* Whether this is marked as being used */
    10 	cell_t local_addr;	/* Local address to free */
    11 	cell_t *phys_addr;	/* Physical address of our copy */
    12 	cell_t *orig_addr;	/* Original address to copy back to */
    13 	ucell_t size;		/* Size of array in bytes */
    14 };
    15 
    16 class CPlugin;
    17 
    18 class CFunction : public IPluginFunction
    19 {
    20 	friend class SourcePawnEngine;
    21 public:
    22 	CFunction(funcid_t funcid, IPluginContext *pContext);
    23 public:
    24 	virtual int PushCell(cell_t cell);
    25 	virtual int PushCellByRef(cell_t *cell, int flags);
    26 	virtual int PushFloat(float number);
    27 	virtual int PushFloatByRef(float *number, int flags);
    28 	virtual int PushArray(cell_t *inarray, unsigned int cells, cell_t **phys_addr, int copyback);
    29 	virtual int PushString(const char *string);
    30 	virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
    31 	virtual cell_t *GetAddressOfPushedParam(unsigned int param);
    32 	virtual int Execute(cell_t *result);
    33 	virtual void Cancel();
    34 	virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
    35 	virtual IPluginContext *GetParentContext();
    36 public:
    37 	void Set(funcid_t funcid, IPluginContext *plugin);
    38 private:
    39 	int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
    40 	inline int SetError(int err)
    41 	{
    42 		m_errorstate = err;
    43 		return err;
    44 	}
    45 private:
    46 	funcid_t m_funcid;
    47 	IPluginContext *m_pContext;
    48 	cell_t m_params[SP_MAX_EXEC_PARAMS];
    49 	ParamInfo m_info[SP_MAX_EXEC_PARAMS];
    50 	unsigned int m_curparam;
    51 	int m_errorstate;
    52 	CFunction *m_pNext;
    53 };
    54 
    55 #endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_