mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-04 19:51:35 +08:00
dsdlc template fix
This commit is contained in:
@@ -137,14 +137,14 @@ public:
|
|||||||
* If the union is set to another type, returns null pointer.
|
* If the union is set to another type, returns null pointer.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T* as() const;
|
const typename ::uavcan::StorageType<T>::Type* as() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches the union to the given type and returns a mutable reference to the appropriate field.
|
* Switches the union to the given type and returns a mutable reference to the appropriate field.
|
||||||
* If the previous type was different, a default constructor will be executed.
|
* If the previous type was different, a default constructor will be executed.
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T& to();
|
typename ::uavcan::StorageType<T>::Type& to();
|
||||||
% endif
|
% endif
|
||||||
<!--(end)-->
|
<!--(end)-->
|
||||||
|
|
||||||
@@ -305,35 +305,40 @@ ${generate_codec_calls_per_field(call_name='decode', self_parameter_type='Refere
|
|||||||
|
|
||||||
% if union:
|
% if union:
|
||||||
% for idx,a in enumerate(fields):
|
% for idx,a in enumerate(fields):
|
||||||
template <int _tmpl>
|
|
||||||
template <>
|
template <>
|
||||||
bool ${scope_prefix}::is< typename ${scope_prefix}::FieldTypes::${a.name} >() const
|
template <>
|
||||||
|
bool ${scope_prefix}<0>::is< typename ${scope_prefix}<0>::FieldTypes::${a.name} >() const
|
||||||
{
|
{
|
||||||
return _tag_ == ${idx};
|
return _tag_ == ${idx};
|
||||||
}
|
}
|
||||||
|
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for idx,a in enumerate(fields):
|
% for idx,a in enumerate(fields):
|
||||||
template <int _tmpl>
|
|
||||||
template <>
|
template <>
|
||||||
const T* ${scope_prefix}::as< typename ${scope_prefix}::FieldTypes::${a.name} >() const
|
template <>
|
||||||
|
const typename ::uavcan::StorageType< typename ${scope_prefix}<0>::FieldTypes::${a.name} >::Type*
|
||||||
|
${scope_prefix}<0>::as< typename ${scope_prefix}<0>::FieldTypes::${a.name} >() const
|
||||||
{
|
{
|
||||||
return is< typename FieldTypes::${a.name} >() ? &${a.name} : NULL;
|
return is< typename FieldTypes::${a.name} >() ? &${a.name} : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
% for idx,a in enumerate(fields):
|
% for idx,a in enumerate(fields):
|
||||||
template <int _tmpl>
|
|
||||||
template <>
|
template <>
|
||||||
T& ${scope_prefix}::to< ${scope_prefix}::FieldTypes::${a.name} >()
|
template <>
|
||||||
|
typename ::uavcan::StorageType< typename ${scope_prefix}<0>::FieldTypes::${a.name} >::Type&
|
||||||
|
${scope_prefix}<0>::to< ${scope_prefix}<0>::FieldTypes::${a.name} >()
|
||||||
{
|
{
|
||||||
if (_tag_ != ${idx})
|
if (_tag_ != ${idx})
|
||||||
{
|
{
|
||||||
_tag_ = ${idx};
|
_tag_ = ${idx};
|
||||||
${a.name} = FieldTypes::${a.name}();
|
${a.name} = ::uavcan::StorageType< typename FieldTypes::${a.name} >::Type();
|
||||||
}
|
}
|
||||||
return ${a.name};
|
return ${a.name};
|
||||||
}
|
}
|
||||||
|
|
||||||
% endfor
|
% endfor
|
||||||
% endif
|
% endif
|
||||||
<!--(end)-->
|
<!--(end)-->
|
||||||
|
|||||||
Reference in New Issue
Block a user