libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
LibraryLoader.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7namespace Ship::Scripting {
8
10typedef void (*LibraryFunc_t)(void);
11
13typedef void* LibraryHandle_t;
14
31 public:
35 LibraryLoader() : mHandle(nullptr), mTempFile("") {
36 }
37
42 std::string GenerateTempFile();
43
50 void WriteToTempFile(const std::vector<uint8_t>& data);
51
64 void Init(const std::string& path);
65
71 void* GetFunction(const std::string& name);
72
81 void Unload();
82
83 private:
84 LibraryHandle_t mHandle;
85 std::string mTempFile;
86};
87} // namespace Ship::Scripting
Loads and manages a single shared library (DLL / .so / .dylib) at runtime.
Definition LibraryLoader.h:30
void Unload()
Unloads the library from memory and cleans up platform resources.
void * GetFunction(const std::string &name)
Resolves an exported symbol from the loaded library.
void Init(const std::string &path)
Loads the shared library already written at path via the platform dynamic linker.
void WriteToTempFile(const std::vector< uint8_t > &data)
Writes raw library bytes to the temp file created by GenerateTempFile().
std::string GenerateTempFile()
Creates a temporary file path suitable for holding a library copy.
LibraryLoader()
Constructs an unloaded LibraryLoader with no associated library.
Definition LibraryLoader.h:35
Definition LibraryLoader.h:7
void(* LibraryFunc_t)(void)
Function pointer type for library entry points with no parameters and no return value.
Definition LibraryLoader.h:10
void * LibraryHandle_t
Opaque handle to a dynamically loaded shared library.
Definition LibraryLoader.h:13