================ @@ -57,235 +68,288 @@ 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. */ + } + + void operator()(const protocol::Request &request) const override { + protocol::Response response; + response.request_seq = request.seq; + response.command = request.command; + Args arguments; + llvm::json::Path::Root root; + if (request.rawArguments && + !fromJSON(request.rawArguments, arguments, root)) { ---------------- vogelsgesang wrote:
I think we should handle the case of missing arguments here... Something like ``` if constexpr (!std::is_same_v< Args, std::monostate>) { if (!request.rawArguments) { // Send error... return; } if (!fromJSON(request.rawArguments, arguments, root)) { // Send error... return; } } ``` https://github.com/llvm/llvm-project/pull/130090 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits