From 3e2558bec67ab824bc3c8a3862839d8d526cbe02 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 14 Nov 2011 09:49:50 -0600 Subject: [PATCH] Patch from PH which orders fields by size - important for using the M4 FPU --- ground/uavobjgenerator/uavobjectparser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ground/uavobjgenerator/uavobjectparser.cpp b/ground/uavobjgenerator/uavobjectparser.cpp index cba02f8ee..8a69bd9a1 100644 --- a/ground/uavobjgenerator/uavobjectparser.cpp +++ b/ground/uavobjgenerator/uavobjectparser.cpp @@ -111,6 +111,11 @@ int UAVObjectParser::getNumBytes(int objIndex) } } +bool fieldTypeLessThan(const FieldInfo* f1, const FieldInfo* f2) +{ + return f1->numBytes > f2->numBytes; +} + /** * Parse supplied XML file * @param xml The xml text @@ -201,6 +206,9 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename) childNode = childNode.nextSibling(); } + // Sort all fields according to size + qStableSort(info->fields.begin(), info->fields.end(), fieldTypeLessThan); + // Make sure that required elements were found if ( !accessFound ) return QString("Object::access element is missing");