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);
	}
}
Exemple #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);
	}
}
void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, const Ref<Native> &entry)
{
	if (!entry->owner)
		return;

	IPluginContext *pContext = pPlugin->GetBaseContext();

	uint32_t i;
	if (pContext->FindNativeByName(entry->name(), &i) != SP_ERROR_NONE)
		return;

	sp_native_t *native;
	if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
		return;

	if (native->status == SP_NATIVE_BOUND)
		return;

	BindNativeToPlugin(pPlugin, native, i, entry);
}
Exemple #4
0
void ShareSystem::BindNativeToPlugin(CPlugin *pPlugin, NativeEntry *pEntry)
{
	uint32_t i;
	sp_native_t *native;
	IPluginContext *pContext;

	pContext = pPlugin->GetBaseContext();

	if (pContext->FindNativeByName(pEntry->name, &i) != SP_ERROR_NONE)
	{
		return;
	}
	if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
	{
		return;
	}

	if (native->status == SP_NATIVE_BOUND)
	{
		return;
	}

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