From 52b3cd46c76fd4be18aeb8422a08a073484b9fad Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Sat, 29 Aug 2026 12:01:42 +0200 Subject: More module implementation partition units --- server/src/xml.cppm | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'server/src/xml.cppm') diff --git a/server/src/xml.cppm b/server/src/xml.cppm index 4648047..ffaf159 100644 --- a/server/src/xml.cppm +++ b/server/src/xml.cppm @@ -201,7 +201,8 @@ struct eof_event using event = std::variant< start_element_event, end_element_event, character_data_event, - processing_instructions_event, xml_decl_event, eof_event>; + processing_instructions_event, xml_decl_event, eof_event +>; template concept event_type = requires(event ev) { std::get(ev); }; @@ -522,6 +523,7 @@ public: } constexpr auto await_resume() const noexcept -> void { return; } }; + if (this->continuation()) { return awaiter{this->continuation()}; @@ -548,16 +550,19 @@ public: { return !executor_->advance_flag(); } + auto await_suspend(std::coroutine_handle> h) -> void { executor_->set_continuation(h.promise().base_handle()); } + [[nodiscard]] auto await_resume() const -> event { assert(executor_->event()); return executor_->event().value(); } }; + return awaiter{req.executor}; } @@ -572,6 +577,7 @@ public: { return false; } + auto await_suspend(std::coroutine_handle> h) -> std::coroutine_handle<> { @@ -580,6 +586,7 @@ public: next_->set_continuation(h.promise().base_handle()); return next_->handle(); } + auto await_resume() -> U { // Promise is still valid since coroutine frame is still alive @@ -599,6 +606,7 @@ public: } } }; + return awaiter{util::not_null{&coro.promise()}}; } }; @@ -717,14 +725,16 @@ auto expect_element( co_await expect_end_element(e, want); co_await ignore_whitespace(e); co_return std::forward< - parser_invoke_result_t>(res); + parser_invoke_result_t + >(res); } auto allow_element( executor_ref e, qname_view want, parser_invocable auto p) -> parser>> + parser_invoke_result_t + >> { co_await ignore_whitespace(e); if (auto mattrs = co_await allow_start_element(e, want)) @@ -734,8 +744,8 @@ auto allow_element( co_await ignore_whitespace(e); co_return std::make_optional( std::forward< - parser_invoke_result_t>( - res)); + parser_invoke_result_t + >(res)); } co_return std::nullopt; } @@ -744,7 +754,8 @@ auto allow_element( executor_ref e, qname_view want, parser_invocable auto p) -> parser requires std::is_void_v< - parser_invoke_result_t> + parser_invoke_result_t + > { co_await ignore_whitespace(e); if (auto mattrs = co_await allow_start_element(e, want)) -- cgit v1.3