Skip to content

Commit

Permalink
Merge pull request OpenDDS#4549 from mitza-oci/master
Browse files Browse the repository at this point in the history
Update integer type used internally for enums
  • Loading branch information
jrw972 authored Mar 29, 2024
2 parents fafdb00 + 9835582 commit c29c704
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion dds/idl/dds_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ inline std::string to_cxx_type(AST_Type* type, std::size_t& size)
const AstTypeClassification::Classification cls = AstTypeClassification::classify(type);
if (cls & AstTypeClassification::CL_ENUM) {
size = 4;
return "ACE_CDR::ULong";
// Using the XTypes definition of Enums, this type is signed.
// It contradicts the OMG standard CDR definition.
return "ACE_CDR::Long";
}
if (cls & AstTypeClassification::CL_STRING) {
return string_type(cls);
Expand Down
14 changes: 7 additions & 7 deletions dds/idl/marshal_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ namespace {
AST_Type* elem = resolveActualType(seq->base_type());
TryConstructFailAction try_construct = be_global->sequence_element_try_construct(seq);

Classification elem_cls = classify(elem);
const Classification elem_cls = classify(elem);
const bool primitive = elem_cls & CL_PRIMITIVE;
if (!elem->in_main_file()) {
if (elem->node_type() == AST_Decl::NT_pre_defined) {
Expand Down Expand Up @@ -918,7 +918,7 @@ namespace {

AST_Type* elem = resolveActualType(arr->base_type());
TryConstructFailAction try_construct = be_global->array_element_try_construct(arr);
Classification elem_cls = classify(elem);
const Classification elem_cls = classify(elem);
const bool primitive = elem_cls & CL_PRIMITIVE;
if (!elem->in_main_file()
&& elem->node_type() != AST_Decl::NT_pre_defined) {
Expand Down Expand Up @@ -1260,7 +1260,7 @@ namespace {
if (type == type_stack[i]) return false;
}
type_stack.push_back(type);
Classification fld_cls = classify(type);
const Classification fld_cls = classify(type);
if ((fld_cls & CL_STRING) && !(fld_cls & CL_BOUNDED)) {
bounded = false;
} else if (fld_cls & CL_STRUCTURE) {
Expand Down Expand Up @@ -2477,7 +2477,7 @@ namespace {
" if (!" << generate_field_stream(
indent, field, ">> stru" + value_access, wrap_nested_key_only, intro) << ") {\n";
AST_Type* const field_type = resolveActualType(field->field_type());
Classification fld_cls = classify(field_type);
const Classification fld_cls = classify(field_type);

if (use_cxx11) {
field_name += "()";
Expand Down Expand Up @@ -3046,7 +3046,7 @@ marshal_generator::gen_field_getValueFromSerialized(AST_Structure* node, const s
const OpenDDS::XTypes::MemberId id = be_global->get_id(field);
std::string field_name = field->local_name()->get_string();
AST_Type* const field_type = resolveActualType(field->field_type());
Classification fld_cls = classify(field_type);
const Classification fld_cls = classify(field_type);

cases << " case " << id << ": {\n";
if (fld_cls & CL_SCALAR) {
Expand Down Expand Up @@ -3131,7 +3131,7 @@ marshal_generator::gen_field_getValueFromSerialized(AST_Structure* node, const s
size_t size = 0;
const std::string idl_name = canonical_name(field);
AST_Type* const field_type = resolveActualType(field->field_type());
Classification fld_cls = classify(field_type);
const Classification fld_cls = classify(field_type);
if (fld_cls & CL_SCALAR) {
const std::string cxx_type = to_cxx_type(field_type, size);
const std::string val = (fld_cls & CL_STRING) ? (use_cxx11 ? "val" : "val.out()")
Expand Down Expand Up @@ -3492,7 +3492,7 @@ bool marshal_generator::gen_union(AST_Union* node, UTL_ScopedName* name,
NamespaceGuard ng;
be_global->add_include("dds/DCPS/Serializer.h");
string cxx = scoped(name); // name as a C++ class
Classification disc_cls = classify(discriminator);
const Classification disc_cls = classify(discriminator);

FieldInfo::EleLenSet anonymous_seq_generated;
for (size_t i = 0; i < branches.size(); ++i) {
Expand Down

0 comments on commit c29c704

Please sign in to comment.