|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include <Plugin.h>
Public Member Functions | |
| Plugin () noexcept | |
| ~Plugin () | |
| Plugin (const Plugin &)=delete | |
| Plugin & | operator= (const Plugin &)=delete |
| Plugin (Plugin &&) noexcept=default | |
| Plugin & | operator= (Plugin &&) noexcept=default |
| bool | load (const std::string &id, const PluginManifest &manifest) |
| Load bytecode + instantiate the module. Does NOT run plugin_init yet - the manager handles ordering of init + prerequisites. | |
| void | unload () noexcept |
| Destroy WAMR instance + free bytecode buffer. Idempotent. | |
| bool | callI (const char *name, std::initializer_list< int32_t > args={}, int32_t *out_i32=nullptr) |
| Call an exported i32(i32...)->i32 function by name. | |
| bool | hasExport (const char *name) const |
| bool | lastCallTrapped () const noexcept |
| const char * | lastTrapMessage () const noexcept |
| const PluginManifest & | manifest () const noexcept |
| const std::string & | id () const noexcept |
| bool | isLoaded () const noexcept |
| bool | loadLangOverlay (const char *path=nullptr) |
| Load the plugin's translation overlay from disk into PSRAM. | |
| const char * | trKey (const char *key) const noexcept |
| Look up a plugin-local translation key in the loaded overlay. | |
Public Attributes | |
| std::vector< std::string > | acquired_prereqs |
|
defaultnoexcept |
Referenced by operator=(), operator=(), Plugin(), Plugin(), and ~Plugin().
|
default |
References Plugin().
|
delete |
References Plugin().
|
defaultnoexcept |
References Plugin().
|
nodiscard |
Call an exported i32(i32...)->i32 function by name.
| name | Exported function name. |
| args | Optional int32 arguments. |
| out_i32 | Receives the i32 return value when non-null. |
Definition at line 145 of file Plugin.cpp.
References isLoaded(), name, plg_get_active_plugin(), plg_log_error(), plg_log_warn(), and plg_set_active_plugin().
Referenced by cdc::plugin_manager::PluginManager::dispatchActionTo(), cdc::plugin_manager::PluginManager::dispatchCmd(), and operator=().
|
nodiscard |
Definition at line 128 of file Plugin.cpp.
References isLoaded(), and name.
Referenced by cdc::plugin_manager::PluginManager::dispatchCmd().
|
inlinenodiscardnoexcept |
Definition at line 89 of file Plugin.h.
Referenced by load(), and cdc::plugin_manager::Prerequisites::walk().
|
inlinenodiscardnoexcept |
Definition at line 90 of file Plugin.h.
Referenced by callI(), and hasExport().
|
inlinenodiscardnoexcept |
True if the most recent callI() failed because the WASM module trapped (as opposed to a missing export). Reset on every callI().
Definition at line 82 of file Plugin.h.
Referenced by cdc::plugin_manager::PluginManager::dispatchActionTo(), and cdc::plugin_manager::PluginManager::dispatchCmd().
|
inlinenodiscardnoexcept |
|
nodiscard |
Load bytecode + instantiate the module. Does NOT run plugin_init yet - the manager handles ordering of init + prerequisites.
Definition at line 78 of file Plugin.cpp.
References cdc::plugin_manager::PluginStorage::binaryPath(), id(), manifest(), plg_log_error(), and unload().
Referenced by operator=().
| bool cdc::plugin_manager::Plugin::loadLangOverlay | ( | const char * | path = nullptr | ) |
Load the plugin's translation overlay from disk into PSRAM.
Parses a JSON file with a { "translations": { "<code>": {...} } } schema and keeps the active language's key/value pairs in a sorted array for binary-search lookup via trKey(). Missing or invalid file is non-fatal - lookups fall back to the manifest's English strings.
| path | Filesystem path, defaults to /plugins/<id>.lang. |
Definition at line 192 of file Plugin.cpp.
References cdc::ui::I18n::getLanguageCode(), cdc::ui::I18n::instance(), cdc::plugin_manager::PluginStorage::langPath(), cdc::core::openFile(), plg_log_warn(), and cdc::core::psramAlloc().
|
inlinenodiscardnoexcept |
Definition at line 88 of file Plugin.h.
Referenced by cdc::plugin_manager::PluginManager::getLockscreenItems(), load(), operator=(), and cdc::plugin_manager::Prerequisites::walk().
|
nodiscardnoexcept |
Look up a plugin-local translation key in the loaded overlay.
| key | Plugin-local key (e.g. "toggle_ok"). |
Definition at line 260 of file Plugin.cpp.
Referenced by cdc::plugin_manager::PluginManager::getLockscreenItems().
|
noexcept |
Destroy WAMR instance + free bytecode buffer. Idempotent.
Definition at line 134 of file Plugin.cpp.
References acquired_prereqs.
Referenced by load(), and operator=().
| std::vector<std::string> cdc::plugin_manager::Plugin::acquired_prereqs |
Definition at line 118 of file Plugin.h.
Referenced by cdc::plugin_manager::Prerequisites::release(), unload(), and cdc::plugin_manager::Prerequisites::walk().