core/NativeOwner.cpp
changeset 3872 4c93f74cae51
parent 3871 4edce76aefe3
child 3873 a496ff7c2aad
     1.1 --- a/core/NativeOwner.cpp	Fri Mar 29 12:28:02 2013 -0400
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,144 +0,0 @@
     1.4 -#include "NativeOwner.h"
     1.5 -#include "ShareSys.h"
     1.6 -#include "PluginSys.h"
     1.7 -
     1.8 -CNativeOwner::CNativeOwner() : m_nMarkSerial(0)
     1.9 -{
    1.10 -}
    1.11 -
    1.12 -void CNativeOwner::SetMarkSerial(unsigned int serial)
    1.13 -{
    1.14 -	m_nMarkSerial = serial;
    1.15 -}
    1.16 -
    1.17 -unsigned int CNativeOwner::GetMarkSerial()
    1.18 -{
    1.19 -	return m_nMarkSerial;
    1.20 -}
    1.21 -
    1.22 -void CNativeOwner::AddDependent(CPlugin *pPlugin)
    1.23 -{
    1.24 -	m_Dependents.push_back(pPlugin);
    1.25 -}
    1.26 -
    1.27 -void CNativeOwner::AddWeakRef(const WeakNative & ref)
    1.28 -{
    1.29 -	m_WeakRefs.push_back(ref);
    1.30 -}
    1.31 -
    1.32 -void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives)
    1.33 -{
    1.34 -	NativeEntry *pEntry;
    1.35 -
    1.36 -	for (unsigned int i = 0; natives[i].func != NULL && natives[i].name != NULL; i++)
    1.37 -	{
    1.38 -		if ((pEntry = g_ShareSys.AddNativeToCache(this, &natives[i])) == NULL)
    1.39 -		{
    1.40 -			continue;
    1.41 -		}
    1.42 -
    1.43 -		m_Natives.push_back(pEntry);
    1.44 -	}
    1.45 -}
    1.46 -
    1.47 -void CNativeOwner::PropogateMarkSerial(unsigned int serial)
    1.48 -{
    1.49 -	CNativeOwner *pOwner;
    1.50 -	List<CPlugin *>::iterator iter;
    1.51 -
    1.52 -	for (iter = m_Dependents.begin();
    1.53 -		 iter != m_Dependents.end();
    1.54 -		 iter++)
    1.55 -	{
    1.56 -		pOwner = (*iter);
    1.57 -		pOwner->SetMarkSerial(serial);
    1.58 -	}
    1.59 -}
    1.60 -
    1.61 -void CNativeOwner::UnbindWeakRef(const WeakNative & ref)
    1.62 -{
    1.63 -	sp_native_t *native;
    1.64 -	IPluginContext *pContext;
    1.65 -
    1.66 -	pContext = ref.pl->GetBaseContext();
    1.67 -	if ((pContext->GetNativeByIndex(ref.idx, &native)) == SP_ERROR_NONE)
    1.68 -	{
    1.69 -		/* If there is no reference, the native must be unbound */
    1.70 -		if (ref.entry == NULL)
    1.71 -		{
    1.72 -			native->status = SP_NATIVE_UNBOUND;
    1.73 -			native->pfn = NULL;
    1.74 -		}
    1.75 -		/* If we've cached a reference, it's a core native we can 
    1.76 -		 * rebind back to its original (this was a replacement).
    1.77 -		 */
    1.78 -		else
    1.79 -		{
    1.80 -			native->pfn = ref.entry->func;
    1.81 -		}
    1.82 -	}
    1.83 -}
    1.84 -
    1.85 -void CNativeOwner::DropEverything()
    1.86 -{
    1.87 -	NativeEntry *pEntry;
    1.88 -	List<WeakNative>::iterator iter;
    1.89 -	List<NativeEntry *>::iterator ntv_iter;
    1.90 -
    1.91 -	/* Unbind and remove all weak references to us */
    1.92 -	iter = m_WeakRefs.begin();
    1.93 -	while (iter != m_WeakRefs.end())
    1.94 -	{
    1.95 -		UnbindWeakRef((*iter));
    1.96 -		iter = m_WeakRefs.erase(iter);
    1.97 -	}
    1.98 -
    1.99 -	/* Unmark our replacement natives */
   1.100 -	ntv_iter = m_ReplacedNatives.begin();
   1.101 -	while (ntv_iter != m_ReplacedNatives.end())
   1.102 -	{
   1.103 -		pEntry = (*ntv_iter);
   1.104 -		pEntry->replacement.func = NULL;
   1.105 -		pEntry->replacement.owner = NULL;
   1.106 -		ntv_iter = m_ReplacedNatives.erase(ntv_iter);
   1.107 -	}
   1.108 -
   1.109 -	/* Strip all of our natives from the cache */
   1.110 -	ntv_iter = m_Natives.begin();
   1.111 -	while (ntv_iter != m_Natives.end())
   1.112 -	{
   1.113 -		g_ShareSys.ClearNativeFromCache(this, (*ntv_iter)->name);
   1.114 -		ntv_iter = m_Natives.erase(ntv_iter);
   1.115 -	}
   1.116 -}
   1.117 -
   1.118 -void CNativeOwner::DropWeakRefsTo(CPlugin *pPlugin)
   1.119 -{
   1.120 -	List<WeakNative>::iterator iter;
   1.121 -
   1.122 -	iter = m_WeakRefs.begin();
   1.123 -	while (iter != m_WeakRefs.end())
   1.124 -	{
   1.125 -		WeakNative & ref = (*iter);
   1.126 -
   1.127 -		if (ref.pl == pPlugin)
   1.128 -		{
   1.129 -			iter = m_WeakRefs.erase(iter);
   1.130 -		}
   1.131 -		else
   1.132 -		{
   1.133 -			iter++;
   1.134 -		}
   1.135 -	}
   1.136 -}
   1.137 -
   1.138 -void CNativeOwner::DropRefsTo(CPlugin *pPlugin)
   1.139 -{
   1.140 -	m_Dependents.remove(pPlugin);
   1.141 -	DropWeakRefsTo(pPlugin);
   1.142 -}
   1.143 -
   1.144 -void CNativeOwner::AddReplacedNative(NativeEntry *pEntry)
   1.145 -{
   1.146 -	m_ReplacedNatives.push_back(pEntry);
   1.147 -}