Skip to content

Commit

Permalink
Refs #19236: fix bitmask serialization code
Browse files Browse the repository at this point in the history
Signed-off-by: JLBuenoLopez-eProsima <[email protected]>
  • Loading branch information
JLBuenoLopez committed Jul 26, 2023
1 parent 6035bc9 commit 8e3b418
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,29 @@ 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.name$: { \n");
$bitmask.members:{printf("$it.name$: %s\n", topic->$it.name$() ? "true" : "false");}; separator="\n"$
}

void $if(bitmask.hasScope)$$bitmask.scope$::$endif$initialize$bitmask.name$(
$bitmask.name$* topic)
{
$bitmask.members:{topic->$it.name$(static_cast<bool>(rand()%2==1));}; separator="\n"$
}

int $if(bitmask.hasScope)$$bitmask.scope$::$endif$compare$bitmask.name$(
$bitmask.name$* topic_a,
$bitmask.name$* topic_b)
{
$bitmask.members:{if(topic_a->$it.name$() != topic_b->$it.name$()) return 0;$endif$}; separator="\n"$
return 1;
}

>>

typedef_decl(ctx, parent, typedefs) ::= <<>>

Expand Down

0 comments on commit 8e3b418

Please sign in to comment.