Fix Response type info, make response 'body' field optional

The `body` field of the Response is optional. Do not error if it is missing.

If the typeinfo of the response. This was incorrectly using the Request type.

Authored by kuafuwang, squashed by ben-clayton.
This commit is contained in:
kuafuwang
2020-01-01 04:58:33 +08:00
committed by Ben Clayton
parent eab43f3518
commit 73d697eac4
3 changed files with 43 additions and 18 deletions

View File

@@ -201,7 +201,8 @@ class Session {
virtual void registerHandler(const TypeInfo* typeinfo,
const GenericResponseSentHandler& handler) = 0;
virtual bool send(const dap::TypeInfo* typeinfo,
virtual bool send(const dap::TypeInfo* requestTypeInfo,
const dap::TypeInfo* responseTypeInfo,
const void* request,
const GenericResponseHandler& responseHandler) = 0;
@@ -251,9 +252,9 @@ template <typename T, typename>
future<ResponseOrError<typename T::Response>> Session::send(const T& request) {
using Response = typename T::Response;
promise<ResponseOrError<Response>> promise;
const TypeInfo* typeinfo = TypeOf<T>::type();
auto sent =
send(typeinfo, &request, [=](const void* result, const Error* error) {
auto sent = send(
TypeOf<T>::type(), TypeOf<Response>::type(), &request,
[=](const void* result, const Error* error) {
if (error != nullptr) {
promise.set_value(ResponseOrError<Response>(*error));
} else {