diff --git a/src/CppGenerator.cc b/src/CppGenerator.cc index 6d2b3f9..84328e9 100644 --- a/src/CppGenerator.cc +++ b/src/CppGenerator.cc @@ -508,6 +508,8 @@ void CppGenerator::scanRequirements(Message *m) hasUnused = true; continue; } + if (f->isObsolete()) + continue; int id = f->getId(); if ((id == 0) && !target->getFlag("id0")) error("Use of id 0 requires special considerations. Enable support for it with option id0."); @@ -633,36 +635,28 @@ void CppGenerator::scanRequirements(Message *m) break; // fixed case ft_fixed8: - hasU8 = true; hasWT8 = true; break; case ft_fixed16: - hasU16 = true; hasWT16 = true; break; case ft_fixed32: - hasU32 = true; hasWT32 = true; break; case ft_fixed64: - hasU64 = true; hasWT64 = true; break; // sfixed case ft_sfixed8: - hasS8 = true; hasWT8 = true; break; case ft_sfixed16: - hasS16 = true; hasWT16 = true; break; case ft_sfixed32: - hasS32 = true; hasWT32 = true; break; case ft_sfixed64: - hasS64 = true; hasWT64 = true; break; default: @@ -4387,7 +4381,7 @@ void CppGenerator::writeHelpers(vector &funcs) if (hasCStr || hasString) funcs.push_back(ct_json_cstr); funcs.push_back(ct_to_decstr); - if (hasFloat|hasDouble) + if (hasFloat || hasDouble) funcs.push_back(ct_to_dblstr); } @@ -4409,21 +4403,21 @@ void CppGenerator::writeHelpers(vector &funcs) funcs.push_back(ct_parse_ascii_dbl); if (hasFloat) funcs.push_back(ct_parse_ascii_flt); - if (hasU64) + if (hasU64||hasWT64) funcs.push_back(ct_parse_ascii_u64); - if (hasU32) + if (hasU32||hasWT32) funcs.push_back(ct_parse_ascii_u32); - if (hasU16) + if (hasU16||hasWT16) funcs.push_back(ct_parse_ascii_u16); - if (hasU8) + if (hasU8||hasWT8) funcs.push_back(ct_parse_ascii_u8); - if (hasS64) + if (hasS64||hasWT64) funcs.push_back(ct_parse_ascii_s64); - if (hasS32) + if (hasS32||hasWT32) funcs.push_back(ct_parse_ascii_s32); - if (hasS16) + if (hasS16||hasWT16) funcs.push_back(ct_parse_ascii_s16); - if (hasS8) + if (hasS8||hasWT8) funcs.push_back(ct_parse_ascii_s8); if (hasBytes) funcs.push_back(ct_parse_ascii_bytes); diff --git a/testsuite/testcases/xint.wfc b/testsuite/testcases/xint.wfc new file mode 100644 index 0000000..2aa3a95 --- /dev/null +++ b/testsuite/testcases/xint.wfc @@ -0,0 +1,10 @@ +option varintbits=32; +option intsize=32; + +message xint +{ + int8 i8 = 1; + int16 i16 = 2; + sint8 s8 = 3; + sint16 s16 = 4; +} diff --git a/testsuite/testcases/xint_test.cpp b/testsuite/testcases/xint_test.cpp new file mode 100644 index 0000000..4ac192f --- /dev/null +++ b/testsuite/testcases/xint_test.cpp @@ -0,0 +1,33 @@ +#include "xint.h" +#include +#include "runcheck.h" +#include "runcheck.cpp" + + +int main() +{ + xint x; + x.set_i8(-1); + x.set_i16(-1); + x.set_s8(-1); + x.set_s16(-1); + runcheck(x); + + x.set_i8(1); + x.set_i16(1); + x.set_s8(1); + x.set_s16(1); + runcheck(x); + + x.set_i8(INT8_MAX); + x.set_i16(INT16_MAX); + x.set_s8(INT8_MAX); + x.set_s16(INT16_MAX); + runcheck(x); + + x.set_i8(INT8_MIN); + x.set_i16(INT16_MIN); + x.set_s8(INT8_MIN); + x.set_s16(INT16_MIN); + runcheck(x); +}