-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "PluginManager.h" | ||
|
||
#include "ll/api/plugin/Plugin.h" | ||
#include "lse/Entry.h" | ||
#include "main/PluginManager.h" | ||
|
||
#include <ll/api/plugin/PluginManager.h> | ||
|
||
#if LEGACY_SCRIPT_ENGINE_BACKEND == lua | ||
|
||
constexpr auto PluginManagerName = "lse-lua"; | ||
|
||
#elif LEGACY_SCRIPT_ENGINE_BACKEND == quickjs | ||
|
||
constexpr auto PluginManagerName = "lse-quickjs"; | ||
|
||
#else | ||
|
||
#error "LEGACY_SCRIPT_ENGINE_BACKEND is not defined!" | ||
|
||
#endif | ||
|
||
namespace lse { | ||
|
||
PluginManager::PluginManager() : ll::plugin::PluginManager(PluginManagerName) {} | ||
|
||
auto PluginManager::load(ll::plugin::Manifest manifest) -> bool { | ||
auto& logger = getSelfPluginInstance().getLogger(); | ||
|
||
logger.info("loading plugin {}", manifest.name); | ||
|
||
if (hasPlugin(manifest.name)) { | ||
logger.error("plugin {} already loaded", manifest.name); | ||
return false; | ||
} | ||
|
||
auto pluginDir = std::filesystem::canonical(ll::plugin::getPluginsRoot() / manifest.name); | ||
|
||
auto entryPath = pluginDir / manifest.entry; | ||
|
||
return ::PluginManager::loadPlugin(entryPath.string(), false, true); | ||
} | ||
|
||
auto PluginManager::unload(std::string_view name) -> bool { | ||
auto& logger = getSelfPluginInstance().getLogger(); | ||
|
||
logger.info("unloading plugin {}", name); | ||
|
||
// TODO: Unload plugin | ||
|
||
return false; | ||
} | ||
|
||
} // namespace lse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <ll/api/plugin/Manifest.h> | ||
#include <ll/api/plugin/PluginManager.h> | ||
#include <string_view> | ||
|
||
namespace lse { | ||
|
||
class PluginManager final : public ll::plugin::PluginManager { | ||
public: | ||
PluginManager(); | ||
|
||
PluginManager(const PluginManager&) = delete; | ||
PluginManager(PluginManager&&) = delete; | ||
auto operator=(const PluginManager&) -> PluginManager& = delete; | ||
auto operator=(PluginManager&&) -> PluginManager& = delete; | ||
|
||
~PluginManager() override = default; | ||
|
||
auto load(ll::plugin::Manifest manifest) -> bool override; | ||
auto unload(std::string_view name) -> bool override; | ||
}; | ||
|
||
} // namespace lse |