Skip to content
Snippets Groups Projects
Commit 478c9d26 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

remove useless .empty check. Fix codegeneration for quaternioins for gcc13

parent 1f173728
No related branches found
No related tags found
No related merge requests found
Pipeline #16842 canceled
......@@ -98,7 +98,7 @@ namespace armarx::aron::codegenerator::cpp::generator
{
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "::Identity();");
}
else if (type.getDefaultValue().empty() || type.getDefaultValue() == aron::type::matrix::default_value::DEFAULT || type.getDefaultValue() == aron::type::matrix::default_value::ZEROS)
else if (type.getDefaultValue() == aron::type::matrix::default_value::DEFAULT || type.getDefaultValue() == aron::type::matrix::default_value::ZEROS)
{
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "::Zero();");
}
......
......@@ -62,13 +62,13 @@ namespace armarx::aron::codegenerator::cpp::generator
{
if (type.getDefaultValue() == aron::type::quaternion::default_value::DEFAULT)
{
return {{}, false};
return {{{name, getInstantiatedCppTypename() + "::Identity())"}}, true};
}
if (type.getDefaultValue() == aron::type::quaternion::default_value::ZEROS)
else if (type.getDefaultValue() == aron::type::quaternion::default_value::ZEROS)
{
return {{{name, getInstantiatedCppTypename() + "(0, 0, 0, 0)"}}, true};
}
if (type.getDefaultValue() == aron::type::quaternion::default_value::ONES)
else if (type.getDefaultValue() == aron::type::quaternion::default_value::ONES)
{
return {{{name, getInstantiatedCppTypename() + "(1, 1, 1, 1)"}}, true};
}
......@@ -80,6 +80,31 @@ namespace armarx::aron::codegenerator::cpp::generator
}
}
CppBlockPtr
Quaternion::getResetHardBlock(const std::string& cppAccessor) const
{
CppBlockPtr block_if_data = std::make_shared<CppBlock>();
if (type.getDefaultValue() == aron::type::quaternion::default_value::DEFAULT)
{
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "::Identity();");
}
else if (type.getDefaultValue() == aron::type::quaternion::default_value::ZEROS)
{
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "(0, 0, 0, 0);");
}
else if (type.getDefaultValue() == aron::type::quaternion::default_value::ONES)
{
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "(1, 1, 1, 1);");
}
else if (not type.getDefaultValue().empty())
{
// try to parse num. We ensure from typereader that defaultValue is valid number
block_if_data->addLine(cppAccessor + " = " + getInstantiatedCppTypename() + "(" + type.getDefaultValue() + ");");
}
return resolveMaybeResetHardBlock(block_if_data, cppAccessor);
}
CppBlockPtr
Quaternion::getResetSoftBlock(const std::string& cppAccessor) const
{
......
......@@ -42,6 +42,7 @@ namespace armarx::aron::codegenerator::cpp::generator
std::vector<std::string> getRequiredIncludes() const final;
std::pair<std::vector<std::pair<std::string, std::string>>, bool>
getCtorInitializers(const std::string&) const final;
CppBlockPtr getResetHardBlock(const std::string& cppAccessor) const final;
CppBlockPtr getResetSoftBlock(const std::string& cppAccessor) const final;
CppBlockPtr getWriteTypeBlock(const std::string& typeAccessor,
const std::string& cppAccessor,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment