From d7ec6918beacab4c7e3c1a56c55edaaf3beeb59b Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Wed, 9 Apr 2014 19:28:26 +0400 Subject: [PATCH] dsdlc: YAML streamer specialization methods defined out-of-line --- .../data_type_template.tmpl | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 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 36af3ec558..2879d70062 100644 --- a/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl +++ b/libuavcan/dsdl_compiler/libuavcan_dsdl_compiler/data_type_template.tmpl @@ -295,6 +295,9 @@ const ::uavcan::DefaultDataTypeRegistrator< ${t.cpp_full_type_name} > _uavcan_gd } // Namespace ${nsc} % endfor +/* + * YAML streamer specialization + */ namespace uavcan { @@ -303,30 +306,33 @@ template <> struct UAVCAN_EXPORT YamlStreamer< ${type_name} > { template - static void stream(Stream& s, ${type_name}::ParameterType obj, const int level) - { + static void stream(Stream& s, ${type_name}::ParameterType obj, const int level); +}; + +template +void YamlStreamer< ${type_name} >::stream(Stream& s, ${type_name}::ParameterType obj, const int level) +{ % for idx,a in enumerate(fields): - % if idx == 0: - if (level > 0) - { - s << '\n'; - for (int pos = 0; pos < level; pos++) - { - s << " "; - } - } - % else: +% if idx == 0: + if (level > 0) + { s << '\n'; for (int pos = 0; pos < level; pos++) { s << " "; } - % endif - s << "${a.name}: "; - YamlStreamer< ${type_name}::FieldTypes::${a.name} >::stream(s, obj.${a.name}, level + 1); -% endfor } -}; +% else: + s << '\n'; + for (int pos = 0; pos < level; pos++) + { + s << " "; + } +% endif + s << "${a.name}: "; + YamlStreamer< ${type_name}::FieldTypes::${a.name} >::stream(s, obj.${a.name}, level + 1); +% endfor +} % if t.kind == t.KIND_SERVICE: ${define_yaml_streamer(t.cpp_full_type_name + '::Request', t.request_fields)}