Remove CPluginManager direct use of CPlugin::m_RequiredLibs.
This commit is contained in:
parent
717ad38d06
commit
f27dbaf716
@ -1045,10 +1045,7 @@ bool CPluginManager::FindOrRequirePluginDeps(CPlugin *pPlugin, char *error, size
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Check that we aren't registering the same library twice */
|
/* Check that we aren't registering the same library twice */
|
||||||
if (pPlugin->m_RequiredLibs.find(name) != pPlugin->m_RequiredLibs.end())
|
pPlugin->AddRequiredLib(name);
|
||||||
continue;
|
|
||||||
|
|
||||||
pPlugin->m_RequiredLibs.push_back(name);
|
|
||||||
|
|
||||||
CPlugin *found;
|
CPlugin *found;
|
||||||
for (auto iter=m_plugins.begin(); iter!=m_plugins.end(); iter++) {
|
for (auto iter=m_plugins.begin(); iter!=m_plugins.end(); iter++) {
|
||||||
@ -1114,6 +1111,21 @@ void CPlugin::ForEachLibrary(ke::Lambda<void(const char *)> callback)
|
|||||||
callback((*iter).c_str());
|
callback((*iter).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlugin::AddRequiredLib(const char *name)
|
||||||
|
{
|
||||||
|
if (m_RequiredLibs.find(name) == m_RequiredLibs.end())
|
||||||
|
m_RequiredLibs.push_back(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPlugin::ForEachRequiredLib(ke::Lambda<bool(const char *)> callback)
|
||||||
|
{
|
||||||
|
for (auto iter = m_RequiredLibs.begin(); iter != m_RequiredLibs.end(); iter++) {
|
||||||
|
if (!callback((*iter).c_str()))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CPluginManager::LoadExtensions(CPlugin *pPlugin)
|
void CPluginManager::LoadExtensions(CPlugin *pPlugin)
|
||||||
{
|
{
|
||||||
auto callback = [pPlugin] (const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
|
auto callback = [pPlugin] (const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
|
||||||
@ -1317,22 +1329,24 @@ void CPluginManager::TryRefreshDependencies(CPlugin *pPlugin)
|
|||||||
|
|
||||||
g_ShareSys.BindNativesToPlugin(pPlugin, false);
|
g_ShareSys.BindNativesToPlugin(pPlugin, false);
|
||||||
|
|
||||||
for (auto req_iter=pPlugin->m_RequiredLibs.begin(); req_iter!=pPlugin->m_RequiredLibs.end(); req_iter++) {
|
bool all_found = pPlugin->ForEachRequiredLib([this, pPlugin] (const char *lib) -> bool {
|
||||||
CPlugin *found = nullptr;
|
CPlugin *found = nullptr;
|
||||||
for (auto pl_iter=m_plugins.begin(); pl_iter!=m_plugins.end(); pl_iter++) {
|
for (auto pl_iter=m_plugins.begin(); pl_iter!=m_plugins.end(); pl_iter++) {
|
||||||
CPlugin *search = (*pl_iter);
|
CPlugin *search = (*pl_iter);
|
||||||
if (search->HasLibrary((*req_iter).c_str())) {
|
if (search->HasLibrary(lib)) {
|
||||||
found = search;
|
found = search;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
pPlugin->SetErrorState(Plugin_Error, "Library not found: %s", (*req_iter).c_str());
|
pPlugin->SetErrorState(Plugin_Error, "Library not found: %s", lib);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
found->AddDependent(pPlugin);
|
found->AddDependent(pPlugin);
|
||||||
}
|
return true;
|
||||||
|
});
|
||||||
|
if (!all_found)
|
||||||
|
return;
|
||||||
|
|
||||||
/* Find any unbound natives
|
/* Find any unbound natives
|
||||||
* Right now, these are not allowed
|
* Right now, these are not allowed
|
||||||
|
@ -270,6 +270,9 @@ public:
|
|||||||
return m_errormsg;
|
return m_errormsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddRequiredLib(const char *name);
|
||||||
|
bool ForEachRequiredLib(ke::Lambda<bool(const char *)> callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool ReadInfo();
|
bool ReadInfo();
|
||||||
void DependencyDropped(CPlugin *pOwner);
|
void DependencyDropped(CPlugin *pOwner);
|
||||||
|
Loading…
Reference in New Issue
Block a user