Skip to content

Commit

Permalink
Update IDL parser submodule to support new Union discriminator as a M…
Browse files Browse the repository at this point in the history
…ember (#262)

* Refs #19932: update IDL parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19932: changes required from review suggestion in IDL Parser

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19932: update submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
  • Loading branch information
JLBuenoLopez authored and richiware committed Mar 13, 2024
1 parent 6980bbe commit 944e8dd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/eprosima/fastcdr/idl/templates/JavaType.stg
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class $union.name$
}; separator="\n"$
}

public $union.discriminator.javaTypename$ getDiscriminator()
public $union.discriminator.typecode.javaTypename$ getDiscriminator()
{
return d__;
}
Expand All @@ -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)$
Expand Down Expand Up @@ -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"$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"$
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"$

Expand All @@ -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"$
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ bool $union.name$::operator !=(
}

void $union.name$::_d(
$union.discriminator.cppTypename$ __d)
$union.discriminator.typecode.cppTypename$ __d)
{
bool b = false;

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ bool $union.name$::operator !=(
}

void $union.name$::_d(
$union.discriminator.cppTypename$ __d)
$union.discriminator.typecode.cppTypename$ __d)
{
bool b = false;

Expand All @@ -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;
}
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)$
Expand Down Expand Up @@ -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)$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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$");
Expand Down

0 comments on commit 944e8dd

Please sign in to comment.