Add translation infrastructure

This commit is contained in:
Jack Andersen
2018-07-24 20:01:01 -10:00
parent b3958e9d52
commit ca81c07600
10 changed files with 747 additions and 62 deletions

View File

@@ -28,7 +28,50 @@ struct MakeDefaultCmdOp
template <class Tp, class R>
static std::unique_ptr<SoundMacro::ICmd> Do(R& r)
{
return std::make_unique<Tp>();
std::unique_ptr<SoundMacro::ICmd> ret = std::make_unique<Tp>();
if (const SoundMacro::CmdIntrospection* introspection = SoundMacro::GetCmdIntrospection(r))
{
for (int f = 0; f < 7; ++f)
{
const amuse::SoundMacro::CmdIntrospection::Field& field = introspection->m_fields[f];
if (!field.m_name.empty())
{
switch (field.m_tp)
{
case amuse::SoundMacro::CmdIntrospection::Field::Type::Bool:
AccessField<bool>(ret.get(), field) = bool(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::Int8:
case amuse::SoundMacro::CmdIntrospection::Field::Type::Choice:
AccessField<int8_t>(ret.get(), field) = int8_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt8:
AccessField<uint8_t>(ret.get(), field) = uint8_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::Int16:
AccessField<int16_t>(ret.get(), field) = int16_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt16:
AccessField<uint16_t>(ret.get(), field) = uint16_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::Int32:
AccessField<int32_t>(ret.get(), field) = int32_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::UInt32:
AccessField<uint32_t>(ret.get(), field) = uint32_t(field.m_default);
break;
case amuse::SoundMacro::CmdIntrospection::Field::Type::SoundMacroId:
case amuse::SoundMacro::CmdIntrospection::Field::Type::TableId:
case amuse::SoundMacro::CmdIntrospection::Field::Type::SampleId:
AccessField<SoundMacroIdDNA<athena::Little>>(ret.get(), field).id = uint16_t(field.m_default);
break;
default:
break;
}
}
}
}
return ret;
}
};