MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / loadPlugin

Method loadPlugin

Libraries/Plugin/Plugin.cpp:987–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987SC::Result SC::PluginRegistry::loadPlugin(StringSpan identifier, const PluginCompiler& compiler,
988 const PluginSysroot& sysroot, StringSpan executablePath, LoadMode loadMode)
989{
990 PluginDynamicLibrary* res = findPlugin(identifier);
991 SC_TRY_MSG(res != nullptr, "loadplugin res == nullptr");
992 PluginDynamicLibrary& lib = *res;
993 if (loadMode == LoadMode::Reload or not lib.dynamicLibrary.isValid())
994 {
995 // TODO: Shield against circular dependencies
996 for (const auto& dependency : lib.definition.dependencies)
997 {
998 SC_TRY(loadPlugin(dependency.view(), compiler, sysroot, executablePath, LoadMode::Load));
999 }
1000 if (lib.dynamicLibrary.isValid())
1001 {
1002 SC_TRY_MSG(unloadPlugin(identifier), "unload plugin");
1003 }
1004 SC_TRY(lib.load(compiler, sysroot, executablePath));
1005 SC_TRY_MSG(lib.pluginInit(lib.instance), "PluginInit failed"); // TODO: Return actual failure strings
1006 return Result(true);
1007 }
1008 return Result(true);
1009}
1010
1011SC::Result SC::PluginRegistry::unloadPlugin(StringSpan identifier) { return unloadPlugin(identifier, true); }
1012

Callers 3

PluginTestMethod · 0.80
loadMethod · 0.80
loadMethod · 0.80

Calls 4

ResultClass · 0.50
isValidMethod · 0.45
viewMethod · 0.45
loadMethod · 0.45

Tested by 2

PluginTestMethod · 0.64
loadMethod · 0.64