Search before asking
Version
Latest
Component(s)
C++
Minimal reproduce step
When use a normal struct with uint32_t, the type id is 0x0C, but write data as 8 bytes like 0x01 0x00 0x00 0x00.
What did you expect to see?
If use 0x0C, the data should be 0x01.
What did you see instead?
I see a comment at Serializer<uint32_t> and Serializer<uint64_t>:
/// uint32_t serializer - uses VAR_UINT32 to match Rust xlang mode
template <> struct Serializer<uint32_t> {
... codes
/// uint64_t serializer - uses VAR_UINT64 to match Rust xlang mode
template <> struct Serializer<uint64_t> {
... codes
But if using a struct, in struct_serializer.h -> write_struct_fields_impl function, it will walk in branch:
if constexpr (prim_count == total_count) {
...codes
}
So it will use write_primitive_fields_fast function to write data. It will let uint32_t field in fixed_count, so it will walk into branch:
if constexpr (fixed_count > 0 && fixed_bytes > 0) {
write_fixed_primitive_fields<T>(obj, buffer,
std::make_index_sequence<fixed_count>{});
}
So maybe let uint32_t as a varint when use FORY_STRUCT?
Anything Else?
No response
Are you willing to submit a PR?
Search before asking
Version
Latest
Component(s)
C++
Minimal reproduce step
When use a normal struct with
uint32_t, the type id is0x0C, but write data as 8 bytes like0x01 0x00 0x00 0x00.What did you expect to see?
If use
0x0C, the data should be0x01.What did you see instead?
I see a comment at
Serializer<uint32_t>andSerializer<uint64_t>:But if using a
struct, instruct_serializer.h -> write_struct_fields_implfunction, it will walk in branch:So it will use
write_primitive_fields_fastfunction to write data. It will letuint32_tfield infixed_count, so it will walk into branch:So maybe let
uint32_tas avarintwhen useFORY_STRUCT?Anything Else?
No response
Are you willing to submit a PR?