λ61
|
Handling native extensions. More...
#include <NativeExtension.hpp>
Public Types | |
using | ExtensionEntryPoint_t = int(l61_api_extension_ptr) |
using | ExtensionEntryPointPtr_t = std::add_pointer_t<ExtensionEntryPoint_t> |
using | ExtensionEntryPointCall_t = std::function<ExtensionEntryPoint_t> |
Public Member Functions | |
bool | isValid () const |
NativeExtension (const std::string &path) | |
const ExtensionEntryPointCall_t & | getExtensionEntryPointCall () const |
const std::string & | getExtensionPath () const |
std::string | toString () const override |
void | unload () |
template<typename T> | |
std::expected< std::add_pointer_t< std::type_identity_t< T > >, std::string > | extensionSymbolLookup (const std::string &symStr) const |
A relatively safe way to look up symbols within an extension. | |
const lex61_header_t * | getExtensionHeader () const |
__inline const lex61_header_t & | getExtensionHeaderAsRef () const |
~NativeExtension () override | |
NativeExtension (NativeExtension &)=delete | |
NativeExtension (const NativeExtension &)=delete | |
NativeExtension (NativeExtension &&nativeExtension) noexcept | |
Public Member Functions inherited from l61::Object | |
virtual | ~Object ()=default |
virtual std::size_t | hashCode () const |
Returns a hash code for the object. | |
std::string | typeName () const |
Returns the demangled name of the type. | |
const std::type_info & | typeInfo () const |
Returns RTTI type information object. | |
virtual nlohmann::json | toJsonValue () const |
Serializes the object into JSON form. | |
operator std::string () const | |
Explicit conversion operator to std::string. | |
operator nlohmann::json () const | |
Explicit conversion operator to nlohmann::json. |
Static Public Member Functions | |
static int | safeExtensionLoad (const std::expected< NativeExtension, std::string > &extension, l61_api_extension_ptr api, bool required=true) |
Safely loads an extension. | |
static std::expected< NativeExtension, std::string > | extensionLookUp (const std::vector< std::string > &spaths, const std::string &exName) |
A lookup system. |
Static Public Attributes | |
static constexpr const char * | entryPointSymbolName = "__l61_rt_ex_init__" |
The standard entry point for an extension usually defined by the extension runtime. | |
static constexpr const char * | headerSymbolName = "__lex61_header__" |
The symbol name for the extension header this must be self defined. |
Private Member Functions | |
l61_rosetta_SharedLibrary_symbol_t | blindSymbolLookup (const std::string &symStr) const |
Horrifically unsafe and that's why it's private. | |
void | isGoodExtension () const |
Private Attributes | |
std::string | extensionPath |
l61_rosetta_SharedLibrary_handle_t | soHandle |
an OS dependent handle to a shared library | |
ExtensionEntryPointCall_t | extensionEntryPointCall |
std::mutex | soMutex |
A mutex for a slight safety. |
Handling native extensions.
using l61::ExtensionSystem::NativeExtension::ExtensionEntryPointCall_t = std::function<ExtensionEntryPoint_t> |
using l61::ExtensionSystem::NativeExtension::ExtensionEntryPointPtr_t = std::add_pointer_t<ExtensionEntryPoint_t> |
|
explicit |
path | The full path to an extension |
|
override |
|
delete |
|
delete |
|
noexcept |
|
nodiscardprivate |
Horrifically unsafe and that's why it's private.
symStr | The name of the symbol |
|
static |
A lookup system.
spaths | |
exName | Extension file name not the path |
|
inline |
A relatively safe way to look up symbols within an extension.
T | The type of the symbol you are looking up |
symStr |
|
nodiscard |
const lex61_header_t * l61::ExtensionSystem::NativeExtension::getExtensionHeader | ( | ) | const |
|
inline |
|
nodiscard |
|
private |
|
nodiscard |
|
static |
Safely loads an extension.
extension | Fill in with the result of the lookup |
api | Fill in with a pointer to the api exchange structure |
required | Do you care if this extension is not loaded |
|
overridevirtual |
Reimplemented from l61::Object.
void l61::ExtensionSystem::NativeExtension::unload | ( | ) |
|
staticconstexpr |
The standard entry point for an extension usually defined by the extension runtime.
|
private |
|
private |
|
staticconstexpr |
The symbol name for the extension header this must be self defined.
|
private |
an OS dependent handle to a shared library
|
mutableprivate |
A mutex for a slight safety.