diff --git a/build.gradle b/build.gradle index c224d3f0..b2246c52 100644 --- a/build.gradle +++ b/build.gradle @@ -91,7 +91,7 @@ repositories { } dependencies { - implementation files('thirdparty/idl-parser/build/libs/idlparser-1.6.0.jar') + implementation files('thirdparty/idl-parser/build/libs/idlparser-1.7.1.jar') testImplementation('org.junit.jupiter:junit-jupiter-api:5.5.2') testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.5.2') } 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 abbaf1ab..82f0c5bc 100644 --- a/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg +++ b/src/main/java/com/eprosima/fastcdr/idl/templates/TypesHeader.stg @@ -415,13 +415,14 @@ enum $enum.name$ : uint32_t bitmask_type(ctx, parent, bitmask) ::= << /*! - * @brief This class represents the bitmask $bitmask.name$ defined by the user in the IDL file. + * @brief This enumeration represents the $bitmask.name$ bitflags defined by the user in the IDL file. * @ingroup $ctx.trimfilename$ */ -enum $bitmask.name$$bitmask.boundType$ +enum $bitmask.name$Bits$bitmask.boundType$ { $bitmask.members:{ member | $member.name$ = 0x01ull << $member.position$}; separator=",\n"$ }; +typedef $bitmask.castingType$ $bitmask.name$; >> fwd_decl(ctx, parent, type) ::= << @@ -626,6 +627,8 @@ $if(member.annotationDefault)$ $elseif(!member.annotationOptional)$ $if(member.typecode.initialValue)$ {$member.typecode.initialValue$} +$elseif(member.typecode.isBitmaskType)$ + {0} $endif$ $endif$ $endif$ diff --git a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationHeader.stg b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationHeader.stg index 774110f7..0db7af6b 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationHeader.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationHeader.stg @@ -70,7 +70,18 @@ enum_type(ctx, parent, enum) ::= <<>> typedef_decl(ctx, parent, typedefs) ::= <<>> -bitmask_type(ctx, parent, bitmask) ::= <<>> +bitmask_type(ctx, parent, bitmask) ::= << +void print$bitmask.name$( + $bitmask.name$* topic); + +void initialize$bitmask.name$( + $bitmask.name$* topic); + +int compare$bitmask.name$( + $bitmask.name$* a, + $bitmask.name$* b); + +>> bitset_type(ctx, parent, bitset) ::= << void print$bitset.name$( 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 77bae39b..84e227a6 100644 --- a/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg +++ b/src/main/java/com/eprosima/fastdds/idl/templates/SerializationSource.stg @@ -148,7 +148,33 @@ int $if(union.hasScope)$$union.scope$::$endif$compare$union.name$( enum_type(ctx, parent, enum) ::= <<>> -bitmask_type(ctx, parent, bitmask) ::= <<>> +bitmask_type(ctx, parent, bitmask) ::= << +void $if(bitmask.hasScope)$$bitmask.scope$::$endif$print$bitmask.name$( + $bitmask.name$* topic) +{ + printf("$bitmask.scopedname$: { \n"); + $bitmask.members:{ member | printf("$member.name$: %s\n", ((*topic & $bitmask.name$Bits::$member.name$) == $bitmask.name$Bits::$member.name$) ? "true" : "false");}; separator="\n"$ +} + +void $if(bitmask.hasScope)$$bitmask.scope$::$endif$initialize$bitmask.name$( + $bitmask.name$* topic) +{ + $bitmask.members:{ member | + if (rand() % 2 == 1) + { + *topic |= $bitmask.name$Bits::$member.name$; + \} + }; separator="\n"$ +} + +int $if(bitmask.hasScope)$$bitmask.scope$::$endif$compare$bitmask.name$( + $bitmask.name$* topic_a, + $bitmask.name$* topic_b) +{ + return *topic_a == *topic_b; +} + +>> typedef_decl(ctx, parent, typedefs) ::= <<>> diff --git a/thirdparty/idl-parser b/thirdparty/idl-parser index e88ae80b..0dec761f 160000 --- a/thirdparty/idl-parser +++ b/thirdparty/idl-parser @@ -1 +1 @@ -Subproject commit e88ae80bf1ad5f962731110455d211823e8eb89c +Subproject commit 0dec761fad8e25c48d4a865d8fcb9b9f9429f94e