diff --git a/.github/workflows/4.0.1.yml b/.github/workflows/4.0.1.yml new file mode 100644 index 0000000..f185668 --- /dev/null +++ b/.github/workflows/4.0.1.yml @@ -0,0 +1,11 @@ +name: 🚀 4.0.1 + +on: + workflow_dispatch: + +jobs: + deploy: + uses: libhal/ci/.github/workflows/deploy_all.yml@5.x.y + with: + version: 4.0.1 + secrets: inherit diff --git a/CMakeLists.txt b/CMakeLists.txt index e86f8d2..44f9850 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ libhal_test_and_make_library( tests/serial.test.cpp tests/spi.test.cpp tests/static_callable.test.cpp + tests/serial_coroutines.test.cpp tests/static_list.test.cpp tests/steady_clock.test.cpp tests/streams.test.cpp diff --git a/include/libhal-util/as_bytes.hpp b/include/libhal-util/as_bytes.hpp index 76b8450..c0b90cb 100644 --- a/include/libhal-util/as_bytes.hpp +++ b/include/libhal-util/as_bytes.hpp @@ -49,11 +49,14 @@ constexpr std::span as_bytes(const T* p_address, return std::span(start, number_of_bytes); } +// Turning off clang-format because concepts because give it an aneurysm. +// clang-format off template concept convertible_to_bytes = requires(T a) { *a.data(); a.size(); }; +// clang-format on constexpr std::span as_writable_bytes( convertible_to_bytes auto& p_container) diff --git a/include/libhal-util/serial_coroutines.hpp b/include/libhal-util/serial_coroutines.hpp index a65e3e9..9907a18 100644 --- a/include/libhal-util/serial_coroutines.hpp +++ b/include/libhal-util/serial_coroutines.hpp @@ -73,12 +73,12 @@ class skip_past * * Call this function again to resume reading from the port. * - * @return result - work_state::in_progress if the sequence hasn't + * @return work_state::in_progress - if the sequence hasn't * been met and the buffer still has space. - * @return result - work_state::finished if the sequence was + * @return work_state::finished - if the sequence was * found before the buffer was filled completely. */ - result operator()() + work_state operator()() { if (m_search_index == m_sequence.size()) { return work_state::finished; @@ -86,7 +86,7 @@ class skip_past for (size_t read_limit = 0; read_limit < m_read_limit; read_limit++) { std::array buffer; - auto read_result = HAL_CHECK(m_serial->read(buffer)); + auto read_result = m_serial->read(buffer); if (read_result.data.size() != buffer.size()) { return work_state::in_progress; diff --git a/include/libhal-util/steady_clock.hpp b/include/libhal-util/steady_clock.hpp index b93c59b..b2db580 100644 --- a/include/libhal-util/steady_clock.hpp +++ b/include/libhal-util/steady_clock.hpp @@ -149,8 +149,7 @@ void delay(hal::steady_clock& p_steady_clock, hal::time_duration p_duration); */ inline auto timeout_generator(hal::steady_clock& p_steady_clock) { - return [&p_steady_clock](hal::time_duration p_duration) -> auto - { + return [&p_steady_clock](hal::time_duration p_duration) { return create_timeout(p_steady_clock, p_duration); }; } diff --git a/include/libhal-util/timeout.hpp b/include/libhal-util/timeout.hpp index 8648d2a..4e89fcb 100644 --- a/include/libhal-util/timeout.hpp +++ b/include/libhal-util/timeout.hpp @@ -63,13 +63,15 @@ constexpr bool failed(work_state p_state) { return p_state == work_state::failed; } - +// Turning off clang-format because concepts because give it an aneurysm. +// clang-format off template concept has_work_state = requires(T a) { { a.state() } -> std::same_as; }; +// clang-format on constexpr bool terminated(has_work_state auto p_worker) { diff --git a/tests/serial_coroutines.test.cpp b/tests/serial_coroutines.test.cpp new file mode 100644 index 0000000..96c2a41 --- /dev/null +++ b/tests/serial_coroutines.test.cpp @@ -0,0 +1,15 @@ +// Copyright 2024 Khalil Estell +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include \ No newline at end of file diff --git a/tests/static_list.test.cpp b/tests/static_list.test.cpp index f7e6905..9219fa8 100644 --- a/tests/static_list.test.cpp +++ b/tests/static_list.test.cpp @@ -349,8 +349,7 @@ void static_list_test() "static_list::dtor() handles dandling list items"_test = []() { // Setup - auto destroy_list_keep_items = []() -> auto - { + auto destroy_list_keep_items = []() { static_list list; return std::array::item, 5>{