[Lldb-commits] [lldb] [lldb-dap] Adding support for well typed events. (PR #130104)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 18 08:20:43 PDT 2025


================
@@ -0,0 +1,57 @@
+//===-- EventHandler.h ----------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_TOOLS_LLDB_DAP_EVENTS_EVENT_HANDLER
+#define LLDB_TOOLS_LLDB_DAP_EVENTS_EVENT_HANDLER
+
+#include "DAP.h"
+#include "Protocol/ProtocolBase.h"
+#include "Protocol/ProtocolEvents.h"
+#include "lldb/API/SBProcess.h"
+
+namespace lldb_dap {
+
+template <typename Body, typename... Args> class BaseEventHandler {
+public:
+  BaseEventHandler(DAP &dap) : dap(dap) {}
+
+  virtual ~BaseEventHandler() = default;
+
+  virtual llvm::StringLiteral getEvent() const = 0;
+  virtual Body Handler(Args...) const = 0;
+
+  void operator()(Args... args) const {
+    Body body = Handler(args...);
+    protocol::Event event{/*event=*/getEvent().str(), /*body=*/std::move(body)};
----------------
vogelsgesang wrote:

should this be using `Body.getEvent()` instead? Afaict, we then wouldn't need a virtual call to `getEvent` then

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


More information about the lldb-commits mailing list