Skip to content

Commit

Permalink
fix union switch and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Brat-vseznamus committed Aug 1, 2024
1 parent 69c77b9 commit 42ce2c1
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 164 deletions.
6 changes: 0 additions & 6 deletions internal/tlcodegen/test/gen/cases_cpp/benchmarks/details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ void tl2::details::BenchmarksVrutoyPositionsReset(::tl2::benchmarks::VrutoyPosit
}

bool tl2::details::BenchmarksVrutoyPositionsWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoyPositions& item, uint32_t nat_n) {
auto add_comma = false;
s << "{";
if ((item.next_positions.size() != 0) || (nat_n != 0)) {
add_comma = true;
s << "\"next_positions\":";
if (!::tl2::details::BuiltinTupleBenchmarksVruPositionWriteJSON(s, item.next_positions, nat_n)) { return false; }
}
Expand Down Expand Up @@ -378,9 +376,7 @@ void tl2::details::BenchmarksVrutoyTopLevelContainerReset(::tl2::benchmarks::Vru
}

bool tl2::details::BenchmarksVrutoyTopLevelContainerWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoyTopLevelContainer& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"value\":";
if (!::tl2::details::BenchmarksVrutoyTopLevelUnionWriteJSON(s, item.value)) { return false; }
s << "}";
Expand Down Expand Up @@ -574,10 +570,8 @@ void tl2::details::BenchmarksVrutoytopLevelUnionBigReset(::tl2::benchmarks::Vrut
}

bool tl2::details::BenchmarksVrutoytopLevelUnionBigWriteJSON(std::ostream& s, const ::tl2::benchmarks::VrutoytopLevelUnionBig& item) {
auto add_comma = false;
s << "{";
if (item.next_positions.size() != 0) {
add_comma = true;
s << "\"next_positions\":";
if (!::tl2::details::BuiltinVectorBenchmarksVruPositionWriteJSON(s, item.next_positions)) { return false; }
}
Expand Down
22 changes: 1 addition & 21 deletions internal/tlcodegen/test/gen/cases_cpp/cases/details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,10 +1178,8 @@ void tl2::details::CasesTestDictAnyReset(::tl2::cases::TestDictAny& item) {
}

bool tl2::details::CasesTestDictAnyWriteJSON(std::ostream& s, const ::tl2::cases::TestDictAny& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::DictionaryAnyDoubleIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -1239,10 +1237,8 @@ void tl2::details::CasesTestDictIntReset(::tl2::cases::TestDictInt& item) {
}

bool tl2::details::CasesTestDictIntWriteJSON(std::ostream& s, const ::tl2::cases::TestDictInt& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::BuiltinVectorDictionaryFieldAnyIntIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -1300,10 +1296,8 @@ void tl2::details::CasesTestDictStringReset(::tl2::cases::TestDictString& item)
}

bool tl2::details::CasesTestDictStringWriteJSON(std::ostream& s, const ::tl2::cases::TestDictString& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::DictionaryIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -1571,9 +1565,7 @@ void tl2::details::CasesTestEnumContainerReset(::tl2::cases::TestEnumContainer&
}

bool tl2::details::CasesTestEnumContainerWriteJSON(std::ostream& s, const ::tl2::cases::TestEnumContainer& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"value\":";
if (!::tl2::details::CasesTestEnumWriteJSON(s, item.value)) { return false; }
s << "}";
Expand Down Expand Up @@ -1742,10 +1734,8 @@ void tl2::details::CasesTestMaybeReset(::tl2::cases::TestMaybe& item) {
}

bool tl2::details::CasesTestMaybeWriteJSON(std::ostream& s, const ::tl2::cases::TestMaybe& item) {
auto add_comma = false;
s << "{";
if (item.value.has_value()) {
add_comma = true;
s << "\"value\":";
if (!::tl2::details::IntMaybeWriteJSON(s, item.value)) { return false; }
}
Expand Down Expand Up @@ -2106,9 +2096,7 @@ void tl2::details::CasesTestTupleReset(::tl2::cases::TestTuple& item) {
}

bool tl2::details::CasesTestTupleWriteJSON(std::ostream& s, const ::tl2::cases::TestTuple& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"tpl\":";
if (!::tl2::details::BuiltinTuple4IntWriteJSON(s, item.tpl)) { return false; }
s << "}";
Expand Down Expand Up @@ -2240,10 +2228,8 @@ void tl2::details::CasesTestUnion1Reset(::tl2::cases::TestUnion1& item) {
}

bool tl2::details::CasesTestUnion1WriteJSON(std::ostream& s, const ::tl2::cases::TestUnion1& item) {
auto add_comma = false;
s << "{";
if (item.value != 0) {
add_comma = true;
s << "\"value\":";
s << item.value;
}
Expand Down Expand Up @@ -2301,10 +2287,8 @@ void tl2::details::CasesTestUnion2Reset(::tl2::cases::TestUnion2& item) {
}

bool tl2::details::CasesTestUnion2WriteJSON(std::ostream& s, const ::tl2::cases::TestUnion2& item) {
auto add_comma = false;
s << "{";
if (item.value.size() != 0) {
add_comma = true;
s << "\"value\":";
s << "\"" << item.value << "\"";
}
Expand Down Expand Up @@ -2362,9 +2346,7 @@ void tl2::details::CasesTestUnionContainerReset(::tl2::cases::TestUnionContainer
}

bool tl2::details::CasesTestUnionContainerWriteJSON(std::ostream& s, const ::tl2::cases::TestUnionContainer& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"value\":";
if (!::tl2::details::CasesTestUnionWriteJSON(s, item.value)) { return false; }
s << "}";
Expand Down Expand Up @@ -2421,10 +2403,8 @@ void tl2::details::CasesTestVectorReset(::tl2::cases::TestVector& item) {
}

bool tl2::details::CasesTestVectorWriteJSON(std::ostream& s, const ::tl2::cases::TestVector& item) {
auto add_comma = false;
s << "{";
if (item.arr.size() != 0) {
add_comma = true;
s << "\"arr\":";
if (!::tl2::details::BuiltinVectorIntWriteJSON(s, item.arr)) { return false; }
}
Expand Down Expand Up @@ -2456,7 +2436,7 @@ bool tl2::details::IntMaybeWriteJSON(std::ostream & s, const std::optional<int32
s << "{";
if (item) {
s << "\"ok\":true";
if(*item != 0) {
if((*item) != 0) {
s << ",\"value\":";
s << *item;
}
Expand Down
14 changes: 0 additions & 14 deletions internal/tlcodegen/test/gen/cases_cpp/cases_bytes/details.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,8 @@ void tl2::details::CasesBytesTestDictAnyReset(::tl2::cases_bytes::TestDictAny& i
}

bool tl2::details::CasesBytesTestDictAnyWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestDictAny& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::DictionaryAnyDoubleIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -330,10 +328,8 @@ void tl2::details::CasesBytesTestDictIntReset(::tl2::cases_bytes::TestDictInt& i
}

bool tl2::details::CasesBytesTestDictIntWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestDictInt& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::BuiltinVectorDictionaryFieldAnyIntIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -391,10 +387,8 @@ void tl2::details::CasesBytesTestDictStringReset(::tl2::cases_bytes::TestDictStr
}

bool tl2::details::CasesBytesTestDictStringWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestDictString& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::DictionaryIntWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -452,10 +446,8 @@ void tl2::details::CasesBytesTestDictStringStringReset(::tl2::cases_bytes::TestD
}

bool tl2::details::CasesBytesTestDictStringStringWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestDictStringString& item) {
auto add_comma = false;
s << "{";
if (item.dict.size() != 0) {
add_comma = true;
s << "\"dict\":";
if (!::tl2::details::DictionaryStringWriteJSON(s, item.dict)) { return false; }
}
Expand Down Expand Up @@ -723,9 +715,7 @@ void tl2::details::CasesBytesTestEnumContainerReset(::tl2::cases_bytes::TestEnum
}

bool tl2::details::CasesBytesTestEnumContainerWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestEnumContainer& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"value\":";
if (!::tl2::details::CasesTestEnumWriteJSON(s, item.value)) { return false; }
s << "}";
Expand Down Expand Up @@ -782,9 +772,7 @@ void tl2::details::CasesBytesTestTupleReset(::tl2::cases_bytes::TestTuple& item)
}

bool tl2::details::CasesBytesTestTupleWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestTuple& item) {
auto add_comma = false;
s << "{";
add_comma = true;
s << "\"tpl\":";
if (!::tl2::details::BuiltinTuple4StringWriteJSON(s, item.tpl)) { return false; }
s << "}";
Expand Down Expand Up @@ -841,10 +829,8 @@ void tl2::details::CasesBytesTestVectorReset(::tl2::cases_bytes::TestVector& ite
}

bool tl2::details::CasesBytesTestVectorWriteJSON(std::ostream& s, const ::tl2::cases_bytes::TestVector& item) {
auto add_comma = false;
s << "{";
if (item.arr.size() != 0) {
add_comma = true;
s << "\"arr\":";
if (!::tl2::details::BuiltinVectorStringWriteJSON(s, item.arr)) { return false; }
}
Expand Down
Loading

0 comments on commit 42ce2c1

Please sign in to comment.