1.1 --- a/core/vm/sp_vm_basecontext.h Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,122 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourcePawn
1.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#ifndef _INCLUDE_SOURCEPAWN_BASECONTEXT_H_
1.36 -#define _INCLUDE_SOURCEPAWN_BASECONTEXT_H_
1.37 -
1.38 -#include "sp_vm_api.h"
1.39 -#include "sp_vm_function.h"
1.40 -
1.41 -/**
1.42 - * :TODO: Make functions allocate as a lump instead of individual allocations!
1.43 - */
1.44 -
1.45 -namespace SourcePawn
1.46 -{
1.47 - class BaseContext :
1.48 - public IPluginContext,
1.49 - public IPluginDebugInfo
1.50 - {
1.51 - public:
1.52 - BaseContext(sp_context_t *ctx);
1.53 - ~BaseContext();
1.54 - public: //IPluginContext
1.55 - IVirtualMachine *GetVirtualMachine();
1.56 - sp_context_t *GetContext();
1.57 - bool IsDebugging();
1.58 - int SetDebugBreak(SPVM_DEBUGBREAK newpfn, SPVM_DEBUGBREAK *oldpfn);
1.59 - IPluginDebugInfo *GetDebugInfo();
1.60 - int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr);
1.61 - int HeapPop(cell_t local_addr);
1.62 - int HeapRelease(cell_t local_addr);
1.63 - int FindNativeByName(const char *name, uint32_t *index);
1.64 - int GetNativeByIndex(uint32_t index, sp_native_t **native);
1.65 - uint32_t GetNativesNum();
1.66 - int FindPublicByName(const char *name, uint32_t *index);
1.67 - int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
1.68 - uint32_t GetPublicsNum();
1.69 - int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
1.70 - int FindPubvarByName(const char *name, uint32_t *index);
1.71 - int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
1.72 - uint32_t GetPubVarsNum();
1.73 - int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr);
1.74 - int LocalToString(cell_t local_addr, char **addr);
1.75 - int StringToLocal(cell_t local_addr, size_t chars, const char *source);
1.76 - int StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes);
1.77 - int PushCell(cell_t value);
1.78 - int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells);
1.79 - int PushString(cell_t *local_addr, char **phys_addr, const char *string);
1.80 - int PushCellsFromArray(cell_t array[], unsigned int numcells);
1.81 - int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite);
1.82 - int BindNative(const sp_nativeinfo_t *native);
1.83 - int BindNativeToAny(SPVM_NATIVE_FUNC native);
1.84 - int Execute(uint32_t code_addr, cell_t *result);
1.85 - cell_t ThrowNativeErrorEx(int error, const char *msg, ...);
1.86 - cell_t ThrowNativeError(const char *msg, ...);
1.87 - IPluginFunction *GetFunctionByName(const char *public_name);
1.88 - IPluginFunction *GetFunctionById(funcid_t func_id);
1.89 -#if defined SOURCEMOD_BUILD
1.90 - SourceMod::IdentityToken_t *GetIdentity();
1.91 - void SetIdentity(SourceMod::IdentityToken_t *token);
1.92 - cell_t *GetNullRef(SP_NULL_TYPE type);
1.93 - int LocalToStringNULL(cell_t local_addr, char **addr);
1.94 -#endif
1.95 - int BindNativeToIndex(uint32_t index, SPVM_NATIVE_FUNC native);
1.96 - public: //IPluginDebugInfo
1.97 - int LookupFile(ucell_t addr, const char **filename);
1.98 - int LookupFunction(ucell_t addr, const char **name);
1.99 - int LookupLine(ucell_t addr, uint32_t *line);
1.100 - public:
1.101 - void SetContext(sp_context_t *_ctx);
1.102 - bool IsInExec();
1.103 - private:
1.104 - void SetErrorMessage(const char *msg, va_list ap);
1.105 - void FlushFunctionCache();
1.106 - void RefreshFunctionCache();
1.107 - private:
1.108 - sp_context_t *ctx;
1.109 -#if defined SOURCEMOD_BUILD
1.110 - SourceMod::IdentityToken_t *m_pToken;
1.111 - cell_t *m_pNullVec;
1.112 - cell_t *m_pNullString;
1.113 -#endif
1.114 - char m_MsgCache[1024];
1.115 - bool m_CustomMsg;
1.116 - bool m_InExec;
1.117 - unsigned int m_funcsnum;
1.118 -#if 0
1.119 - CFunction **m_priv_funcs;
1.120 -#endif
1.121 - CFunction **m_pub_funcs;
1.122 - };
1.123 -};
1.124 -
1.125 -#endif //_INCLUDE_SOURCEPAWN_BASECONTEXT_H_