Skip to content

Commit f7c4531

Browse files
committed
Fix alias parsing
Signed-off-by: Yangbo Long <[email protected]>
1 parent e3789f8 commit f7c4531

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

examples/cpp/dds/IdlParserExample/IdlParser_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define FASTDDS_ENFORCE_LOG_INFO
2121

2222
#include <DynamicTypeBuilderFactoryImpl.hpp>
23-
#include <fastrtps/log/Log.h>
23+
#include <fastdds/dds/log/Log.hpp>
2424

2525
#include <iostream>
2626

src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlParser.hpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,17 @@ struct action<char_type>
489489
{
490490
case Context::CHAR:
491491
state["type"] = "char";
492+
break;
492493
case Context::UINT8:
493494
state["type"] = "uint8";
495+
break;
494496
case Context::INT8:
495497
state["type"] = "int8";
498+
break;
496499
default:
497500
EPROSIMA_LOG_ERROR(IDLPARSER, "Invalid char type " << ctx->char_translation);
498501
state["type"] = "char";
502+
break;
499503
}
500504
}
501505

@@ -515,11 +519,14 @@ struct action<wide_char_type>
515519
{
516520
case Context::WCHAR_T:
517521
state["type"] = "wchar";
522+
break;
518523
case Context::CHAR16_T:
519524
state["type"] = "char16";
525+
break;
520526
default:
521527
EPROSIMA_LOG_ERROR(IDLPARSER, "Invalid wchar type " << ctx->char_translation);
522528
state["type"] = "wchar";
529+
break;
523530
}
524531
}
525532

@@ -1409,10 +1416,11 @@ struct action<typedef_dcl>
14091416
DynamicType::_ref_type alias_type = ctx->get_type(state, state["type"]);
14101417
DynamicTypeBuilderFactory::_ref_type factory {DynamicTypeBuilderFactory::get_instance()};
14111418
TypeDescriptor::_ref_type type_descriptor {traits<TypeDescriptor>::make_shared()};
1419+
type_descriptor->kind(TK_ALIAS);
1420+
type_descriptor->name(alias_name);
14121421
if (sizes_str.empty())
14131422
{
1414-
type_descriptor->kind(TK_ALIAS);
1415-
type_descriptor->name(alias_name);
1423+
type_descriptor->base_type(alias_type);
14161424
}
14171425
else
14181426
{
@@ -1421,9 +1429,8 @@ struct action<typedef_dcl>
14211429
{
14221430
sizes.push_back(static_cast<uint32_t>(std::stoul(size)));
14231431
}
1424-
type_descriptor->kind(TK_ARRAY);
1425-
type_descriptor->element_type(alias_type);
1426-
type_descriptor->bound(sizes);
1432+
DynamicTypeBuilder::_ref_type array_builder {factory->create_array_type(alias_type, sizes)};
1433+
type_descriptor->base_type(array_builder->build());
14271434
}
14281435

14291436
DynamicTypeBuilder::_ref_type builder {factory->create_type(type_descriptor)};

0 commit comments

Comments
 (0)