From 944e8dd3cc50dda8becbe7c00ed9ca35a4efdf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Bueno=20L=C3=B3pez?= <69244257+JLBuenoLopez-eProsima@users.noreply.github.com> Date: Tue, 21 Nov 2023 11:27:26 +0100 Subject: [PATCH] Update IDL parser submodule to support new Union discriminator as a Member (#262) * Refs #19932: update IDL parser submodule Signed-off-by: JLBuenoLopez-eProsima * Refs #19932: changes required from review suggestion in IDL Parser Signed-off-by: JLBuenoLopez-eProsima * Refs #19932: update submodule Signed-off-by: JLBuenoLopez-eProsima --------- Signed-off-by: JLBuenoLopez-eProsima --- .../eprosima/fastcdr/idl/templates/JavaType.stg | 6 +++--- .../fastcdr/idl/templates/TypesHeader.stg | 8 ++++---- .../fastcdr/idl/templates/TypesHeaderv1.stg | 8 ++++---- .../fastcdr/idl/templates/TypesSource.stg | 6 +++--- .../fastcdr/idl/templates/TypesSourcev1.stg | 16 ++++++++-------- .../idl/parser/typecode/UnionTypeCode.java | 2 +- .../idl/templates/SerializationSource.stg | 12 ++++++------ .../fastdds/idl/templates/TypeObjectSource.stg | 12 ++++++------ 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/JavaType.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/JavaType.stg index bcd2e107..f9912de9 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/JavaType.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/JavaType.stg @@ -109,7 +109,7 @@ public class $union.name$ }; separator="\n"$ } - public $union.discriminator.javaTypename$ getDiscriminator() + public $union.discriminator.typecode.javaTypename$ getDiscriminator() { return d__; } @@ -127,7 +127,7 @@ public class $union.name$ $endif$ } - public void set$member.javaName$($union.discriminator.javaTypename$ discriminator, $member.typecode.javaTypename$ $member.name$) + public void set$member.javaName$($union.discriminator.typecode.javaTypename$ discriminator, $member.typecode.javaTypename$ $member.name$) throws Exception { $if(member.default)$ @@ -188,7 +188,7 @@ public class $union.name$ return false; } - $union.discriminator.javaTypename$ d__; + $union.discriminator.typecode.javaTypename$ d__; $union.members : { member |private $member.typecode.javaTypename$ $member.name$_; }; separator="\n"$ 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 b6e244d4..28b8bfd1 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -301,26 +301,26 @@ public: * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. */ eProsima_user_DllExport void _d( - $union.discriminator.cppTypename$ __d); + $union.discriminator.typecode.cppTypename$ __d); /*! * @brief This function returns the value of the discriminator. * @return Value of the discriminator */ - eProsima_user_DllExport $union.discriminator.cppTypename$ _d() const; + eProsima_user_DllExport $union.discriminator.typecode.cppTypename$ _d() const; /*! * @brief This function returns a reference to the discriminator. * @return Reference to the discriminator. */ - eProsima_user_DllExport $union.discriminator.cppTypename$& _d(); + eProsima_user_DllExport $union.discriminator.typecode.cppTypename$& _d(); $union.members:{ member | $public_unionmember_declaration(member)$}; separator="\n"$ $serialization_functions(union)$ $extensions : {extension | $extension$}; separator="\n"$ private: - $union.discriminator.cppTypename$ m__d; + $union.discriminator.typecode.cppTypename$ m__d; $union.members:{ member | $private_member_declaration(member=member)$}; separator="\n"$ }; diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg index 9b38df38..4e3f3c8d 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeaderv1.stg @@ -410,19 +410,19 @@ public: * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. */ eProsima_user_DllExport void _d( - $union.discriminator.cppTypename$ __d); + $union.discriminator.typecode.cppTypename$ __d); /*! * @brief This function returns the value of the discriminator. * @return Value of the discriminator */ - eProsima_user_DllExport $union.discriminator.cppTypename$ _d() const; + eProsima_user_DllExport $union.discriminator.typecode.cppTypename$ _d() const; /*! * @brief This function returns a reference to the discriminator. * @return Reference to the discriminator. */ - eProsima_user_DllExport $union.discriminator.cppTypename$& _d(); + eProsima_user_DllExport $union.discriminator.typecode.cppTypename$& _d(); $union.members:{ member | $public_unionmember_declaration(member)$}; separator="\n"$ @@ -434,7 +434,7 @@ public: private: - $private_declaration(typecode=union.discriminator, name="_d")$ + $private_declaration(typecode=union.discriminator.typecode, name="_d")$ $union.members:{ member | $private_member_declaration(member=member)$}; separator="\n"$ }; diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg index a17daaff..17ce20c5 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg @@ -470,7 +470,7 @@ bool $union.name$::operator !=( } void $union.name$::_d( - $union.discriminator.cppTypename$ __d) + $union.discriminator.typecode.cppTypename$ __d) { bool b = false; @@ -491,12 +491,12 @@ void $union.name$::_d( m__d = __d; } -$union.discriminator.cppTypename$ $union.name$::_d() const +$union.discriminator.typecode.cppTypename$ $union.name$::_d() const { return m__d; } -$union.discriminator.cppTypename$& $union.name$::_d() +$union.discriminator.typecode.cppTypename$& $union.name$::_d() { return m__d; } diff --git a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg index 59f2058b..7b060006 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesSourcev1.stg @@ -766,7 +766,7 @@ bool $union.name$::operator !=( } void $union.name$::_d( - $union.discriminator.cppTypename$ __d) + $union.discriminator.typecode.cppTypename$ __d) { bool b = false; @@ -783,12 +783,12 @@ void $union.name$::_d( m__d = __d; } -$union.discriminator.cppTypename$ $union.name$::_d() const +$union.discriminator.typecode.cppTypename$ $union.name$::_d() const { return m__d; } -$union.discriminator.cppTypename$& $union.name$::_d() +$union.discriminator.typecode.cppTypename$& $union.name$::_d() { return m__d; } @@ -804,7 +804,7 @@ size_t $union.name$::getCdrSerializedSize( (void)data; size_t initial_alignment = current_alignment; - $serialized_size_type(ctx=ctx, typecode=union.discriminator, var="current_alignment")$ + $serialized_size_type(ctx=ctx, typecode=union.discriminator.typecode, var="current_alignment")$ switch(data.m__d) { @@ -821,7 +821,7 @@ $if(ctx.cdr)$ void $union.name$::serialize( eprosima::fastcdr::Cdr& scdr) const { - scdr << $serializeCasting(typecode=union.discriminator)$m__d; + scdr << $serializeCasting(typecode=union.discriminator.typecode)$m__d; switch(m__d) { @@ -833,7 +833,7 @@ void $union.name$::serialize( void $union.name$::deserialize( eprosima::fastcdr::Cdr& dcdr) { - $deserializePossibleEnum(typecode=union.discriminator, name="m__d", preffix="")$ + $deserializePossibleEnum(typecode=union.discriminator.typecode, name="m__d", preffix="")$ switch(m__d) { @@ -848,7 +848,7 @@ $if(ctx.fastcdr)$ void $union.name$::serialize( eprosima::fastcdr::FastCdr& scdr) const { - scdr << $serializeCasting(typecode=union.discriminator)$m__d; + scdr << $serializeCasting(typecode=union.discriminator.typecode)$m__d; switch(m__d) { @@ -860,7 +860,7 @@ void $union.name$::serialize( void $union.name$::deserialize( eprosima::fastcdr::FastCdr& dcdr) { - $deserializePossibleEnum(typecode=union.discriminator, name="m__d", preffix="")$ + $deserializePossibleEnum(typecode=union.discriminator.typecode, name="m__d", preffix="")$ switch(m__d) { diff --git a/src/main/java/com/eprosima/fastdds/idl/parser/typecode/UnionTypeCode.java b/src/main/java/com/eprosima/fastdds/idl/parser/typecode/UnionTypeCode.java index 1e9dc57d..bc8e467e 100644 --- a/src/main/java/com/eprosima/fastdds/idl/parser/typecode/UnionTypeCode.java +++ b/src/main/java/com/eprosima/fastdds/idl/parser/typecode/UnionTypeCode.java @@ -49,7 +49,7 @@ public long maxSerializedSize( detect_recursive_ = true; current_alignment = MemberedTypeCode.xcdr_extra_header_serialized_size(current_alignment, union_ext_kind); - current_alignment += ((TypeCode)getDiscriminator()).maxSerializedSize(current_alignment); + current_alignment += ((TypeCode)getDiscriminator().getTypecode()).maxSerializedSize(current_alignment); for (Member member : getMembers()) { diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg index 522a8346..d10978fb 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg @@ -163,12 +163,12 @@ void $if(union.hasScope)$$union.scope$::$endif$print$union.name$( printf("$union.name$: { \n"); $if(union.members)$ $if(last(union.members).labels)$ - topic->_d(static_cast<$union.discriminator.cppTypename$>($first(last(union.members).labels)$)); + topic->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(last(union.members).labels)$)); $member_print(ctx=ctx, typecode=last(union.members).typecode, name=last(union.members).name, originName=last(union.members).name, optional=last(union.members).annotationOptional, external=last(union.members).annotationExternal)$ $else$ - topic->_d(static_cast<$union.discriminator.cppTypename$>($first(first(union.members).labels)$)); + topic->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(first(union.members).labels)$)); $member_print(ctx=ctx, typecode=first(union.members).typecode, name=first(union.members).name, originName=first(union.members).name, optional=first(union.members).annotationOptional, external=first(union.members).annotationExternal)$ @@ -199,14 +199,14 @@ int $if(union.hasScope)$$union.scope$::$endif$compare$union.name$( { $if(union.members)$ $if(last(union.members).labels)$ - topic_a->_d(static_cast<$union.discriminator.cppTypename$>($first(last(union.members).labels)$)); - topic_b->_d(static_cast<$union.discriminator.cppTypename$>($first(last(union.members).labels)$)); + topic_a->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(last(union.members).labels)$)); + topic_b->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(last(union.members).labels)$)); $member_comparision(ctx=ctx, typecode=last(union.members).typecode, name=last(union.members).name, originName=last(union.members).name, optional=last(union.members).annotationOptional, external=last(union.members).annotationExternal)$ $else$ - topic_a->_d(static_cast<$union.discriminator.cppTypename$>($first(first(union.members).labels)$)); - topic_b->_d(static_cast<$union.discriminator.cppTypename$>($first(first(union.members).labels)$)); + topic_a->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(first(union.members).labels)$)); + topic_b->_d(static_cast<$union.discriminator.typecode.cppTypename$>($first(first(union.members).labels)$)); $member_comparision(ctx=ctx, typecode=first(union.members).typecode, name=first(union.members).name, originName=first(union.members).name, optional=first(union.members).annotationOptional, external=first(union.members).annotationExternal)$ diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg index cdd48991..9bce2b32 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/TypeObjectSource.stg @@ -1069,10 +1069,10 @@ const TypeObject* GetMinimal$union.name$Object() type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().type_id(*$get_type_identifier(ctx=ctx, type=union.discriminator, ek="false")$); + type_object->minimal().union_type().discriminator().common().type_id(*$get_type_identifier(ctx=ctx, type=union.discriminator.typecode, ek="false")$); MemberId memberId = 0; - $union.members:{ member | $minimal_union_member_object_type(ctx=ctx, object=member, discriminator=union.discriminator)$}; separator="\n"$ + $union.members:{ member | $minimal_union_member_object_type(ctx=ctx, object=member, discriminator=union.discriminator.typecode)$}; separator="\n"$ // Header //type_object->minimal().union_type().header().detail()... // Empty @@ -1137,10 +1137,10 @@ const TypeObject* GetComplete$union.name$Object() type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().type_id(*$get_type_identifier(ctx=ctx, type=union.discriminator, ek="true")$); + type_object->complete().union_type().discriminator().common().type_id(*$get_type_identifier(ctx=ctx, type=union.discriminator.typecode, ek="true")$); - $if(union.discriminator.annotationList)$ - $union.discriminator.annotationList:{ ann | + $if(union.discriminator.typecode.annotationList)$ + $union.discriminator.typecode.annotationList:{ ann | { AppliedAnnotation ann; //ann.annotation_typeid(Get$ann.name$Identifier(true)); @@ -1168,7 +1168,7 @@ const TypeObject* GetComplete$union.name$Object() $endif$ MemberId memberId = 0; - $union.members:{ member | $complete_union_member_object_type(ctx=ctx, object=member, discriminator=union.discriminator)$}; separator="\n"$ + $union.members:{ member | $complete_union_member_object_type(ctx=ctx, object=member, discriminator=union.discriminator.typecode)$}; separator="\n"$ // Header type_object->complete().union_type().header().detail().type_name("$union.name$");