================
@@ -297,6 +354,463 @@ class JSONRPCTransport : public IOTransport<Req, Resp,
Evt> {
static constexpr llvm::StringLiteral kMessageSeparator = "\n";
};
-} // namespace lldb_private
+/// A handler for the response to an outgoing request.
+template <typename T>
+using Reply =
+ std::conditional_t<std::is_void_v<T>,
+ llvm::unique_function<void(llvm::Error)>,
+ llvm::unique_function<void(llvm::Expected<T>)>>;
+
+namespace detail {
+template <typename R, typename P> struct request_t final {
+ using type = llvm::unique_function<void(const P &, Reply<R>)>;
+};
+template <typename R> struct request_t<R, void> final {
+ using type = llvm::unique_function<void(Reply<R>)>;
+};
+template <typename P> struct event_t final {
+ using type = llvm::unique_function<void(const P &)>;
+};
+template <> struct event_t<void> final {
+ using type = llvm::unique_function<void()>;
+};
+} // namespace detail
+
+template <typename R, typename P>
+using OutgoingRequest = typename detail::request_t<R, P>::type;
+
+/// A function to send an outgoing event.
+template <typename P> using OutgoingEvent = typename detail::event_t<P>::type;
+
+// FIXME: With c++20, we should use this concept:
----------------
JDevlieghere wrote:
I find commented out code really annoying and I strongly prefer putting code
behind `#if 0`. Or even better, if it compiles with C++20 support, we could
gate this by `#if __cplusplus >= 202002L`.
https://github.com/llvm/llvm-project/pull/159160
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits