1.1 --- a/core/systems/PluginSys.h Mon May 26 07:48:26 2008 +0000
1.2 +++ b/core/systems/PluginSys.h Mon May 26 07:51:11 2008 +0000
1.3 @@ -54,6 +54,8 @@
1.4 #include "convar_sm.h"
1.5 #endif
1.6 #include "ITranslator.h"
1.7 +#include "NativeOwner.h"
1.8 +#include "ShareSys.h"
1.9
1.10 using namespace SourceHook;
1.11
1.12 @@ -120,14 +122,6 @@
1.13 IVirtualMachine *vm;
1.14 };
1.15
1.16 -struct FakeNative
1.17 -{
1.18 - IPluginContext *ctx;
1.19 - IPluginFunction *call;
1.20 - String name;
1.21 - SPVM_NATIVE_FUNC func;
1.22 -};
1.23 -
1.24 enum LoadRes
1.25 {
1.26 LoadRes_Successful,
1.27 @@ -144,18 +138,10 @@
1.28 };
1.29
1.30 class CPlugin;
1.31 -struct WeakNative
1.32 -{
1.33 - WeakNative(CPlugin *plugin, uint32_t index)
1.34 - {
1.35 - pl = plugin;
1.36 - idx = index;
1.37 - }
1.38 - CPlugin *pl;
1.39 - uint32_t idx;
1.40 -};
1.41
1.42 -class CPlugin : public IPlugin
1.43 +class CPlugin :
1.44 + public IPlugin,
1.45 + public CNativeOwner
1.46 {
1.47 friend class CPluginManager;
1.48 friend class CFunction;
1.49 @@ -177,6 +163,7 @@
1.50 unsigned int CalcMemUsage();
1.51 bool SetProperty(const char *prop, void *ptr);
1.52 bool GetProperty(const char *prop, void **ptr, bool remove=false);
1.53 + void DropEverything();
1.54 public:
1.55 /**
1.56 * Creates a plugin object with default values.
1.57 @@ -266,6 +253,7 @@
1.58
1.59 Handle_t GetMyHandle();
1.60
1.61 + bool AddFakeNative(IPluginFunction *pFunc, const char *name, SPVM_FAKENATIVE_FUNC func);
1.62 void AddConfig(bool autoCreate, const char *cfg, const char *folder);
1.63 unsigned int GetConfigCount();
1.64 AutoConfig *GetConfig(unsigned int i);
1.65 @@ -292,10 +280,6 @@
1.66 Handle_t m_handle;
1.67 bool m_WasRunning;
1.68 IPhraseCollection *m_pPhrases;
1.69 - List<CPlugin *> m_dependents;
1.70 - List<CPlugin *> m_dependsOn;
1.71 - List<FakeNative *> m_fakeNatives;
1.72 - List<WeakNative> m_WeakNatives;
1.73 List<String> m_RequiredLibs;
1.74 List<String> m_Libraries;
1.75 Trie *m_pProps;
1.76 @@ -382,11 +366,6 @@
1.77 bool IsLateLoadTime() const;
1.78
1.79 /**
1.80 - * Adds natives from core into the native pool.
1.81 - */
1.82 - void RegisterNativesFromCore(sp_nativeinfo_t *natives);
1.83 -
1.84 - /**
1.85 * Converts a Handle to an IPlugin if possible.
1.86 */
1.87 IPlugin *PluginFromHandle(Handle_t handle, HandleError *err);
1.88 @@ -461,11 +440,6 @@
1.89 bool RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength);
1.90
1.91 /**
1.92 - * Adds any globally registered natives to a plugin
1.93 - */
1.94 - void AddCoreNativesToPlugin(CPlugin *pPlugin);
1.95 -
1.96 - /**
1.97 * Runs an extension pass on a plugin.
1.98 */
1.99 bool LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass, char *error, size_t maxlength);
1.100 @@ -486,11 +460,7 @@
1.101 {
1.102 return m_MyIdent;
1.103 }
1.104 -public:
1.105 - bool AddFakeNative(IPluginFunction *pFunction, const char *name, SPVM_FAKENATIVE_FUNC func);
1.106 - SPVM_NATIVE_FUNC FindCoreNative(const char *name);
1.107 private:
1.108 - void AddFakeNativesToPlugin(CPlugin *pPlugin);
1.109 void TryRefreshDependencies(CPlugin *pOther);
1.110 private:
1.111 List<IPluginsListener *> m_listeners;
1.112 @@ -500,11 +470,9 @@
1.113 Trie *m_LoadLookup;
1.114 bool m_AllPluginsLoaded;
1.115 IdentityToken_t *m_MyIdent;
1.116 - Trie *m_pCoreNatives;
1.117
1.118 /* Dynamic native stuff */
1.119 List<FakeNative *> m_Natives;
1.120 - Trie *m_pNativeLookup;
1.121
1.122 bool m_LoadingLocked;
1.123 };