Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions include/dap/typeof.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ M member_type(M T::*);
bool TypeOf<STRUCT>::deserializeFields(const Deserializer* fd, void* obj) { \
using StructTy = STRUCT; \
(void)sizeof(StructTy); /* avoid unused 'using' warning */ \
for (auto& field : std::initializer_list<Field>{__VA_ARGS__}) { \
if (!fd->field(field.name, [&](Deserializer* d) { \
auto ptr = reinterpret_cast<uint8_t*>(obj) + field.offset; \
return field.type->deserialize(d, ptr); \
const std::initializer_list<Field> fields{__VA_ARGS__}; \
for (const auto& field : fields) { \
const auto ptr = reinterpret_cast<uint8_t*>(obj) + field.offset; \
const auto type = field.type; \
if (!fd->field(field.name, [ptr, type](Deserializer* d) { \
return type->deserialize(d, ptr); \
})) { \
return false; \
} \
Expand All @@ -177,10 +179,12 @@ M member_type(M T::*);
bool TypeOf<STRUCT>::serializeFields(FieldSerializer* fs, const void* obj) {\
using StructTy = STRUCT; \
(void)sizeof(StructTy); /* avoid unused 'using' warning */ \
for (auto& field : std::initializer_list<Field>{__VA_ARGS__}) { \
if (!fs->field(field.name, [&](Serializer* s) { \
auto ptr = reinterpret_cast<const uint8_t*>(obj) + field.offset; \
return field.type->serialize(s, ptr); \
const std::initializer_list<Field> fields{__VA_ARGS__}; \
for (const auto& field : fields) { \
const auto ptr = reinterpret_cast<const uint8_t*>(obj) + field.offset; \
const auto type = field.type; \
if (!fs->field(field.name, [ptr, type](Serializer* s) { \
return type->serialize(s, ptr); \
})) { \
return false; \
} \
Expand Down