-
Notifications
You must be signed in to change notification settings - Fork 439
Description
Test Report: C++ and C work differently with XType @appended Enumeration Value
Objective
Test OMG DDS X-Types 1.3 behavior when an XType @appended Enumeration value
maps to default value (ordinal 0) using @try_construct(USE_DEFAULT).
Test Setup
HelloWorld1 idl:
module HelloWorldData
{
@appendable
enum ColorAppendable {
CA_UNKNOWN,
CA_BLACK,
CA_WHITE
};
@topic
@appendable
struct Msg
{
@key
long userID;
string message;
ColorAppendable colorAppendable;
};
};
HelloWorld2 idl:
module HelloWorldData
{
@appendable
enum ColorAppendable {
CA_UNKNOWN,
CA_BLACK,
CA_WHITE,
CA_RED // Added/Appended New Value
};
@topic
@appendable
struct Msg
{
@key
long userID;
string message;
ColorAppendable colorAppendable;
};
};
C++ Test Procedure (cyclonedds-cxx release 11.0.0)
- C++ HelloWorld2 Publisher writes Msg with colorAppendable = CA_RED
- C++ HelloWorld1 Subscriber (unaware of CA_RED) reads Msg successfully
- colorAppendable mapped to CA_UNKNOWN (ordinal 0)
- This works because idlc generates “enum_conversion” API to unknown value to default case, which is “0”.
- Equivalent to
@try_construct(USE_DEFAULT), see the idlc generated C++ code withenum_conversionAPI.
c Test Procedure (cyclonedds release 11.0.0)
- c HelloWorld2 Publisher writes Msg with colorAppendable = CA_RED
- c HelloWorld1 Subscriber (unaware of CA_RED) fails to read Msg
- c HelloWorld1 gets "deserialization HelloWorldData_Msg/HelloWorldData::Msg failed (for reasons unknown)"
- This fails because read_normalize_enum in dds_cdrstream.c return “false” if the value is greater the maximum value of enumeration type.
- Equivalent to
@try_construct(DISCARD)which is the XTpes default behavior when @try_construct is not specified
Requested Change
Add idlc options to allow idlc generated c code to act equivalent to @try_construct(USE_DEFAULT).
Note: idl compiler options are standard solutions from other OMG DDS vendor implementations that do not support @try_contruct annotation in the IDL.
RTI Community: https://community.rti.com/static/documentation/connext-dds/current/doc/api/connext_dds/api_cpp2/classrti_1_1config_1_1compliance_1_1XTypesMask.html.
Example Programs
cyclonedds-cxx:
HelloWorld1 source: helloWorld_cxx.zip
HelloWorld2 source: helloWorld_cxx.zip
Cyclonedds (C version):
HelloWorld1 source: helloWorld_c.zip
HelloWorld2 source: helloWorld_c.zip