Christoph Grüninger
bb059f0daf
Add reference in range-for for non-trivial type
...
Avoid copy-ctor and dtor to get called.
Found by Clazy (range-loop-reference)
2024-01-08 09:59:59 +00:00
Brad King
5f49573daf
Fix compiler warning and error encountered on some platforms ( #106 )
...
* typeof: Avoid -Wshadow-uncaptured-local in DAP_IMPLEMENT_STRUCT_TYPEINFO
Previously, applications using `DAP_IMPLEMENT_STRUCT_TYPEINFO` may see:
<app-file>:<app-line>:1: warning: declaration shadows a local variable [-Wshadow-uncaptured-local]
DAP_IMPLEMENT_STRUCT_TYPEINFO(<app-args>),
^
/.../include/dap/typeof.h:199:3: note: expanded from macro 'DAP_IMPLEMENT_STRUCT_TYPEINFO'
DAP_IMPLEMENT_STRUCT_FIELD_SERIALIZATION(STRUCT, NAME, __VA_ARGS__) \
^
/.../include/dap/typeof.h:168:51: note: expanded from macro 'DAP_IMPLEMENT_STRUCT_FIELD_SERIALIZATION'
if (!d->field(field.name, [&](Deserializer* d) { \
^
<app-file>:<app-line>:1: note: previous declaration is here
/.../include/dap/typeof.h:199:3: note: expanded from macro 'DAP_IMPLEMENT_STRUCT_TYPEINFO'
DAP_IMPLEMENT_STRUCT_FIELD_SERIALIZATION(STRUCT, NAME, __VA_ARGS__) \
^
/.../include/dap/typeof.h:164:62: note: expanded from macro 'DAP_IMPLEMENT_STRUCT_FIELD_SERIALIZATION'
bool TypeOf<STRUCT>::deserializeFields(const Deserializer* d, void* obj) { \
^
* io: add missing include for std::string
2023-05-17 19:10:58 +01:00
Ben Clayton
7b02b9f73a
Add dap::initialize() and terminate() functions
...
Can be used to explicitly control when the TypeInfo static initializers / destructors are called.
Usually not needed.
Issue: #40
2020-06-22 19:51:39 +01:00
Ben Clayton
9d3f5c8f1d
clang: Enable -Weverything, fix all warnings
...
This change fixes the following warnings:
```
-Wc++98-compat-extra-semi
-Wc++98-compat-local-type-template-args
-Wc++98-compat-pedantic
-Wc++98-compat
-Wcomma
-Wdeprecated-copy-dtor
-Wexit-time-destructors
-Wextra-semi-stmt
-Wextra-semi
-Wfloat-conversion
-Wfloat-equal
-Wformat-nonliteral
-Wglobal-constructors
-Winconsistent-missing-destructor-override
-Wnon-virtual-dtor
-Wold-style-cast
-Wpadded
-Wreturn-std-move-in-c++11
-Wshadow-field-in-constructor
-Wshadow-uncaptured-local
-Wshift-sign-overflow
-Wsign-conversion
-Wundef
-Wunreachable-code-return
-Wused-but-marked-unused
-Wweak-vtables
-Wzero-as-null-pointer-constant
```
2020-06-10 15:10:57 +01:00
Ben Clayton
cc93ba9747
Add the ability to derive message types from one another.
...
`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
2020-06-02 17:18:32 +01:00
Ben Clayton
cdc19ac4d9
Serialization: Correctly encode structs with no fields
...
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
2020-01-06 15:00:24 +00:00
Ben Clayton
2dfd15462f
Initial drop of cppdap
2019-11-08 21:58:50 +00:00