Skip to content

Commit

Permalink
Refs #13333: Modified compilation guard generation. Changed equality …
Browse files Browse the repository at this point in the history
…and non-equality operator generation to const (#82)

Signed-off-by: Javier Santiago <[email protected]>
  • Loading branch information
jsan-rt authored Dec 23, 2021
1 parent 4276ff4 commit 2bbb292
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ group TypeObjectHeader;
main(ctx, definitions) ::= <<
$fileHeader(file=[ctx.filename, "TypeObject.h"], description=["This header file contains the declaration of the described types in the IDL file."])$

#ifndef _$ctx.headerGuardName$_TYPE_OBJECT_H_
#define _$ctx.headerGuardName$_TYPE_OBJECT_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_TYPE_OBJECT_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_TYPE_OBJECT_H_

$ctx.directIncludeDependencies : {include | #include "$include$TypeObject.h"}; separator="\n"$

Expand Down Expand Up @@ -55,7 +55,7 @@ eProsima_user_DllExport void register$ctx.filename$Types();

$definitions; separator="\n"$

#endif // _$ctx.headerGuardName$_TYPE_OBJECT_H_
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_TYPE_OBJECT_H_
>>

typedef_decl(ctx, parent, typedefs) ::= <<
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ group TypesHeader;
main(ctx, definitions) ::= <<
$fileHeader(file=[ctx.filename, ".h"], description=["This header file contains the declaration of the described types in the IDL file."])$

#ifndef _$ctx.headerGuardName$_H_
#define _$ctx.headerGuardName$_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_

$if(ctx.printexception)$
#include <$ctx.product$/exceptions/UserException.h>
Expand Down Expand Up @@ -84,7 +84,7 @@ $endif$

$definitions; separator="\n"$

#endif // _$ctx.headerGuardName$_H_
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_H_
>>

// TODO name -> module
Expand Down Expand Up @@ -267,14 +267,14 @@ public:
* @param x $struct.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator ==(
const $struct.name$& x);
const $struct.name$& x) const;

/*!
* @brief Comparison operator.
* @param x $struct.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator !=(
const $struct.name$& x);
const $struct.name$& x) const;

$struct.members:{$public_member_declaration(it)$}; separator="\n"$

Expand Down Expand Up @@ -342,14 +342,14 @@ public:
* @param x $union.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator ==(
const $union.name$& x);
const $union.name$& x) const;

/*!
* @brief Comparison operator.
* @param x $union.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator !=(
const $union.name$& x);
const $union.name$& x) const;

/*!
* @brief This function sets the discriminator value.
Expand Down Expand Up @@ -439,14 +439,14 @@ public:
* @param x $bitset.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator ==(
const $bitset.name$& x);
const $bitset.name$& x) const;

/*!
* @brief Comparison operator.
* @param x $bitset.scopedname$ object to compare.
*/
eProsima_user_DllExport bool operator !=(
const $bitset.name$& x);
const $bitset.name$& x) const;

$bitset.bitfields:{$public_bitfield_declaration(it)$}; separator="\n"$

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/eprosima/fastcdr/idl/templates/TypesSource.stg
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ $struct.scopedname$& $struct.scopedname$::operator =(
}

bool $struct.scopedname$::operator ==(
const $struct.name$& x)
const $struct.name$& x) const
{
$if(struct.inheritances)$ $struct.inheritances : { if ($it.scopedname$::operator !=(x)) return false;}; separator="\n"$ $endif$

return ($struct.members:{m_$it.name$ == x.m_$it.name$}; separator=" && "$);
}

bool $struct.scopedname$::operator !=(
const $struct.name$& x)
const $struct.name$& x) const
{
return !(*this == x);
}
Expand Down Expand Up @@ -395,15 +395,15 @@ $bitset.scopedname$& $bitset.scopedname$::operator =(
}

bool $bitset.scopedname$::operator ==(
const $bitset.name$& x)
const $bitset.name$& x) const
{
$if(bitset.parents)$ $bitset.parents : { if ($it.scopedname$::operator !=(x)) return false;}; separator="\n"$ $endif$

return m_bitset == x.m_bitset;
}

bool $bitset.scopedname$::operator !=(
const $bitset.name$& x)
const $bitset.name$& x) const
{
return !(*this == x);
}
Expand Down Expand Up @@ -586,7 +586,7 @@ $union.scopedname$& $union.scopedname$::operator =(
}

bool $union.scopedname$::operator ==(
const $union.name$& x)
const $union.name$& x) const
{
if (m__d != x.m__d)
{
Expand All @@ -602,7 +602,7 @@ bool $union.scopedname$::operator ==(
}

bool $union.scopedname$::operator !=(
const $union.name$& x)
const $union.name$& x) const
{
return !(*this == x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, "PubSubTypes.h"], description=["This header file contains the declaration of the serialization functions."])$


#ifndef _$ctx.headerGuardName$_PUBSUBTYPES_H_
#define _$ctx.headerGuardName$_PUBSUBTYPES_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBSUBTYPES_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBSUBTYPES_H_

#include <fastdds/dds/topic/TopicDataType.hpp>
#include <fastrtps/utils/md5.h>

#include "$ctx.filename$.h"

#if !defined(GEN_API_VER) || (GEN_API_VER != 1)
#error Generated $ctx.filename$ is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
#error \
Generated $ctx.filename$ is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
#endif // GEN_API_VER

$definitions; separator="\n"$

#endif // _$ctx.headerGuardName$_PUBSUBTYPES_H_
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBSUBTYPES_H_
>>

// TODO name -> module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, "Publisher.h"], description=["This header file contains the declaration of the publisher functions."])$


#ifndef _$ctx.headerGuardName$_PUBLISHER_H_
#define _$ctx.headerGuardName$_PUBLISHER_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBLISHER_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBLISHER_H_

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/publisher/DataWriter.hpp>
Expand Down Expand Up @@ -64,7 +64,7 @@ private:
listener_;
};

#endif // _$ctx.headerGuardName$_PUBLISHER_H_
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_PUBLISHER_H_
>>

module(ctx, parent, module, definition_list) ::= <<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, "Subscriber.h"], description=["This header file contains the declaration of the subscriber functions."])$


#ifndef _$ctx.headerGuardName$_SUBSCRIBER_H_
#define _$ctx.headerGuardName$_SUBSCRIBER_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_SUBSCRIBER_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_SUBSCRIBER_H_

#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/subscriber/DataReader.hpp>
Expand Down Expand Up @@ -67,7 +67,7 @@ private:
listener_;
};

#endif // _$ctx.headerGuardName$_SUBSCRIBER_H_
#endif // _FAST_DDS_GENERATED_$ctx.headerGuardName$_SUBSCRIBER_H_
>>

module(ctx, parent, module, definition_list) ::= <<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ group ProtocolHeader;
main(ctx, definitions) ::= <<
$fileHeader(ctx=ctx, file=[ctx.filename, "Serialization.h"], description=["This file contains serialization definitions."])$

#ifndef _$ctx.headerGuardName$_SERIALIZATION_H_
#define _$ctx.headerGuardName$_SERIALIZATION_H_
#ifndef _FAST_DDS_GENERATED_$ctx.headerGuardName$_SERIALIZATION_H_
#define _FAST_DDS_GENERATED_$ctx.headerGuardName$_SERIALIZATION_H_

#include "$ctx.filename$.h"

$definitions; separator="\n"$

#endif //_$ctx.headerGuardName$_SERIALIZATION_H_
#endif //_FAST_DDS_GENERATED_$ctx.headerGuardName$_SERIALIZATION_H_
>>

struct_type(ctx, parent, struct) ::= <<
Expand Down

0 comments on commit 2bbb292

Please sign in to comment.