THRIFT-4989: Fix run time exception when using Swift TCompactProtocol

Client: Swift
Patch: David Furey

This closes #1908

Sort TStruct members by key before generating class properties so that Swift Thrift lib can use delta encoding for CompactProtocol.
This commit is contained in:
David Furey 2019-11-01 09:52:37 +00:00 committed by Jens Geyer
parent 9ea48f362a
commit b1d4b3afcc

View File

@ -697,7 +697,9 @@ void t_swift_generator::generate_swift_struct(ostream& out,
}
block_open(out);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
vector<t_field*> sorted = members;
sort(sorted.begin(), sorted.end(), [](t_field *a, t_field *b) { return (a->get_key() < b->get_key()); } );
for (m_iter = sorted.begin(); m_iter != sorted.end(); ++m_iter) {
out << endl;
// TODO: Defaults