diff --git a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp index 289831003..9ae807b1e 100644 --- a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp +++ b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp @@ -115,13 +115,30 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) replaceCommonTags(outInclude, info); replaceCommonTags(outCode, info); + // Use the appropriate typedef for enums where we find them. Set up + // that StringList here for use below. + // + QStringList typeList; + for (int n = 0; n < info->fields.length(); ++n) + { + if (info->fields[n]->type == FIELDTYPE_ENUM) + { + typeList << QString("%1%2Options").arg(info->name).arg(info->fields[n]->name); + } + else + { + typeList << fieldTypeStrC[info->fields[n]->type]; + } + } + // Replace the $(DATAFIELDS) tag QString type; QString fields; QString dataStructures; for (int n = 0; n < info->fields.length(); ++n) { // Determine type - type = fieldTypeStrC[info->fields[n]->type]; + //type = fieldTypeStrC[info->fields[n]->type]; // RHV TODO: remove + type = typeList[n]; // Append field // Check if it a named set and creates structures accordingly if (info->fields[n]->numElements > 1) { @@ -260,28 +277,29 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) { // For non-array fields if (info->fields[n]->numElements == 1) { + /* Set */ setgetfields.append(QString("void %2%3Set(%1 *New%3)\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name)); setgetfields.append(QString("{\n")); setgetfields.append(QString(" UAVObjSetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), sizeof(%3));\n") .arg(info->name) .arg(info->fields[n]->name) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); /* GET */ setgetfields.append(QString("void %2%3Get(%1 *New%3)\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name)); setgetfields.append(QString("{\n")); setgetfields.append(QString(" UAVObjGetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), sizeof(%3));\n") .arg(info->name) .arg(info->fields[n]->name) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); } else { // When no struct accessor is available for a field array accessor is the default. @@ -300,7 +318,7 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) .arg(info->name) .arg(info->fields[n]->name) .arg(info->fields[n]->numElements) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); /* GET */ @@ -313,7 +331,7 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) .arg(info->name) .arg(info->fields[n]->name) .arg(info->fields[n]->numElements) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); // Append array suffix to array accessors @@ -323,7 +341,7 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) // array based field accessor /* SET */ setgetfields.append(QString("void %2%3%4Set( %1 *New%3 )\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name) .arg(suffix)); @@ -332,12 +350,12 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) .arg(info->name) .arg(info->fields[n]->name) .arg(info->fields[n]->numElements) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); /* GET */ setgetfields.append(QString("void %2%3%4Get( %1 *New%3 )\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name) .arg(suffix)); @@ -346,7 +364,7 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) .arg(info->name) .arg(info->fields[n]->name) .arg(info->fields[n]->numElements) - .arg(fieldTypeStrC[info->fields[n]->type])); + .arg(typeList[n])); setgetfields.append(QString("}\n")); } } @@ -378,14 +396,14 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo *info) } /* SET */ setgetfieldsextern.append(QString("extern void %2%3%4Set(%1 *New%3);\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name) .arg(suffix)); /* GET */ setgetfieldsextern.append(QString("extern void %2%3%4Get(%1 *New%3);\n") - .arg(fieldTypeStrC[info->fields[n]->type]) + .arg(typeList[n]) .arg(info->name) .arg(info->fields[n]->name) .arg(suffix));