[Lldb-commits] [lldb] [lldb-dap] Creating well defined structures for DAP messages. (PR #129155)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Fri Feb 28 09:38:55 PST 2025
================
@@ -0,0 +1,191 @@
+//===-- Protocol.cpp ------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "Protocol.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/JSON.h"
+#include <optional>
+#include <utility>
+
+namespace llvm {
+namespace json {
+bool fromJSON(const llvm::json::Value &Params, llvm::json::Value &V,
+ llvm::json::Path P) {
+ V = std::move(Params);
+ return true;
+}
+} // namespace json
+} // namespace llvm
----------------
ashgti wrote:
In each of the `Event`, `Response`, `Request` types I have a 'raw<prop>` field that is used to collect the property for later decoding.
In https://github.com/ashgti/llvm-project/commit/f32d984942361e6e47f2357f43ea7da290d660ed from my prototype I have additional helpers to decode the fields for more inform handling. That updates the handlers to `RequestHandler<ArgsType, ResponeBodyType>` like:
```
class SourceRequestHandler
: public RequestHandler<protocol::SourceArguments,
protocol::SourceResponseBody> {
public:
using RequestHandler::RequestHandler;
static llvm::StringLiteral getCommand() { return "source"; }
llvm::Expected<protocol::SourceResponseBody>
Execute(const protocol::SourceArguments &args) const override;
};
```
Which does the decoding of the `rawArguments` into the arguments and the return into the `rawBody` for the response.
https://github.com/llvm/llvm-project/pull/129155
More information about the lldb-commits
mailing list