|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Loads and manages a single shared library (DLL / .so / .dylib) at runtime. More...
#include <LibraryLoader.h>
Public Member Functions | |
| LibraryLoader () | |
| Constructs an unloaded LibraryLoader with no associated library. | |
| std::string | GenerateTempFile () |
| Creates a temporary file path suitable for holding a library copy. | |
| void | WriteToTempFile (const std::vector< uint8_t > &data) |
| Writes raw library bytes to the temp file created by GenerateTempFile(). | |
| void | Init (const std::string &path) |
Loads the shared library already written at path via the platform dynamic linker. | |
| void * | GetFunction (const std::string &name) |
| Resolves an exported symbol from the loaded library. | |
| void | Unload () |
| Unloads the library from memory and cleans up platform resources. | |
Loads and manages a single shared library (DLL / .so / .dylib) at runtime.
LibraryLoader loads a compiled library from a caller-supplied path via the platform's dynamic-linker API, and resolves exported symbols by name.
Typical usage:
This is used by the scripting subsystem to hot-reload compiled script modules.
|
inline |
Constructs an unloaded LibraryLoader with no associated library.
| std::string Ship::Scripting::LibraryLoader::GenerateTempFile | ( | ) |
Creates a temporary file path suitable for holding a library copy.
| void * Ship::Scripting::LibraryLoader::GetFunction | ( | const std::string & | name | ) |
Resolves an exported symbol from the loaded library.
| name | The symbol name to look up. |
| void Ship::Scripting::LibraryLoader::Init | ( | const std::string & | path | ) |
Loads the shared library already written at path via the platform dynamic linker.
| path | Filesystem path to the shared library to load. The file must already exist on disk (written by WriteToTempFile() or an external tool such as TCC); Init() does not copy or create it. |
path is unlinked from the filesystem immediately after a successful dlopen() call so that the temporary file is removed without waiting for Unload(). The library remains mapped in memory until Unload() is called. | std::runtime_error | if the library cannot be loaded. |
| void Ship::Scripting::LibraryLoader::Unload | ( | ) |
Unloads the library from memory and cleans up platform resources.
| void Ship::Scripting::LibraryLoader::WriteToTempFile | ( | const std::vector< uint8_t > & | data | ) |
Writes raw library bytes to the temp file created by GenerateTempFile().
| data | Raw bytes of the shared library to write to disk. |
| std::runtime_error | if the temp file cannot be opened for writing. |