Split LoadOrRequireExtensions into two distinct functions.
This commit is contained in:
parent
15f4a05122
commit
3195dec436
@ -927,7 +927,7 @@ LoadRes CPluginManager::LoadPlugin(CPlugin **aResult, const char *path, bool deb
|
|||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case APLRes_Success:
|
case APLRes_Success:
|
||||||
if (!LoadOrRequireExtensions(plugin, 1, error, maxlength))
|
if (!LoadExtensions(plugin, error, maxlength))
|
||||||
return LoadRes_Failure;
|
return LoadRes_Failure;
|
||||||
return LoadRes_Successful;
|
return LoadRes_Successful;
|
||||||
|
|
||||||
@ -1158,21 +1158,30 @@ bool CPlugin::ForEachExtVar(const ExtVarCallback& callback)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass, char *error, size_t maxlength)
|
bool CPluginManager::LoadExtensions(CPlugin *pPlugin, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
auto callback = [pPlugin, pass, error, maxlength]
|
auto callback = [pPlugin, error, maxlength]
|
||||||
(const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
|
(const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
|
||||||
{
|
{
|
||||||
char path[PLATFORM_MAX_PATH];
|
char path[PLATFORM_MAX_PATH];
|
||||||
if (pass == 1) {
|
|
||||||
/* Attempt to auto-load if necessary */
|
/* Attempt to auto-load if necessary */
|
||||||
if (ext.autoload) {
|
if (ext.autoload) {
|
||||||
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file);
|
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file);
|
||||||
g_Extensions.LoadAutoExtension(path, ext.required);
|
g_Extensions.LoadAutoExtension(path, ext.required);
|
||||||
}
|
}
|
||||||
} else if (pass == 2) {
|
return true;
|
||||||
|
};
|
||||||
|
return pPlugin->ForEachExtVar(ke::Move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPluginManager::RequireExtensions(CPlugin *pPlugin, char *error, size_t maxlength)
|
||||||
|
{
|
||||||
|
auto callback = [pPlugin, error, maxlength]
|
||||||
|
(const sp_pubvar_t *pubvar, const CPlugin::ExtVar& ext) -> bool
|
||||||
|
{
|
||||||
/* Is this required? */
|
/* Is this required? */
|
||||||
if (ext.required) {
|
if (ext.required) {
|
||||||
|
char path[PLATFORM_MAX_PATH];
|
||||||
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file);
|
libsys->PathFormat(path, PLATFORM_MAX_PATH, "%s", ext.file);
|
||||||
IExtension *pExt = g_Extensions.FindExtensionByFile(path);
|
IExtension *pExt = g_Extensions.FindExtensionByFile(path);
|
||||||
if (!pExt)
|
if (!pExt)
|
||||||
@ -1195,7 +1204,7 @@ bool CPluginManager::LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
return pPlugin->ForEachExtVar(ke::Move(callback));
|
return pPlugin->ForEachExtVar(ke::Move(callback));
|
||||||
@ -1257,15 +1266,11 @@ bool CPluginManager::MalwareCheckPass(CPlugin *pPlugin, char *error, size_t maxl
|
|||||||
bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength)
|
bool CPluginManager::RunSecondPass(CPlugin *pPlugin, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
/* Second pass for extension requirements */
|
/* Second pass for extension requirements */
|
||||||
if (!LoadOrRequireExtensions(pPlugin, 2, error, maxlength))
|
if (!RequireExtensions(pPlugin, error, maxlength))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!FindOrRequirePluginDeps(pPlugin, error, maxlength))
|
if (!FindOrRequirePluginDeps(pPlugin, error, maxlength))
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
/* Run another binding pass */
|
/* Run another binding pass */
|
||||||
g_ShareSys.BindNativesToPlugin(pPlugin, false);
|
g_ShareSys.BindNativesToPlugin(pPlugin, false);
|
||||||
|
@ -485,7 +485,8 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Runs an extension pass on a plugin.
|
* Runs an extension pass on a plugin.
|
||||||
*/
|
*/
|
||||||
bool LoadOrRequireExtensions(CPlugin *pPlugin, unsigned int pass, char *error, size_t maxlength);
|
bool LoadExtensions(CPlugin *pPlugin, char *error, size_t maxlength);
|
||||||
|
bool RequireExtensions(CPlugin *pPlugin, char *error, size_t maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages required natives.
|
* Manages required natives.
|
||||||
|
Loading…
Reference in New Issue
Block a user