| author | Nicholas Hastings <skamonkey@gmail.com> |
| Wed Aug 14 14:20:57 2013 -0400 (2013-08-14) | |
| changeset 4008 | 490b01aa0683 |
| parent 3872 | 4c93f74cae51 |
| child 4106 | a39557bde4ac |
| permissions | -rw-r--r-- |
| dvander@2088 | 1 |
#ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |
| dvander@2088 | 2 |
#define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |
| dvander@2088 | 3 |
|
| dvander@2088 | 4 |
#include <sp_vm_types.h> |
| dvander@2088 | 5 |
#include <sh_list.h> |
| dvander@3872 | 6 |
#include "common_logic.h" |
| dvander@2088 | 7 |
|
| dvander@3872 | 8 |
struct NativeEntry; |
| dvander@2088 | 9 |
class CPlugin; |
| dvander@3872 | 10 |
|
| dvander@3872 | 11 |
using namespace SourceMod; |
| dvander@2088 | 12 |
|
| dvander@2088 | 13 |
struct WeakNative |
| dvander@2088 | 14 |
{ |
| dvander@3872 | 15 |
WeakNative(IPlugin *plugin, uint32_t index) : |
| dvander@2088 | 16 |
pl(plugin), idx(index), entry(NULL) |
| dvander@2088 | 17 |
{ |
| dvander@2088 | 18 |
pl = plugin; |
| dvander@2088 | 19 |
idx = index; |
| dvander@2088 | 20 |
} |
| dvander@3872 | 21 |
WeakNative(IPlugin *plugin, uint32_t index, NativeEntry *pEntry) : |
| dvander@2088 | 22 |
pl(plugin), idx(index), entry(pEntry) |
| dvander@2088 | 23 |
{ |
| dvander@2088 | 24 |
pl = plugin; |
| dvander@2088 | 25 |
idx = index; |
| dvander@2088 | 26 |
} |
| dvander@3872 | 27 |
IPlugin *pl; |
| dvander@2088 | 28 |
uint32_t idx; |
| dvander@2088 | 29 |
NativeEntry *entry; |
| dvander@2088 | 30 |
}; |
| dvander@2088 | 31 |
|
| dvander@2088 | 32 |
using namespace SourceHook; |
| dvander@2088 | 33 |
|
| dvander@2088 | 34 |
class CNativeOwner |
| dvander@2088 | 35 |
{ |
| dvander@2088 | 36 |
public: |
| dvander@2226 | 37 |
CNativeOwner(); |
| dvander@2226 | 38 |
public: |
| dvander@2088 | 39 |
virtual void DropEverything(); |
| dvander@2088 | 40 |
public: |
| dvander@2088 | 41 |
void AddNatives(const sp_nativeinfo_t *info); |
| dvander@2088 | 42 |
public: |
| dvander@2088 | 43 |
void SetMarkSerial(unsigned int serial); |
| dvander@2088 | 44 |
unsigned int GetMarkSerial(); |
| dvander@3872 | 45 |
void PropagateMarkSerial(unsigned int serial); |
| dvander@2088 | 46 |
public: |
| dvander@2088 | 47 |
void AddDependent(CPlugin *pPlugin); |
| dvander@2088 | 48 |
void AddWeakRef(const WeakNative & ref); |
| dvander@2088 | 49 |
void DropRefsTo(CPlugin *pPlugin); |
| dvander@2088 | 50 |
void AddReplacedNative(NativeEntry *pEntry); |
| dvander@2088 | 51 |
private: |
| dvander@2088 | 52 |
void DropWeakRefsTo(CPlugin *pPlugin); |
| dvander@2088 | 53 |
void UnbindWeakRef(const WeakNative & ref); |
| dvander@2088 | 54 |
protected: |
| dvander@2088 | 55 |
List<CPlugin *> m_Dependents; |
| dvander@2088 | 56 |
unsigned int m_nMarkSerial; |
| dvander@2088 | 57 |
List<WeakNative> m_WeakRefs; |
| dvander@2088 | 58 |
List<NativeEntry *> m_Natives; |
| dvander@2088 | 59 |
List<NativeEntry *> m_ReplacedNatives; |
| dvander@2088 | 60 |
}; |
| dvander@2088 | 61 |
|
| dvander@3872 | 62 |
extern CNativeOwner g_CoreNatives; |
| dvander@3872 | 63 |
|
| dvander@2088 | 64 |
#endif //_INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ |