1.1 --- a/core/ShareSys.h Fri Mar 29 12:28:02 2013 -0400
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,164 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2008 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_SOURCEMOD_SHARESYSTEM_H_
1.36 -#define _INCLUDE_SOURCEMOD_SHARESYSTEM_H_
1.37 -
1.38 -#include <IShareSys.h>
1.39 -#include <IHandleSys.h>
1.40 -#include <sh_list.h>
1.41 -#include <sm_trie_tpl.h>
1.42 -#include "sm_globals.h"
1.43 -#include "sourcemod.h"
1.44 -
1.45 -using namespace SourceHook;
1.46 -
1.47 -namespace SourceMod
1.48 -{
1.49 - struct IdentityToken_t
1.50 - {
1.51 - Handle_t ident;
1.52 - void *ptr;
1.53 - IdentityType_t type;
1.54 - };
1.55 -};
1.56 -
1.57 -struct IfaceInfo
1.58 -{
1.59 - bool operator ==(const IfaceInfo &info)
1.60 - {
1.61 - return (info.iface == iface && info.owner == owner);
1.62 - }
1.63 - SMInterface *iface;
1.64 - IExtension *owner;
1.65 -};
1.66 -
1.67 -class CNativeOwner;
1.68 -class CPlugin;
1.69 -struct NativeEntry;
1.70 -
1.71 -struct ReplaceNative
1.72 -{
1.73 - CNativeOwner *owner;
1.74 - SPVM_NATIVE_FUNC func;
1.75 -};
1.76 -
1.77 -struct FakeNative
1.78 -{
1.79 - char name[64];
1.80 - IPluginContext *ctx;
1.81 - IPluginFunction *call;
1.82 -};
1.83 -
1.84 -struct NativeEntry
1.85 -{
1.86 - CNativeOwner *owner;
1.87 - SPVM_NATIVE_FUNC func;
1.88 - const char *name;
1.89 - ReplaceNative replacement;
1.90 - FakeNative *fake;
1.91 -};
1.92 -
1.93 -struct Capability
1.94 -{
1.95 - IExtension *ext;
1.96 - IFeatureProvider *provider;
1.97 -};
1.98 -
1.99 -class ShareSystem :
1.100 - public IShareSys,
1.101 - public SMGlobalClass,
1.102 - public IHandleTypeDispatch
1.103 -{
1.104 - friend class CNativeOwner;
1.105 -public:
1.106 - ShareSystem();
1.107 -public: //IShareSys
1.108 - bool AddInterface(IExtension *myself, SMInterface *pIface);
1.109 - bool RequestInterface(const char *iface_name,
1.110 - unsigned int iface_vers,
1.111 - IExtension *myself,
1.112 - SMInterface **pIface);
1.113 - void AddNatives(IExtension *myself, const sp_nativeinfo_t *natives);
1.114 - IdentityType_t CreateIdentType(const char *name);
1.115 - IdentityType_t FindIdentType(const char *name);
1.116 - IdentityToken_t *CreateIdentity(IdentityType_t type, void *ptr);
1.117 - void DestroyIdentType(IdentityType_t type);
1.118 - void DestroyIdentity(IdentityToken_t *identity);
1.119 - void AddDependency(IExtension *myself, const char *filename, bool require, bool autoload);
1.120 - void RegisterLibrary(IExtension *myself, const char *name);
1.121 - void OverrideNatives(IExtension *myself, const sp_nativeinfo_t *natives);
1.122 - void AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
1.123 - const char *name);
1.124 - void DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
1.125 - const char *name);
1.126 -public: //SMGlobalClass
1.127 - /* Pre-empt in case anything tries to register idents early */
1.128 - void Initialize();
1.129 - void OnSourceModShutdown();
1.130 -public: //IHandleTypeDispatch
1.131 - void OnHandleDestroy(HandleType_t type, void *object);
1.132 -public:
1.133 - IdentityToken_t *CreateCoreIdentity();
1.134 - void RemoveInterfaces(IExtension *pExtension);
1.135 - FeatureStatus TestFeature(IPluginRuntime *pRuntime, FeatureType feature, const char *name);
1.136 - FeatureStatus TestNative(IPluginRuntime *pRuntime, const char *name);
1.137 - FeatureStatus TestCap(const char *name);
1.138 -public:
1.139 - inline IdentityToken_t *GetIdentRoot()
1.140 - {
1.141 - return &m_IdentRoot;
1.142 - }
1.143 -public:
1.144 - void BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly);
1.145 - void BindNativeToPlugin(CPlugin *pPlugin, NativeEntry *pEntry);
1.146 - NativeEntry *AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKENATIVE_FUNC func);
1.147 - NativeEntry *FindNative(const char *name);
1.148 -private:
1.149 - NativeEntry *AddNativeToCache(CNativeOwner *pOwner, const sp_nativeinfo_t *ntv);
1.150 - void ClearNativeFromCache(CNativeOwner *pOwner, const char *name);
1.151 - void BindNativeToPlugin(CPlugin *pPlugin,
1.152 - sp_native_t *ntv,
1.153 - uint32_t index,
1.154 - NativeEntry *pEntry);
1.155 -private:
1.156 - List<IfaceInfo> m_Interfaces;
1.157 - HandleType_t m_TypeRoot;
1.158 - IdentityToken_t m_IdentRoot;
1.159 - HandleType_t m_IfaceType;
1.160 - IdentityType_t m_CoreType;
1.161 - KTrie<NativeEntry *> m_NtvCache;
1.162 - KTrie<Capability> m_caps;
1.163 -};
1.164 -
1.165 -extern ShareSystem g_ShareSys;
1.166 -
1.167 -#endif //_INCLUDE_SOURCEMOD_SHARESYSTEM_H_