[Lldb-commits] [lldb] [lldb-dap] Updating RequestHandler to encode/decode arguments and response. (PR #130090)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 14 01:16:46 PDT 2025


================
@@ -57,235 +77,306 @@ class RequestHandler {
   DAP &dap;
 };
 
-class AttachRequestHandler : public RequestHandler {
-public:
-  using RequestHandler::RequestHandler;
+/// Base class for handling DAP requests. Handlers should declare their
+/// arguments and response body types like:
+///
+/// class MyRequestHandler : public RequestHandler<Arguments, ResponseBody> {
+///   ....
+/// };
+template <typename Args, typename Body>
+class RequestHandler : public BaseRequestHandler {
+  using BaseRequestHandler::BaseRequestHandler;
+
+  void operator()(const llvm::json::Object &request) const override {
+    /* no-op, the other overload handles json coding. */
+  }
----------------
labath wrote:

I think this wouldn't be necessary if you had something like a `LegacyRequestHandler` class which would declare the (abstract) function which takes the json object, and implements the protocol::Request version to forward to that). The base interface would only contain the protocol::Request overload.

https://github.com/llvm/llvm-project/pull/130090


More information about the lldb-commits mailing list