From 489575283b37292cfec202fbe2f20b04fd65ba13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Mon, 13 May 2024 14:30:34 +0200 Subject: [PATCH] Fix windows warning in TypeObject generated source code [21006] (#340) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #20424. Fix windows warning in TypeObject generated source code Signed-off-by: Ricardo González Moreno * Refs #20424. Update submodule Signed-off-by: Ricardo González Moreno --------- Signed-off-by: Ricardo González Moreno --- .../idl/templates/XTypesTypeObjectSource.stg | 116 +++++++----------- thirdparty/idl-parser | 2 +- 2 files changed, 48 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg index 7b64d313..7911b5dc 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg @@ -563,30 +563,28 @@ register_sequence_type(sequence, name) ::= << $! TODO(jlbueno): annotated collections generate TypeObject instead of TypeIdentifier pending implementation of annotated collection support !$ $plain_collection_header(type=sequence.contentTypeCode, message="Sequence element", name=name, collection_name=sequence_name(sequence))$ -std::string type_id_kind_$sequence_name(sequence)$("$sequence.typeIdentifier$"); -if (type_id_kind_$sequence_name(sequence)$ == "TI_PLAIN_SEQUENCE_SMALL") { - SBound bound = $if (sequence.unbound)$0$else$static_cast($sequence.evaluatedMaxsize$)$endif$; - PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_$sequence_name(sequence)$, bound, +$if(sequence.isTypeIdentifierKindLarge)$ + LBound bound = $sequence.evaluatedMaxsize$; + PlainSequenceLElemDefn seq_ldefn = TypeObjectUtils::build_plain_sequence_l_elem_defn(header_$sequence_name(sequence)$, bound, eprosima::fastcdr::external(element_identifier_$sequence_name(sequence)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "$sequence_name(sequence)$")) + TypeObjectUtils::build_and_register_l_sequence_type_identifier(seq_ldefn, "$sequence_name(sequence)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$sequence_name(sequence)$ already registered in TypeObjectRegistry for a different type."); } -} -else -{ - LBound bound = $sequence.evaluatedMaxsize$; - PlainSequenceLElemDefn seq_ldefn = TypeObjectUtils::build_plain_sequence_l_elem_defn(header_$sequence_name(sequence)$, bound, +$else$ + SBound bound = $if (sequence.unbound)$0$else$static_cast($sequence.evaluatedMaxsize$)$endif$; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_$sequence_name(sequence)$, bound, eprosima::fastcdr::external(element_identifier_$sequence_name(sequence)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_sequence_type_identifier(seq_ldefn, "$sequence_name(sequence)$")) + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "$sequence_name(sequence)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$sequence_name(sequence)$ already registered in TypeObjectRegistry for a different type."); } +$endif$ } $get_type_identifier_registry(typename=sequence_name(sequence), name=name)$ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) @@ -601,36 +599,34 @@ register_array_type(array, name) ::= << $! TODO(jlbueno): annotated collections generate TypeObject instead of TypeIdentifier pending implementation of annotated collection support !$ $plain_collection_header(type=array.contentTypeCode, message="Array element", name=name, collection_name=array_name(array))$ -std::string type_id_kind_$array_name(array)$("$array.typeIdentifier$"); -if (type_id_kind_$array_name(array)$ == "TI_PLAIN_ARRAY_SMALL") { - SBoundSeq array_bound_seq; +$if(array.isTypeIdentifierKindLarge)$ + LBoundSeq array_bound_seq; $array.evaluatedDimensions: { dimension | - TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast($dimension$)); + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast($dimension$)); }; separator="\n"$ - PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_$array_name(array)$, array_bound_seq, + PlainArrayLElemDefn array_ldefn = TypeObjectUtils::build_plain_array_l_elem_defn(header_$array_name(array)$, array_bound_seq, eprosima::fastcdr::external(element_identifier_$array_name(array)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "$array_name(array)$")) + TypeObjectUtils::build_and_register_l_array_type_identifier(array_ldefn, "$array_name(array)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$array_name(array)$ already registered in TypeObjectRegistry for a different type."); } -} -else -{ - LBoundSeq array_bound_seq; +$else$ + SBoundSeq array_bound_seq; $array.evaluatedDimensions: { dimension | - TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast($dimension$)); + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast($dimension$)); }; separator="\n"$ - PlainArrayLElemDefn array_ldefn = TypeObjectUtils::build_plain_array_l_elem_defn(header_$array_name(array)$, array_bound_seq, + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_$array_name(array)$, array_bound_seq, eprosima::fastcdr::external(element_identifier_$array_name(array)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_array_type_identifier(array_ldefn, "$array_name(array)$")) + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "$array_name(array)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$array_name(array)$ already registered in TypeObjectRegistry for a different type."); } +$endif$ } $get_type_identifier_registry(typename=array_name(array), name=name)$ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) @@ -693,32 +689,30 @@ $! TODO(jlbueno) Annotated collections not yet supported !$ CollectionElementFlag element_flags_$map_name(map)$ = 0; CollectionElementFlag key_flags_$map_name(map)$ = 0; PlainCollectionHeader header_$map_name(map)$ = TypeObjectUtils::build_plain_collection_header(equiv_kind_$map_name(map)$, element_flags_$map_name(map)$); -std::string type_id_kind_$map_name(map)$("$map.typeIdentifier$"); -if (type_id_kind_$map_name(map)$ == "TI_PLAIN_MAP_SMALL") { - SBound bound = $if (map.unbound)$0$else$static_cast($map.evaluatedMaxsize$)$endif$; - PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_$map_name(map)$, bound, +$if(map.isTypeIdentifierKindLarge)$ + LBound bound = $map.evaluatedMaxsize$; + PlainMapLTypeDefn map_ldefn = TypeObjectUtils::build_plain_map_l_type_defn(header_$map_name(map)$, bound, eprosima::fastcdr::external(element_identifier_$map_name(map)$), key_flags_$map_name(map)$, eprosima::fastcdr::external(key_identifier_$map_name(map)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "$map_name(map)$")) + TypeObjectUtils::build_and_register_l_map_type_identifier(map_ldefn, "$map_name(map)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$map_name(map)$ already registered in TypeObjectRegistry for a different type."); } -} -else -{ - LBound bound = $map.evaluatedMaxsize$; - PlainMapLTypeDefn map_ldefn = TypeObjectUtils::build_plain_map_l_type_defn(header_$map_name(map)$, bound, +$else$ + SBound bound = $if (map.unbound)$0$else$static_cast($map.evaluatedMaxsize$)$endif$; + PlainMapSTypeDefn map_sdefn = TypeObjectUtils::build_plain_map_s_type_defn(header_$map_name(map)$, bound, eprosima::fastcdr::external(element_identifier_$map_name(map)$), key_flags_$map_name(map)$, eprosima::fastcdr::external(key_identifier_$map_name(map)$)); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_map_type_identifier(map_ldefn, "$map_name(map)$")) + TypeObjectUtils::build_and_register_s_map_type_identifier(map_sdefn, "$map_name(map)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$map_name(map)$ already registered in TypeObjectRegistry for a different type."); } +$endif$ } $get_type_identifier_registry(typename=map_name(map), name=name)$ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) @@ -800,36 +794,28 @@ bitflag_member(bitflag, parent, name) ::= << >> register_wstring_type(wstring, name) ::= << -std::string type_id_kind_$wstring_name(wstring)$("$wstring.typeIdentifier$"); -if (type_id_kind_$wstring_name(wstring)$ == "TI_STRING16_SMALL") { - SBound bound = $if (!wstring.isBounded)$0$else$static_cast($wstring.evaluatedMaxsize$)$endif$; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); +$if(wstring.isTypeIdentifierKindLarge)$ + LBound bound = $wstring.evaluatedMaxsize$; + StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn, "$wstring_name(wstring)$", true)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$wstring_name(wstring)$ already registered in TypeObjectRegistry for a different type."); } -} -else if (type_id_kind_$wstring_name(wstring)$ == "TI_STRING16_LARGE") -{ - LBound bound = $wstring.evaluatedMaxsize$; - StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound); +$else$ + SBound bound = $if (!wstring.isBounded)$0$else$static_cast($wstring.evaluatedMaxsize$)$endif$; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn, + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, "$wstring_name(wstring)$", true)) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$wstring_name(wstring)$ already registered in TypeObjectRegistry for a different type."); } -} -else -{ - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "$wstring_name(wstring)$: Unknown WString kind."); - return; +$endif$ } $get_type_identifier_registry(typename=wstring_name(wstring), name=name)$ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) @@ -841,36 +827,28 @@ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) >> register_string_type(string, name) ::= << -std::string type_id_kind_$string_name(string)$("$string.typeIdentifier$"); -if (type_id_kind_$string_name(string)$ == "TI_STRING8_SMALL") { - SBound bound = $if (!string.isBounded)$0$else$static_cast($string.evaluatedMaxsize$)$endif$; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); +$if(string.isTypeIdentifierKindLarge)$ + LBound bound = $string.evaluatedMaxsize$; + StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn, "$string_name(string)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$string_name(string)$ already registered in TypeObjectRegistry for a different type."); } -} -else if (type_id_kind_$string_name(string)$ == "TI_STRING8_LARGE") -{ - LBound bound = $string.evaluatedMaxsize$; - StringLTypeDefn string_ldefn = TypeObjectUtils::build_string_l_type_defn(bound); +$else$ + SBound bound = $if (!string.isBounded)$0$else$static_cast($string.evaluatedMaxsize$)$endif$; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_l_string_type_identifier(string_ldefn, + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, "$string_name(string)$")) { EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "$string_name(string)$ already registered in TypeObjectRegistry for a different type."); } -} -else -{ - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "$string_name(string)$: Unknown String kind."); - return; +$endif$ } $get_type_identifier_registry(typename=string_name(string), name=name)$ if (return_code_$name$ != eprosima::fastdds::dds::RETCODE_OK) diff --git a/thirdparty/idl-parser b/thirdparty/idl-parser index 70f6a4d5..22bae24a 160000 --- a/thirdparty/idl-parser +++ b/thirdparty/idl-parser @@ -1 +1 @@ -Subproject commit 70f6a4d5b9d57ca73f9688bea1fb5cdaea7483e6 +Subproject commit 22bae24abbd5d63f22a8ffe26e21f872b655051c