mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
enums sorted out in code and template, need to merge in latest
This commit is contained in:
parent
69fae1b977
commit
04497a5b77
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user