From cc460684aa93d203e84fbc8c32403245c3bc1605 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Busch Date: Wed, 27 Nov 2024 17:36:08 +0100 Subject: [PATCH] unify braces in jinja templates --- .../templates/RosMessageType.msg.jinja2 | 12 ++-- .../templates/convertChoiceType.h.jinja2 | 32 ++++----- .../templates/convertCustomType.h.jinja2 | 24 +++---- .../templates/convertEnumeratedType.h.jinja2 | 18 ++--- .../templates/convertPrimitiveType.h.jinja2 | 26 +++---- .../templates/convertSequenceOfType.h.jinja2 | 36 +++++----- .../templates/convertSequenceType.h.jinja2 | 68 +++++++++---------- 7 files changed, 108 insertions(+), 108 deletions(-) diff --git a/utils/codegen/codegen-py/templates/RosMessageType.msg.jinja2 b/utils/codegen/codegen-py/templates/RosMessageType.msg.jinja2 index 096660be..45b3fc3c 100644 --- a/utils/codegen/codegen-py/templates/RosMessageType.msg.jinja2 +++ b/utils/codegen/codegen-py/templates/RosMessageType.msg.jinja2 @@ -26,25 +26,25 @@ # --- ASN.1 Definition --------------------------------------------------------- {% for line in asn1_definition.split('\n') -%} -# {{ line }} +# {{line}} {% endfor -%} # ------------------------------------------------------------------------------ {% for comment in comments -%} -# {{ comment }} +# {{comment}} {% endfor -%} {% for member in members -%} -{{ member.ros_msg_type }} {{ member.ros_field_name }} +{{member.ros_msg_type}} {{member.ros_field_name}} {% if member.optional -%} -bool {{ member.ros_field_name }}_is_present +bool {{member.ros_field_name}}_is_present {% endif -%} {% if member.default -%} -{{ member.default.ros_msg_type }} {{ member.default.ros_field_name }} = {{ member.default.ros_value }} +{{member.default.ros_msg_type}} {{member.default.ros_field_name}} = {{member.default.ros_value}} {% endif -%} {% if member.has_bits_unused -%} uint8 bits_unused {% endif -%} {% for const in member.constants -%} -{{ const.ros_msg_type }} {{ const.ros_field_name }} = {{ const.ros_value }} +{{const.ros_msg_type}} {{const.ros_field_name}} = {{const.ros_value}} {% endfor %} {% endfor -%} \ No newline at end of file diff --git a/utils/codegen/codegen-py/templates/convertChoiceType.h.jinja2 b/utils/codegen/codegen-py/templates/convertChoiceType.h.jinja2 index c839f98c..edcc4f85 100644 --- a/utils/codegen/codegen-py/templates/convertChoiceType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertChoiceType.h.jinja2 @@ -26,31 +26,31 @@ SOFTWARE. #pragma once -#include +#include {% for member in unique_sorted_members -%} {%- if member.ros_field_name != "choice" -%} -#include +#include {% endif -%} {%- endfor -%} #ifdef ROS1 -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { switch (in.present) { {%- for member in members %} {%- if member.ros_field_name != "choice" -%} {% for const in member.constants %} - case {{etsi_type}}_{{ asn1_type_name }}_PR_{{ member.c_field_name }}: - toRos_{{ member.ros_msg_type|replace("[]", "") }}(in.choice.{{ member.c_field_name }}, out.{{ member.ros_field_name }}); - out.choice = {{ etsi_type}}_msgs::{{ ros_msg_type }}::{{ const.ros_field_name }}; + case {{etsi_type}}_{{asn1_type_name}}_PR_{{member.c_field_name}}: + toRos_{{member.ros_msg_type|replace("[]", "")}}(in.choice.{{member.c_field_name}}, out.{{member.ros_field_name}}); + out.choice = {{etsi_type}}_msgs::{{ros_msg_type}}::{{const.ros_field_name}}; break; {%- endfor %} {%- endif %} @@ -59,16 +59,16 @@ void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name }}_t& in, } } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type }}_{{ asn1_type_name }}_t& out) { - memset(&out, 0, sizeof({{etsi_type}}_{{ asn1_type_name }}_t)); +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name}}_t& out) { + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name}}_t)); switch (in.choice) { {%- for member in members %} {%- if member.ros_field_name != "choice" -%} {% for const in member.constants %} - case {{ etsi_type }}_msgs::{{ ros_msg_type }}::{{ const.ros_field_name }}: - toStruct_{{ member.ros_msg_type|replace("[]", "") }}(in.{{ member.ros_field_name }}, out.choice.{{ member.c_field_name }}); - out.present = {{etsi_type}}_{{ asn1_type_name }}_PR::{{etsi_type}}_{{ asn1_type_name }}_PR_{{ member.c_field_name }}; + case {{etsi_type}}_msgs::{{ros_msg_type}}::{{const.ros_field_name}}: + toStruct_{{member.ros_msg_type|replace("[]", "")}}(in.{{member.ros_field_name}}, out.choice.{{member.c_field_name}}); + out.present = {{etsi_type}}_{{asn1_type_name}}_PR::{{etsi_type}}_{{asn1_type_name}}_PR_{{member.c_field_name}}; break; {%- endfor %} {%- endif %} diff --git a/utils/codegen/codegen-py/templates/convertCustomType.h.jinja2 b/utils/codegen/codegen-py/templates/convertCustomType.h.jinja2 index 31030637..234720ba 100644 --- a/utils/codegen/codegen-py/templates/convertCustomType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertCustomType.h.jinja2 @@ -26,31 +26,31 @@ SOFTWARE. #pragma once -#include +#include {% for member in members -%} -#include +#include {% endfor -%} #ifdef ROS1 -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { {%- for member in members %} - toRos_{{ member.ros_msg_type }}(in, out.{{ member.c_field_name }}); + toRos_{{member.ros_msg_type}}(in, out.{{member.c_field_name}}); {% endfor -%} } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type }}_{{ asn1_type_name }}_t& out) { - memset(&out, 0, sizeof({{ etsi_type}}_{{ asn1_type_name }}_t)); +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name}}_t& out) { + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name}}_t)); {% for member in members %} - toStruct_{{ member.ros_msg_type }}(in.{{ member.ros_field_name }}, out); + toStruct_{{member.ros_msg_type}}(in.{{member.ros_field_name}}, out); {% endfor -%} } diff --git a/utils/codegen/codegen-py/templates/convertEnumeratedType.h.jinja2 b/utils/codegen/codegen-py/templates/convertEnumeratedType.h.jinja2 index ccb88c19..e40b0fa5 100644 --- a/utils/codegen/codegen-py/templates/convertEnumeratedType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertEnumeratedType.h.jinja2 @@ -26,25 +26,25 @@ SOFTWARE. #pragma once -#include +#include #ifdef ROS1 -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { out.value = in; } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type }}_{{ asn1_type_name }}_t& out) { - memset(&out, 0, sizeof({{etsi_type}}_{{ asn1_type_name }}_t)); +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name}}_t& out) { + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name}}_t)); out = in.value; } diff --git a/utils/codegen/codegen-py/templates/convertPrimitiveType.h.jinja2 b/utils/codegen/codegen-py/templates/convertPrimitiveType.h.jinja2 index af86c005..ec6025d6 100644 --- a/utils/codegen/codegen-py/templates/convertPrimitiveType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertPrimitiveType.h.jinja2 @@ -26,34 +26,34 @@ SOFTWARE. #pragma once -#include -#include -#include +#include +#include +#include #ifdef ROS1 -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{etsi_type}}_{{ asn1_type_name|replace("-", "_") }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { {%- for member in members %} - etsi_its_primitives_conversion::toRos_{{ asn1_type_type }}(in, out.{{ member.ros_field_name }}); + etsi_its_primitives_conversion::toRos_{{asn1_type_type}}(in, out.{{member.ros_field_name}}); {%- if member.has_bits_unused %} out.bits_unused = in.bits_unused; {%- endif %} {%- endfor %} } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type}}_{{ asn1_type_name|replace("-", "_") }}_t& out) { +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t& out) { {%- for member in members %} - memset(&out, 0, sizeof({{ etsi_type}}_{{ asn1_type_name|replace("-", "_") }}_t)); + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t)); - etsi_its_primitives_conversion::toStruct_{{ asn1_type_type }}(in.{{ member.ros_field_name }}, out); + etsi_its_primitives_conversion::toStruct_{{asn1_type_type}}(in.{{member.ros_field_name}}, out); {%- if member.has_bits_unused %} out.bits_unused = in.bits_unused; {%- endif %} diff --git a/utils/codegen/codegen-py/templates/convertSequenceOfType.h.jinja2 b/utils/codegen/codegen-py/templates/convertSequenceOfType.h.jinja2 index 067eff68..00063d9b 100644 --- a/utils/codegen/codegen-py/templates/convertSequenceOfType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertSequenceOfType.h.jinja2 @@ -28,45 +28,45 @@ SOFTWARE. #include -#include -#include +#include +#include {% for member in members -%} -#include -#include +#include +#include {% endfor -%} #ifdef ROS1 {% for member in members -%} -#include +#include {% endfor -%} -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else {% for member in members -%} -#include +#include {% endfor -%} -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { {%- for member in members %} for (int i = 0; i < in.list.count; ++i) { - {{ etsi_type}}_msgs::{{ member.ros_msg_type|replace("[]", "") }} el; - toRos_{{ member.ros_msg_type|replace("[]", "") }}(*(in.list.array[i]), el); + {{etsi_type}}_msgs::{{member.ros_msg_type|replace("[]", "")}} el; + toRos_{{member.ros_msg_type|replace("[]", "")}}(*(in.list.array[i]), el); out.array.push_back(el); } {% endfor -%} } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type }}_{{ asn1_type_name }}_t& out) { - memset(&out, 0, sizeof({{etsi_type}}_{{ asn1_type_name }}_t)); +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name}}_t& out) { + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name}}_t)); {% for member in members %} for (int i = 0; i < in.array.size(); ++i) { - {{etsi_type}}_{{ member.ros_msg_type|replace("[]", "") }}_t* el = ({{etsi_type}}_{{ member.ros_msg_type|replace("[]", "") }}_t*) calloc(1, sizeof({{etsi_type}}_{{ member.ros_msg_type|replace("[]", "") }}_t)); - toStruct_{{ member.ros_msg_type|replace("[]", "") }}(in.array[i], *el); + {{etsi_type}}_{{member.ros_msg_type|replace("[]", "")}}_t* el = ({{etsi_type}}_{{member.ros_msg_type|replace("[]", "")}}_t*) calloc(1, sizeof({{etsi_type}}_{{member.ros_msg_type|replace("[]", "")}}_t)); + toStruct_{{member.ros_msg_type|replace("[]", "")}}(in.array[i], *el); if (asn_sequence_add(&out, el)) throw std::invalid_argument("Failed to add to A_SEQUENCE_OF"); } {%- endfor %} diff --git a/utils/codegen/codegen-py/templates/convertSequenceType.h.jinja2 b/utils/codegen/codegen-py/templates/convertSequenceType.h.jinja2 index 55981ea4..24c3b9c7 100644 --- a/utils/codegen/codegen-py/templates/convertSequenceType.h.jinja2 +++ b/utils/codegen/codegen-py/templates/convertSequenceType.h.jinja2 @@ -26,85 +26,85 @@ SOFTWARE. #pragma once -#include +#include {% for member in unique_sorted_members -%} {% if member.is_primitive -%} -#include -#include +#include +#include {% elif not member.is_choice_var -%} -#include +#include {% endif -%} {% endfor -%} #ifdef ROS1 -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs; #else -#include -namespace {{ etsi_type }}_msgs = etsi_its_{{ etsi_type }}_msgs::msg; +#include +namespace {{etsi_type}}_msgs = etsi_its_{{etsi_type}}_msgs::msg; #endif -namespace etsi_its_{{ etsi_type }}_conversion { +namespace etsi_its_{{etsi_type}}_conversion { -void toRos_{{ ros_msg_type }}(const {{ etsi_type }}_{{ asn1_type_name|replace("-", "_") }}_t& in, {{ etsi_type}}_msgs::{{ ros_msg_type }}& out) { +void toRos_{{ros_msg_type}}(const {{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t& in, {{etsi_type}}_msgs::{{ros_msg_type}}& out) { {%- for member in members -%} {% if member.optional or member.default %} - if (in.{{ member.c_field_name }}) { + if (in.{{member.c_field_name}}) { {%- if member.is_primitive %} - etsi_its_primitives_conversion::toRos_{{ member.asn1_type_name }}(*in.{{ member.c_field_name }}, out.{{ member.ros_field_name }}); + etsi_its_primitives_conversion::toRos_{{member.asn1_type_name}}(*in.{{member.c_field_name}}, out.{{member.ros_field_name}}); {%- else %} - toRos_{{ member.ros_msg_type|replace("[]", "") }}(*in.{{ member.c_field_name }}, out.{{ member.ros_field_name }}); + toRos_{{member.ros_msg_type|replace("[]", "")}}(*in.{{member.c_field_name}}, out.{{member.ros_field_name}}); {%- endif %} {%- if member.optional %} - out.{{ member.ros_field_name }}_is_present = true; + out.{{member.ros_field_name}}_is_present = true; {%- endif %} } {%- elif not member.is_choice_var %} {%- if member.is_primitive %} - etsi_its_primitives_conversion::toRos_{{ member.asn1_type_name }}(in.{{ member.c_field_name }}, out.{{ member.ros_field_name }}); + etsi_its_primitives_conversion::toRos_{{member.asn1_type_name}}(in.{{member.c_field_name}}, out.{{member.ros_field_name}}); {%- elif member.is_choice %} - if (in.{{ member.choice_name }}.present == {{etsi_type}}_{{ asn1_type_name }}__{{ member.choice_name }}_PR::{{etsi_type}}_{{ asn1_type_name }}__{{ member.choice_name }}_PR_{{ member.choice_option_name }}) { - toRos_{{ member.ros_msg_type }}(in.{{ member.choice_name }}.choice.{{ member.choice_option_name }}, out.{{ member.ros_field_name }}); - out.{{ member.choice_var_name }} = {{ etsi_type}}_msgs::{{ asn1_type_name }}::{{ member.constants[0].ros_field_name }}; + if (in.{{member.choice_name}}.present == {{etsi_type}}_{{asn1_type_name}}__{{member.choice_name}}_PR::{{etsi_type}}_{{asn1_type_name}}__{{member.choice_name}}_PR_{{member.choice_option_name}}) { + toRos_{{member.ros_msg_type}}(in.{{member.choice_name}}.choice.{{member.choice_option_name}}, out.{{member.ros_field_name}}); + out.{{member.choice_var_name}} = {{etsi_type}}_msgs::{{asn1_type_name}}::{{member.constants[0].ros_field_name}}; } {%- else %} - toRos_{{ member.ros_msg_type|replace("[]", "") }}(in.{{ member.c_field_name }}, out.{{ member.ros_field_name }}); + toRos_{{member.ros_msg_type|replace("[]", "")}}(in.{{member.c_field_name}}, out.{{member.ros_field_name}}); {%- endif -%} {%- endif -%} {% endfor %} } -void toStruct_{{ ros_msg_type }}(const {{ etsi_type}}_msgs::{{ ros_msg_type }}& in, {{ etsi_type }}_{{ asn1_type_name|replace("-", "_") }}_t& out) { - memset(&out, 0, sizeof({{etsi_type}}_{{ asn1_type_name|replace("-", "_") }}_t)); +void toStruct_{{ros_msg_type}}(const {{etsi_type}}_msgs::{{ros_msg_type}}& in, {{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t& out) { + memset(&out, 0, sizeof({{etsi_type}}_{{asn1_type_name|replace("-", "_")}}_t)); {% for member in members -%} {% if member.optional %} - if (in.{{ member.ros_field_name }}_is_present) { + if (in.{{member.ros_field_name}}_is_present) { {%- if member.is_primitive %} - out.{{member.c_field_name}} = ({{ member.asn1_type_name }}_t*) calloc(1, sizeof({{ member.asn1_type_name }}_t)); - etsi_its_primitives_conversion::toStruct_{{ member.asn1_type_name }}(in.{{ member.ros_field_name }}, *out.{{member.c_field_name}}); + out.{{member.c_field_name}} = ({{member.asn1_type_name}}_t*) calloc(1, sizeof({{member.asn1_type_name}}_t)); + etsi_its_primitives_conversion::toStruct_{{member.asn1_type_name}}(in.{{member.ros_field_name}}, *out.{{member.c_field_name}}); {%- else %} out.{{member.c_field_name}} = ({{etsi_type}}_{{member.asn1_type_name|replace("-", "_")|replace("[]", "")}}_t*) calloc(1, sizeof({{etsi_type}}_{{member.asn1_type_name|replace("-", "_")|replace("[]", "")}}_t)); - toStruct_{{ member.ros_msg_type|replace("[]", "") }}(in.{{ member.ros_field_name }}, *out.{{member.c_field_name}}); + toStruct_{{member.ros_msg_type|replace("[]", "")}}(in.{{member.ros_field_name}}, *out.{{member.c_field_name}}); {%- endif %} } {%- elif member.default %} {%- if member.is_primitive %} - out.{{member.c_field_name}} = ({{ member.asn1_type_name }}_t*) calloc(1, sizeof({{ member.asn1_type_name }}_t)); - etsi_its_primitives_conversion::toStruct_{{ member.asn1_type_name }}(in.{{ member.ros_field_name }}, *out.{{member.c_field_name}}); + out.{{member.c_field_name}} = ({{member.asn1_type_name}}_t*) calloc(1, sizeof({{member.asn1_type_name}}_t)); + etsi_its_primitives_conversion::toStruct_{{member.asn1_type_name}}(in.{{member.ros_field_name}}, *out.{{member.c_field_name}}); {%- else %} - out.{{member.c_field_name}} = ({{etsi_type}}_{{ member.ros_msg_type|replace("[]", "") }}_t*) calloc(1, sizeof({{etsi_type}}_{{ member.ros_msg_type|replace("[]", "") }}_t)); - toStruct_{{ member.ros_msg_type|replace("[]", "") }}(in.{{ member.ros_field_name }}, *out.{{member.c_field_name}}); + out.{{member.c_field_name}} = ({{etsi_type}}_{{member.ros_msg_type|replace("[]", "")}}_t*) calloc(1, sizeof({{etsi_type}}_{{member.ros_msg_type|replace("[]", "")}}_t)); + toStruct_{{member.ros_msg_type|replace("[]", "")}}(in.{{member.ros_field_name}}, *out.{{member.c_field_name}}); {%- endif %} {%- elif not member.is_choice_var %} {%- if member.is_primitive %} - etsi_its_primitives_conversion::toStruct_{{ member.asn1_type_name }}(in.{{ member.ros_field_name }}, out.{{ member.c_field_name }}); + etsi_its_primitives_conversion::toStruct_{{member.asn1_type_name}}(in.{{member.ros_field_name}}, out.{{member.c_field_name}}); {%- elif member.is_choice %} - if (in.{{ member.choice_var_name }} == {{ etsi_type}}_msgs::{{ asn1_type_name }}::{{ member.constants[0].ros_field_name }}) { - toStruct_{{ member.ros_msg_type }}(in.{{ member.ros_field_name }}, out.{{ member.choice_name }}.choice.{{ member.choice_option_name }}); - out.{{ member.choice_name }}.present = {{etsi_type}}_{{ asn1_type_name }}__{{ member.choice_name }}_PR::{{etsi_type}}_{{ asn1_type_name }}__{{ member.choice_name }}_PR_{{ member.choice_option_name }}; + if (in.{{member.choice_var_name}} == {{etsi_type}}_msgs::{{asn1_type_name}}::{{member.constants[0].ros_field_name}}) { + toStruct_{{member.ros_msg_type}}(in.{{member.ros_field_name}}, out.{{member.choice_name}}.choice.{{member.choice_option_name}}); + out.{{member.choice_name}}.present = {{etsi_type}}_{{asn1_type_name}}__{{member.choice_name}}_PR::{{etsi_type}}_{{asn1_type_name}}__{{member.choice_name}}_PR_{{member.choice_option_name}}; } {%- else %} - toStruct_{{ member.ros_msg_type|replace("[]", "") }}(in.{{ member.ros_field_name }}, out.{{ member.c_field_name }}); + toStruct_{{member.ros_msg_type|replace("[]", "")}}(in.{{member.ros_field_name}}, out.{{member.c_field_name}}); {%- endif -%} {%- endif -%} {% endfor %}