Fix number->string conversion in struct parsing

This commit is contained in:
GriffinR 2024-03-21 15:24:08 -04:00
parent 56e4955c54
commit 6fe8539461
2 changed files with 8 additions and 8 deletions

View file

@ -77,16 +77,16 @@ namespace fex
switch (type_) switch (type_)
{ {
case Type::kEmpty: case Type::kEmpty:
return "kEmpty: {}"; return "{}";
case Type::kNumber: case Type::kNumber:
return "kNumber: " + std::to_string(int_value_); return std::to_string(int_value_);
case Type::kString: case Type::kString:
return "kString: \"" + string_value_ + "\""; return "\"" + string_value_ + "\"";
case Type::kIdentifier: case Type::kIdentifier:
return "kIdentifier: " + string_value_; return string_value_;
case Type::kValueList: case Type::kValueList:
{ {
std::string out = "kValueList: {\n"; std::string out = "{\n";
for (const ArrayValue &v : values_) for (const ArrayValue &v : values_)
{ {
out += "\t" + v.ToString() + ",\n"; out += "\t" + v.ToString() + ",\n";
@ -94,7 +94,7 @@ namespace fex
return out + "}\n"; return out + "}\n";
} }
case Type::kValuePair: case Type::kValuePair:
return "kValuePair: " + pair_.first + " = " + pair_.second->ToString() + "\n"; return pair_.first + " = " + pair_.second->ToString() + "\n";
} }
} }

View file

@ -564,12 +564,12 @@ QMap<QString, QHash<QString, QString>> ParseUtil::readCStructs(const QString &fi
for (const fex::ArrayValue &v : it->second.values()) { for (const fex::ArrayValue &v : it->second.values()) {
if (v.type() == fex::ArrayValue::Type::kValuePair) { if (v.type() == fex::ArrayValue::Type::kValuePair) {
QString key = QString::fromStdString(v.pair().first); QString key = QString::fromStdString(v.pair().first);
QString value = QString::fromStdString(v.pair().second->string_value()); QString value = QString::fromStdString(v.pair().second->ToString());
values.insert(key, value); values.insert(key, value);
} else { } else {
// For compatibility with structs that don't specify member names. // For compatibility with structs that don't specify member names.
if (memberMap.contains(i) && !values.contains(memberMap.value(i))) if (memberMap.contains(i) && !values.contains(memberMap.value(i)))
values.insert(memberMap.value(i), QString::fromStdString(v.string_value())); values.insert(memberMap.value(i), QString::fromStdString(v.ToString()));
} }
i++; i++;
} }