mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-11 08:22:52 +00:00
Redesign (simplify) top-level avclan interface to use expected/nullable unique_ptr
- Peripheral::read/send now return `expected<unique_ptr<Frame>, Error>` for a unified success/error interface. - Peripheral::route returns `expected<unique_ptr<Frame>, Error>` to distinguish intent: (intentional) non-response vs unable to respond - Other functions with optional message semantics (handle,poll,react) return a unique_ptr whose ownership-state indicates response intent (i.e. send new message) Bundled necessary changes: - Switch Frame allocation from global to local (enabled via member function new/delete) - Add new header-library tl::expected to shim avr-libstdcpp Unrelated: Defensive `continue` added after `route`, to reduce Bus activity check latency Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Idempotent patch driver for FetchContent PATCH_COMMAND steps.
|
||||
#
|
||||
# Usage: cmake -DGIT_EXECUTABLE=<git> -DPATCH_FILE=<patch> -P apply-patch.cmake
|
||||
# (run with CWD = the populated source directory, as PATCH_COMMAND does).
|
||||
#
|
||||
# FetchContent re-runs PATCH_COMMAND after its update step on reconfigure, so a
|
||||
# bare `git apply` fails the second time around. Skip if the patch is already
|
||||
# applied (the reverse-apply dry run succeeds); otherwise apply it for real.
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" apply --reverse --check --ignore-whitespace
|
||||
"${PATCH_FILE}"
|
||||
RESULT_VARIABLE _already_applied
|
||||
OUTPUT_QUIET ERROR_QUIET)
|
||||
if(NOT _already_applied EQUAL 0)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" apply --ignore-whitespace "${PATCH_FILE}"
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
endif()
|
||||
@@ -0,0 +1,36 @@
|
||||
diff --git a/include/tl/expected.hpp b/include/tl/expected.hpp
|
||||
index 59e59aa..75857bd 100644
|
||||
--- a/include/tl/expected.hpp
|
||||
+++ b/include/tl/expected.hpp
|
||||
@@ -20,7 +20,7 @@
|
||||
#define TL_EXPECTED_VERSION_MINOR 3
|
||||
#define TL_EXPECTED_VERSION_PATCH 1
|
||||
|
||||
-#include <exception>
|
||||
+#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
@@ -222,7 +222,7 @@ static constexpr unexpect_t unexpect{};
|
||||
#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED
|
||||
#define TL_EXPECTED_THROW_EXCEPTION(e) throw((e));
|
||||
#else
|
||||
-#define TL_EXPECTED_THROW_EXCEPTION(e) std::terminate();
|
||||
+#define TL_EXPECTED_THROW_EXCEPTION(e) std::abort();
|
||||
#endif
|
||||
|
||||
namespace detail {
|
||||
@@ -1249,11 +1249,11 @@ template <class T, class E> struct expected_default_ctor_base<T, E, false> {
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
-template <class E> class bad_expected_access : public std::exception {
|
||||
+template <class E> class bad_expected_access {
|
||||
public:
|
||||
explicit bad_expected_access(E e) : m_val(std::move(e)) {}
|
||||
|
||||
- virtual const char *what() const noexcept override {
|
||||
+ virtual const char *what() const noexcept {
|
||||
return "Bad expected access";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
diff --git a/include/tl/optional.hpp b/include/tl/optional.hpp
|
||||
index e9c59c2..1ff3d4a 100644
|
||||
--- a/include/tl/optional.hpp
|
||||
+++ b/include/tl/optional.hpp
|
||||
@@ -21,7 +21,6 @@
|
||||
#define TL_OPTIONAL_VERSION_MINOR 1
|
||||
#define TL_OPTIONAL_VERSION_PATCH 0
|
||||
|
||||
-#include <exception>
|
||||
#include <functional>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
@@ -664,7 +663,7 @@ struct nullopt_t {
|
||||
static constexpr nullopt_t nullopt{nullopt_t::do_not_use{},
|
||||
nullopt_t::do_not_use{}};
|
||||
|
||||
-class bad_optional_access : public std::exception {
|
||||
+class bad_optional_access {
|
||||
public:
|
||||
bad_optional_access() = default;
|
||||
const char *what() const noexcept { return "Optional has no value"; }
|
||||
Reference in New Issue
Block a user