sourcepawn/jit/sp_vm_function.h
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 2825 811ec7a539c3
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 /**
     2  * vim: set ts=4 sw=4 tw=99 noet :
     3  * =============================================================================
     4  * SourcePawn
     5  * Copyright (C) 2004-2009 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  */
    29 
    30 #ifndef _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
    31 #define _INCLUDE_SOURCEMOD_BASEFUNCTION_H_
    32 
    33 #include <sp_vm_api.h>
    34 
    35 class BaseRuntime;
    36 
    37 using namespace SourcePawn;
    38 
    39 struct ParamInfo
    40 {
    41 	int flags;			/* Copy-back flags */
    42 	bool marked;		/* Whether this is marked as being used */
    43 	cell_t local_addr;	/* Local address to free */
    44 	cell_t *phys_addr;	/* Physical address of our copy */
    45 	cell_t *orig_addr;	/* Original address to copy back to */
    46 	ucell_t size;		/* Size of array in bytes */
    47 	struct
    48 	{
    49 		bool is_sz;		/* is a string */
    50 		int sz_flags;	/* has sz flags */
    51 	} str;
    52 };
    53 
    54 class CPlugin;
    55 class JitFunction;
    56 
    57 class CFunction : public IPluginFunction
    58 {
    59 	friend class SourcePawnEngine;
    60 public:
    61 	CFunction(BaseRuntime *pRuntime, 
    62 			  funcid_t fnid,
    63 			  uint32_t pub_id);
    64 public:
    65 	virtual int PushCell(cell_t cell);
    66 	virtual int PushCellByRef(cell_t *cell, int flags);
    67 	virtual int PushFloat(float number);
    68 	virtual int PushFloatByRef(float *number, int flags);
    69 	virtual int PushArray(cell_t *inarray, unsigned int cells, int copyback);
    70 	virtual int PushString(const char *string);
    71 	virtual int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
    72 	virtual int Execute(cell_t *result);
    73 	virtual void Cancel();
    74 	virtual int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
    75 	virtual IPluginContext *GetParentContext();
    76 	bool IsRunnable();
    77 	funcid_t GetFunctionID();
    78 	int Execute2(IPluginContext *ctx, cell_t *result);
    79 	int CallFunction2(IPluginContext *ctx, 
    80 		const cell_t *params, 
    81 		unsigned int num_params, 
    82 		cell_t *result);
    83 	IPluginRuntime *GetParentRuntime();
    84 public:
    85 	void Set(BaseRuntime *runtime, funcid_t fnid, uint32_t pub_id);
    86 private:
    87 	int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
    88 	int SetError(int err);
    89 private:
    90 	BaseRuntime *m_pRuntime;
    91 	cell_t m_params[SP_MAX_EXEC_PARAMS];
    92 	ParamInfo m_info[SP_MAX_EXEC_PARAMS];
    93 	unsigned int m_curparam;
    94 	int m_errorstate;
    95 	funcid_t m_FnId;
    96 };
    97 
    98 #endif //_INCLUDE_SOURCEMOD_BASEFUNCTION_H_