MCPcopy Create free account
hub / github.com/dfranx/SHADERed / processResponse

Method processResponse

libs/cppdap/src/session.cpp:414–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412 }
413
414 void processResponse(const dap::Deserializer* d) {
415 dap::integer requestSeq = 0;
416 if (!d->field("request_seq", &requestSeq)) {
417 handlers.error("Response missing int 'request_seq' field");
418 return;
419 }
420
421 const dap::TypeInfo* typeinfo;
422 GenericResponseHandler handler;
423 std::tie(typeinfo, handler) = handlers.response(requestSeq);
424 if (!typeinfo) {
425 handlers.error("Unknown response with sequence %d", requestSeq);
426 return;
427 }
428
429 dap::boolean success = false;
430 if (!d->field("success", &success)) {
431 handlers.error("Response missing int 'success' field");
432 return;
433 }
434
435 if (success) {
436 auto data = std::unique_ptr<uint8_t[]>(new uint8_t[typeinfo->size()]);
437 typeinfo->construct(data.get());
438
439 // "body" field in Response is an optional field.
440 d->field("body", [&](const dap::Deserializer* d) {
441 return typeinfo->deserialize(d, data.get());
442 });
443
444 handler(data.get(), nullptr);
445 typeinfo->destruct(data.get());
446 } else {
447 std::string message;
448 if (!d->field("message", &message)) {
449 handlers.error("Failed to deserialize message");
450 return;
451 }
452 auto error = dap::Error("%s", message.c_str());
453 handler(nullptr, &error);
454 }
455 }
456
457 bool send(const std::string& s) {
458 std::unique_lock<std::mutex> lock(sendMutex);

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected