From f24cb50498b295e312b04f1beafb7cf932cb5df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Gonz=C3=A1lez?= Date: Thu, 26 Sep 2024 12:56:33 +0200 Subject: [PATCH] [21380] Support setting value to an enumeration literal using annotation @value (#379) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refs #21379. Support setting values Signed-off-by: Ricardo González Moreno * Refs #21379. Add test Signed-off-by: Ricardo González Moreno * Refs #21379. Fix error Signed-off-by: Ricardo González Moreno * Refs #21379. Fix error on tests Signed-off-by: Ricardo González Moreno * Refs #21379. Update submodule Signed-off-by: Ricardo González Moreno --------- Signed-off-by: Ricardo González Moreno --- .../java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg | 2 +- .../fastdds/idl/templates/TypeObjectTestingTestSource.stg | 2 +- .../eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg | 2 +- thirdparty/dds-types-test | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg index dca90bdd..e6f62638 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -558,7 +558,7 @@ enum_type(ctx, parent, enum) ::= << */ enum class $enum.name$ : int32_t { - $enum.members:{ member | $member.name$}; separator=",\n"$ + $enum.members:{ member | $member.name$$if(member.annotationValue)$ = $member.annotationValueValue$$endif$}; separator=",\n"$ }; >> diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg index ea041708..7cd15a01 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg @@ -245,7 +245,7 @@ TEST(TypeObjectTests, TestEnumTypeObject_$enum.name$) TypeIdentifierPair type_ids; // Register specific enum TypeObject - $if(enum.scope)$::$endif$$enum.scope$::register_$enum.name$_type_identifier(type_ids); + $if(!enum.scope.empty)$::$endif$$enum.scope$::register_$enum.name$_type_identifier(type_ids); $check_type_identifier_consistency(result="type_ids")$ $check_direct_hash_type_identifier(typeid="type_ids")$ 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 bdc51e49..83627ebe 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/XTypesTypeObjectSource.stg @@ -725,7 +725,7 @@ $endif$ enum_literal(literal, parent, name) ::= << { EnumeratedLiteralFlag flags_$literal.name$ = TypeObjectUtils::build_enumerated_literal_flag($literal.annotationDefaultLiteral$); - CommonEnumeratedLiteral common_$literal.name$ = TypeObjectUtils::build_common_enumerated_literal($literal.index$, flags_$literal.name$); + CommonEnumeratedLiteral common_$literal.name$ = TypeObjectUtils::build_common_enumerated_literal($if(literal.annotationValue)$$literal.annotationValueValue$$else$$literal.index$$endif$, flags_$literal.name$); $empty_ann_builtin_complete_member_detail(member=literal, parent=parent, message=[parent.scopedname, " Enumerated ", literal.name, " literal: only @default_literal and @value builtin annotations apply to literals"], name=name)$ CompleteEnumeratedLiteral literal_$literal.name$ = TypeObjectUtils::build_complete_enumerated_literal(common_$literal.name$, detail_$literal.name$); TypeObjectUtils::add_complete_enumerated_literal(literal_seq_$parent.name$, literal_$literal.name$); diff --git a/thirdparty/dds-types-test b/thirdparty/dds-types-test index 046b97d7..c856b247 160000 --- a/thirdparty/dds-types-test +++ b/thirdparty/dds-types-test @@ -1 +1 @@ -Subproject commit 046b97d7c770a18d8011472774946fadea69bdef +Subproject commit c856b2479b7f15c242b7dc1dd382143c0498da07