From 17aeaf2d0a7b174a8721e554cac8ad83cf7e7a0e Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 10 Jul 2015 16:30:24 +0300 Subject: [PATCH] dsdlc template fix --- .../data_type_template.tmpl | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl index c31791b481..0e477c6bc4 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl @@ -137,14 +137,14 @@ public: * If the union is set to another type, returns null pointer. */ template - const T* as() const; + const typename ::uavcan::StorageType::Type* as() const; /** * 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. */ template - T& to(); + typename ::uavcan::StorageType::Type& to(); % endif @@ -305,35 +305,40 @@ ${generate_codec_calls_per_field(call_name='decode', self_parameter_type='Refere % if union: % for idx,a in enumerate(fields): -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}; } + % endfor % for idx,a in enumerate(fields): -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; } + % endfor % for idx,a in enumerate(fields): -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}) { _tag_ = ${idx}; - ${a.name} = FieldTypes::${a.name}(); + ${a.name} = ::uavcan::StorageType< typename FieldTypes::${a.name} >::Type(); } return ${a.name}; } + % endfor % endif