1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/core/NativeOwner.h Mon May 26 07:52:27 2008 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +#ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
1.5 +#define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_
1.6 +
1.7 +#include <sp_vm_types.h>
1.8 +#include <sh_list.h>
1.9 +
1.10 +class CPlugin;
1.11 +struct NativeEntry;
1.12 +
1.13 +struct WeakNative
1.14 +{
1.15 + WeakNative(CPlugin *plugin, uint32_t index) :
1.16 + pl(plugin), idx(index), entry(NULL)
1.17 + {
1.18 + pl = plugin;
1.19 + idx = index;
1.20 + }
1.21 + WeakNative(CPlugin *plugin, uint32_t index, NativeEntry *pEntry) :
1.22 + pl(plugin), idx(index), entry(pEntry)
1.23 + {
1.24 + pl = plugin;
1.25 + idx = index;
1.26 + }
1.27 + CPlugin *pl;
1.28 + uint32_t idx;
1.29 + NativeEntry *entry;
1.30 +};
1.31 +
1.32 +using namespace SourceHook;
1.33 +
1.34 +class CNativeOwner
1.35 +{
1.36 +public:
1.37 + virtual void DropEverything();
1.38 +public:
1.39 + void AddNatives(const sp_nativeinfo_t *info);
1.40 +public:
1.41 + void SetMarkSerial(unsigned int serial);
1.42 + unsigned int GetMarkSerial();
1.43 + void PropogateMarkSerial(unsigned int serial);
1.44 +public:
1.45 + void AddDependent(CPlugin *pPlugin);
1.46 + void AddWeakRef(const WeakNative & ref);
1.47 + void DropRefsTo(CPlugin *pPlugin);
1.48 + void AddReplacedNative(NativeEntry *pEntry);
1.49 +private:
1.50 + void DropWeakRefsTo(CPlugin *pPlugin);
1.51 + void UnbindWeakRef(const WeakNative & ref);
1.52 +protected:
1.53 + List<CPlugin *> m_Dependents;
1.54 + unsigned int m_nMarkSerial;
1.55 + List<WeakNative> m_WeakRefs;
1.56 + List<NativeEntry *> m_Natives;
1.57 + List<NativeEntry *> m_ReplacedNatives;
1.58 +};
1.59 +
1.60 +#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_