MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / processResponse

Method processResponse

3rdparty/cppdap/src/session.cpp:441–482  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

439 }
440
441 void processResponse(const dap::Deserializer* d) {
442 dap::integer requestSeq = 0;
443 if (!d->field("request_seq", &requestSeq)) {
444 handlers.error("Response missing int 'request_seq' field");
445 return;
446 }
447
448 const dap::TypeInfo* typeinfo;
449 GenericResponseHandler handler;
450 std::tie(typeinfo, handler) = handlers.response(requestSeq);
451 if (!typeinfo) {
452 handlers.error("Unknown response with sequence %d", requestSeq);
453 return;
454 }
455
456 dap::boolean success = false;
457 if (!d->field("success", &success)) {
458 handlers.error("Response missing int 'success' field");
459 return;
460 }
461
462 if (success) {
463 auto data = std::unique_ptr<uint8_t[]>(new uint8_t[typeinfo->size()]);
464 typeinfo->construct(data.get());
465
466 // "body" field in Response is an optional field.
467 d->field("body", [&](const dap::Deserializer* d) {
468 return typeinfo->deserialize(d, data.get());
469 });
470
471 handler(data.get(), nullptr);
472 typeinfo->destruct(data.get());
473 } else {
474 std::string message;
475 if (!d->field("message", &message)) {
476 handlers.error("Failed to deserialize message");
477 return;
478 }
479 auto error = dap::Error("%s", message.c_str());
480 handler(nullptr, &error);
481 }
482 }
483
484 std::atomic<bool> isBound = {false};
485 dap::ContentReader reader;

Callers

nothing calls this directly

Calls 10

ErrorClass · 0.85
errorMethod · 0.80
responseMethod · 0.80
c_strMethod · 0.80
fieldMethod · 0.45
sizeMethod · 0.45
constructMethod · 0.45
getMethod · 0.45
deserializeMethod · 0.45
destructMethod · 0.45

Tested by

no test coverage detected