|
MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
|
RAII wrapper for dynamically loaded functions via dlopen/dlsym. More...
#include <function.hpp>
Public Types | |
| using | Fn = R (*)(Args...) |
Public Member Functions | |
| Function (char const *lib, char const *name) | |
| Load a function from a named shared library. | |
| Function (char const *name) | |
| Load a function from the main program's symbol table. | |
| ~Function () | |
| Function (const Function &)=delete | |
| Function & | operator= (const Function &)=delete |
| Function (Function &&other) noexcept | |
| Function & | operator= (Function &&other) noexcept |
| R | operator() (Args... args) const |
| Invoke the loaded function. | |
Private Attributes | |
| void * | handle = nullptr |
| dlopen library handle | |
| Fn | fn = nullptr |
| resolved function pointer | |
RAII wrapper for dynamically loaded functions via dlopen/dlsym.
| R | Return type of the loaded function |
| Args | Parameter types of the loaded function |
Loads a shared library and resolves a function symbol at construction time. The library handle is automatically closed on destruction. Move-only.
Definition at line 25 of file function.hpp.
| using mxvm::Function< R(Args...)>::Fn = R (*)(Args...) |
Definition at line 27 of file function.hpp.
|
inline |
Load a function from a named shared library.
| lib | Path to the shared library |
| name | Symbol name to resolve |
| std::runtime_error | if dlopen or dlsym fails |
Definition at line 35 of file function.hpp.
Referenced by Function(), Function(), operator=(), and operator=().
|
inline |
Load a function from the main program's symbol table.
| name | Symbol name to resolve (via dlopen(nullptr, ...)) |
| std::runtime_error | if dlsym fails |
Definition at line 52 of file function.hpp.
|
inline |
Definition at line 64 of file function.hpp.
References handle.
|
delete |
References Function().
|
inlinenoexcept |
Definition at line 72 of file function.hpp.
References Function(), fn, and handle.
|
inline |
|
delete |
References Function().
|
inlinenoexcept |
Definition at line 76 of file function.hpp.
References Function(), fn, and handle.
|
private |
resolved function pointer
Definition at line 97 of file function.hpp.
Referenced by Function(), Function(), Function(), operator()(), and operator=().
|
private |
dlopen library handle
Definition at line 96 of file function.hpp.
Referenced by Function(), Function(), Function(), ~Function(), and operator=().