Ejemplo n.º 1
0
void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
{
	sp_native_t *native;
	uint32_t i, native_count;
	IPluginContext *pContext;

	pContext = pPlugin->GetBaseContext();

	/* Generate a new serial ID, mark our dependencies with it. */
	g_mark_serial++;
	pPlugin->PropagateMarkSerial(g_mark_serial);

	native_count = pContext->GetNativesNum();
	for (i = 0; i < native_count; i++)
	{
		if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
			continue;

		// If we're already bound, no need to do anything else.
		if (native->status == SP_NATIVE_BOUND)
			continue;

		/* Otherwise, the native must be in our cache. */
		Ref<Native> pEntry = FindNative(native->name);
		if (!pEntry)
			continue;

		if (bCoreOnly && pEntry->owner != &g_CoreNatives)
			continue;

		BindNativeToPlugin(pPlugin, native, i, pEntry);
	}
}
Ejemplo n.º 2
0
void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
{
	NativeEntry *pEntry;
	sp_native_t *native;
	uint32_t i, native_count;
	IPluginContext *pContext;

	pContext = pPlugin->GetBaseContext();

	/* Generate a new serial ID, mark our dependencies with it. */
	g_mark_serial++;
	pPlugin->PropogateMarkSerial(g_mark_serial);

	native_count = pContext->GetNativesNum();
	for (i = 0; i < native_count; i++)
	{
		if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
		{
			continue;
		}

		/* If we're bound, check if there is a replacement available.  
		 * If not, this native is totally finalized.
		 */
		if (native->status == SP_NATIVE_BOUND)
		{
			pEntry = (NativeEntry *)native->user;
			assert(pEntry != NULL);
			if (pEntry->replacement.owner == NULL
				|| (pEntry->replacement.owner != NULL 
				&&  pEntry->replacement.func == native->pfn))
			{
				continue;
			}
		}
		/* Otherwise, the native must be in our cache. */
		else if ((pEntry = FindNative(native->name)) == NULL)
		{
			continue;
		}

		if (bCoreOnly && pEntry->owner != g_pCoreNatives)
		{
			continue;
		}

		BindNativeToPlugin(pPlugin, native, i, pEntry);
	}
}