A callback function to signal that the endpoint has closed its connection.
Add this as an optional argument to Session::bind() and Session::startProcessingMessages().
Bug: #98
* CMake: Fix target options
* update CMake package version after protocol sync
* Update protocol to 1.59.0
* protocol_gen: change OneOf to `object` type
The DAP spec introduces ambiguities with its particular uses of OneOf,
which means that we can't deserialize the variants generated from it.
Just set OneOf to an `object` type, like godap does.
This was entirely broken:
* The `Server` `Impl` used a `do{}while(false)` block, which never attempted to accept another connection after the first connection closed (#69)
* The `Server` `Impl` could deadlock with the mutex being locked by both the thread calling `isRunning()` and `stopWithLock()` waiting on `thread.join()`.
* `Socket::accept()` didn't check that the returned socket was valid, and could return a `ReaderWriter` that would just error on IO.
* `Socket::accept()` could deadlock on macOS as `shutdown()` can seemingly fail to unblock an accept call. This has been worked around by calling `close()` outside of the mutex write-lock. This introduces a potential race, but I'm not sure of a better solution right now.
Fixes: #69
Schema top-level definitions, such as `InvalidatedAreas` and `SteppingGranularity` were being emitted as empty structures, when they were actually enumerators.
Re-work protocol_gen.go to emit these correctly.
Also bumps the protocol to DAP version 1.46.0
When there is partial message in reader, popping out the
characters lead to parse errors on the subsequent attempt
to parse. To avoid this, the last matched characters'
index is stored during parsing and reset on error.
Bind API is split into connect and startProcessingMessages calls.
This enables users to directly call connect and manage processing
messages on user threads.
bindNoThread in conjunction with OnDataAvailable will provide
users with a choice of thread to process requests on. This is
useful when the user relies on single threaded message loop based
design to avoid locking.
Define `JSON_NOEXCEPTION` to avoid raising exceptions.
Exceptions are usually disabled for Google projects (https://google.github.io/styleguide/cppguide.html#Exceptions).
Also pass `false` to the `allow_exceptions` parameter of `nlohmann::json::parse()`.
Issue identified by @kuafuwang in #26.
`DAP_IMPLEMENT_STRUCT_TYPEINFO_EXT` and `DAP_STRUCT_TYPEINFO_EXT` are two new flavors of `DAP_IMPLEMENT_STRUCT_TYPEINFO` and `DAP_STRUCT_TYPEINFO` that allow you to derive message types.
This involved a bit of reworking on the serializer interfaces.
Added test.
Issue: #32
DAP usually consists of small packet requests, with small packet responses. When there are many frequent, blocking requests made, Nagle's algorithm can dramatically limit the request->response rates.
Empty structs were being serialized as `null`, when they should have been serialized as `{}`.
This was due to the type inference on the serializer - where no calls to `field()` would result in the default `null` type.
To solve this, the `serialize(const void* object, const std::initializer_list<Field>&)` inline helper has been promoted to a virtual function (and renamed to `fields()`).
The JSON serializer implementation of this now first sets the object type to `object`, even if there are no fields to serialize.
Added test for this.
Fixes: #10
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.