1.1 --- a/core/systems/PluginSys.cpp Wed Aug 29 00:28:19 2007 +0000
1.2 +++ b/core/systems/PluginSys.cpp Wed Aug 29 00:47:05 2007 +0000
1.3 @@ -769,6 +769,7 @@
1.4 m_AllPluginsLoaded = false;
1.5 m_MyIdent = NULL;
1.6 m_pNativeLookup = sm_trie_create();
1.7 + m_pCoreNatives = sm_trie_create();
1.8 }
1.9
1.10 CPluginManager::~CPluginManager()
1.11 @@ -780,6 +781,7 @@
1.12 */
1.13 sm_trie_destroy(m_LoadLookup);
1.14 sm_trie_destroy(m_pNativeLookup);
1.15 + sm_trie_destroy(m_pCoreNatives);
1.16
1.17 CStack<CPluginManager::CPluginIterator *>::iterator iter;
1.18 for (iter=m_iters.begin(); iter!=m_iters.end(); iter++)
1.19 @@ -1325,18 +1327,28 @@
1.20
1.21 void CPluginManager::AddCoreNativesToPlugin(CPlugin *pPlugin)
1.22 {
1.23 - List<sp_nativeinfo_t *>::iterator iter;
1.24 + IPluginContext *pContext = pPlugin->GetBaseContext();
1.25 + sp_context_t *ctx = pContext->GetContext();
1.26 +
1.27
1.28 - for (iter=m_natives.begin(); iter!=m_natives.end(); iter++)
1.29 + uint32_t natives = pContext->GetNativesNum();
1.30 + sp_native_t *native;
1.31 + SPVM_NATIVE_FUNC pfn;
1.32 + for (uint32_t i=0; i<natives; i++)
1.33 {
1.34 - sp_nativeinfo_t *natives = (*iter);
1.35 - IPluginContext *ctx = pPlugin->GetBaseContext();
1.36 - unsigned int i=0;
1.37 - /* Attempt to bind every native! */
1.38 - while (natives[i].func != NULL)
1.39 + if (pContext->GetNativeByIndex(i, &native) != SP_ERROR_NONE)
1.40 + {
1.41 + continue;
1.42 + }
1.43 + if (native->status == SP_NATIVE_BOUND)
1.44 {
1.45 - ctx->BindNative(&natives[i++]);
1.46 + continue;
1.47 }
1.48 + if (!sm_trie_retrieve(m_pCoreNatives, native->name, (void **)&pfn))
1.49 + {
1.50 + continue;
1.51 + }
1.52 + pContext->BindNativeToIndex(i, pfn);
1.53 }
1.54 }
1.55
1.56 @@ -1854,7 +1866,10 @@
1.57
1.58 void CPluginManager::RegisterNativesFromCore(sp_nativeinfo_t *natives)
1.59 {
1.60 - m_natives.push_back(natives);
1.61 + for (unsigned int i = 0; natives[i].func != NULL; i++)
1.62 + {
1.63 + sm_trie_insert(m_pCoreNatives, natives[i].name, natives[i].func);
1.64 + }
1.65 }
1.66
1.67 IPlugin *CPluginManager::PluginFromHandle(Handle_t handle, HandleError *err)