-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for headless mode move exception and none-exception impl to different headers replace "friend" with a member function for find_function and add free function for convenience. add preset for header-only
- Loading branch information
Showing
14 changed files
with
355 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
|
||
# IDE-specifics | ||
.idea | ||
.vs | ||
|
||
# common build out-folders: | ||
out-* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/// | ||
|
||
#pragma once | ||
|
||
#include <dynl/dynl_error.hpp> | ||
|
||
#if defined(DYNLOAD_NO_EXCEPTIONS) | ||
#include <dynl/platform_details/dynl_error_noexcept.hpp> | ||
#else | ||
#include <dynl/platform_details/dynl_error_except.hpp> | ||
#endif | ||
|
||
namespace dynl { | ||
/// \typedef c_function_pointer | ||
/// Template alias to make function pointer API readable. | ||
template <typename T> using c_function_pointer = T *; | ||
|
||
/// \class dynamic_library_pointer | ||
/// Represents a raw dynamic library. It lacks any formal definition and is only | ||
/// used for type safety. reinterpret_cast it to/from platform-dependent type | ||
/// representing the dynamic library. | ||
class dynamic_library_pointer; | ||
|
||
constexpr auto _default_error_callbacker = [](dynl_error const &err) { | ||
_default_error_callback(err); | ||
}; | ||
|
||
class dynamic_library; | ||
|
||
/// \class dynamic_function_symbol | ||
/// Represents a callable symbol from a dynamically loaded library. | ||
/// The symbol lacks any type information and it is up to the user to | ||
/// do the correct 'symbol_cast'. | ||
class dynamic_function_symbol { | ||
public: | ||
using raw_cymbol_t = c_function_pointer<void()>; | ||
|
||
private: | ||
c_function_pointer<void()> raw_symbol_{}; | ||
|
||
public: | ||
explicit constexpr dynamic_function_symbol(raw_cymbol_t rs) noexcept | ||
: raw_symbol_(rs) {} | ||
explicit(false) constexpr dynamic_function_symbol(std::nullptr_t) {} | ||
constexpr dynamic_function_symbol() noexcept = default; | ||
|
||
[[nodiscard]] constexpr bool valid() const noexcept { | ||
return raw_symbol_ != nullptr; | ||
} | ||
constexpr explicit operator bool() const noexcept { return valid(); } | ||
|
||
template <typename T> | ||
friend c_function_pointer<T> symbol_cast(dynamic_function_symbol in); | ||
}; | ||
|
||
} // namespace dynl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
///@file | ||
/// Contains default error handling routines when exceptions are enabled. | ||
/// | ||
|
||
#pragma once | ||
|
||
#include <dynl/dynl_error.hpp> | ||
#include <dynl/dynl_except.hpp> | ||
|
||
namespace dynl { | ||
|
||
inline void _default_error_callback(dynl_error const &err) { | ||
throw dynl_except(err); | ||
} | ||
} // namespace dynl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
///@file | ||
/// Contains default error handling routines when exceptions are disabled. | ||
/// | ||
|
||
#pragma once | ||
|
||
#include <cstdlib> | ||
#include <iostream> | ||
|
||
#include <dynl/dynl_error.hpp> | ||
|
||
namespace dynl { | ||
|
||
inline void _default_error_callback(dynl_error const &err) { | ||
std::cerr << "Dynload error: " << message(err) << " (" << details(err) | ||
<< ")\n"; | ||
std::abort(); | ||
} | ||
} // namespace dynl |
Oops, something went wrong.