Skip to content

Commit 32a7bbe

Browse files
committed
Refs #22972: Remove flags and TODOs
Signed-off-by: Carlosespicur <[email protected]>
1 parent 27ec2b7 commit 32a7bbe

File tree

2 files changed

+9
-147
lines changed

2 files changed

+9
-147
lines changed

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

+1-42
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,9 @@ class Module
474474
{
475475
if (name.find("::") != std::string::npos || has_alias(name))
476476
{
477-
// __FLAG__
478-
EPROSIMA_LOG_ERROR(IDLPARSER, "Cannot define alias '" << name << "' with scoped name or already defined.");
479-
////////////////
480477
return false; // Cannot define alias with scoped name (or already defined).
481478
}
479+
482480
std::string name_space = scope();
483481
TypeDescriptor::_ref_type type_descriptor {traits<TypeDescriptor>::make_shared()};
484482
builder->get_descriptor(type_descriptor);
@@ -553,46 +551,7 @@ class Module
553551
}
554552

555553
protected:
556-
// __FLAG__
557-
void info() const
558-
{
559-
std::cout << "[IDLMODULE] Module info: " << "\n";
560-
std::cout << " Name: " << name_ << "\n";
561-
std::cout << " Outer scope: " << (outer_ ? outer_->scope() : "nullptr") << "\n";
562-
std::cout << " Inner scopes: " << inner_.size() << "\n";
563-
for (std::map<std::string, std::shared_ptr<Module>>::const_iterator it = inner_.begin(); it != inner_.end(); ++it)
564-
{
565-
std::cout << " - " << it->first << "\n";
566-
}
567-
std::cout << " Aliases: " << aliases_.size() << "\n";
568-
for (std::map<std::string, DynamicTypeBuilder::_ref_type>::const_iterator it = aliases_.begin(); it != aliases_.end(); ++it)
569-
{
570-
std::cout << " - " << it->first << "\n";
571-
}
572-
std::cout << " Constants: " << constants_.size() << "\n";
573-
for (std::map<std::string, DynamicData::_ref_type>::const_iterator it = constants_.begin(); it != constants_.end(); ++it)
574-
{
575-
std::cout << " - " << it->first << "\n";
576-
}
577-
std::cout << " Enumerations: " << enumerations_32_.size() << "\n";
578-
for (std::map<std::string, DynamicTypeBuilder::_ref_type>::const_iterator it = enumerations_32_.begin(); it != enumerations_32_.end(); ++it)
579-
{
580-
std::cout << " - " << it->first << "\n";
581-
}
582-
std::cout << " Structures: " << structs_.size() << "\n";
583-
for (std::map<std::string, DynamicTypeBuilder::_ref_type>::const_iterator it = structs_.begin(); it != structs_.end(); ++it)
584-
{
585-
std::cout << " - " << it->first << "\n";
586-
}
587-
std::cout << " Unions: " << unions_.size() << "\n";
588-
for (std::map<std::string, DynamicTypeBuilder::_ref_type>::const_iterator it = unions_.begin(); it != unions_.end(); ++it)
589-
{
590-
std::cout << " - " << it->first << "\n";
591-
}
592554

593-
std::cout << "--------------------------------" << std::endl;
594-
}
595-
////////////////////
596555
std::map<std::string, DynamicTypeBuilder::_ref_type> aliases_;
597556
// std::map<std::string, Type> constants_types_;
598557
std::map<std::string, DynamicData::_ref_type> constants_;

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

+8-105
Original file line numberDiff line numberDiff line change
@@ -144,30 +144,6 @@ class Context
144144

145145
}; // class Context
146146

147-
// TODO (Carlosespicur): Perhaps would be better to define state tags as constexpr variables (IDLParserTags.hpp??)
148-
149-
// __FLAG__
150-
template<typename Input>
151-
void debug_action(
152-
const std::string& rule_name,
153-
const Input& in,
154-
const std::map<std::string, std::string>& state,
155-
size_t operand_size)
156-
{
157-
std::cout << "[DEBUG] Rule: " << rule_name << "\n";
158-
std::cout << " Input: \"" << in.string() << "\"\n";
159-
std::cout << " Operands stack: " << operand_size << "\n";
160-
std::cout << " State:\n";
161-
162-
for (std::map<std::string, std::string>::const_iterator it = state.begin(); it != state.end(); ++it)
163-
{
164-
std::cout << " - " << it->first << ": " << it->second << "\n";
165-
}
166-
167-
std::cout << "-----------------------------------\n";
168-
}
169-
170-
/////////////////
171147

172148
// Actions
173149
template<typename Rule>
@@ -195,7 +171,6 @@ struct action<identifier>
195171
std::map<std::string, std::string>& state,
196172
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
197173
{
198-
debug_action("identifier", in, state, 0);
199174
std::string identifier_name = in.string();
200175

201176
if (state.count("enum_name"))
@@ -362,7 +337,6 @@ struct action<scoped_name>
362337
std::map<std::string, std::string>& state,
363338
std::vector<traits<DynamicData>::ref_type>& operands)
364339
{
365-
// debug_action("scoped_name", in, state, operands.size());
366340
Module& module = ctx->module();
367341
std::string identifier_name = in.string();
368342

@@ -420,12 +394,11 @@ struct action<semicolon>
420394
{
421395
template<typename Input>
422396
static void apply(
423-
const Input& in /*in*/,
397+
const Input& /*in*/,
424398
Context* /*ctx*/,
425399
std::map<std::string, std::string>& state,
426400
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
427401
{
428-
debug_action("semicolon", in, state, 0);
429402
if (!state["type"].empty())
430403
{
431404
if (state.count("current_struct_member_name") && !state["current_struct_member_name"].empty())
@@ -475,9 +448,6 @@ struct action<semicolon>
475448
}
476449
else if (state.count("union_name") && !state["union_name"].empty())
477450
{
478-
// TODO (Carlosespicur): Probably, this could be refactored to be unified with the previous case after
479-
// supporting array types in unions.
480-
481451
// Add the type and name to the member lists
482452
// NOTE: For sequence types, the type stored in "union_member_types"
483453
// is the type of each element in the sequence, not "sequence".
@@ -505,7 +475,6 @@ struct action<semicolon>
505475
}
506476

507477
// Clear the temporary states for the next member
508-
// TODO (Carlosespicur): Maybe I could clean variables always in a clean guard class
509478
state["type"].clear();
510479

511480
if (state.count("element_type"))
@@ -561,7 +530,6 @@ struct action<semicolon>
561530
} \
562531
else if (state.count("parsing_sequence") && (state["parsing_sequence"] == "true")) \
563532
{ \
564-
std::cout << "[DEBUG] Parsing sequence type: " << type << "\n"; \
565533
state["element_type"] = type; \
566534
state["arithmetic_expr"] = ""; \
567535
} \
@@ -594,12 +562,6 @@ load_type_action(string_type, string)
594562
load_type_action(wide_string_type, wstring)
595563
load_type_action(sequence_type, sequence)
596564

597-
// TODO (Carlosespicur): Sequences could contain other types (declared before), so maybe i could add here a macro
598-
// to load the name of the type or create a new one. Probably, the first one is the best option because all the types above
599-
// can also be the internal type of a sequence. Ej: sequence<int32>. In this case:
600-
// load_type_action(type_spec, customType). How to get custom type name:
601-
// Maybe check if state["parsing_sequence"] == "true" and state.count("member_type_name") > 0 in macro?
602-
603565
template<>
604566
struct action<char_type>
605567
{
@@ -700,24 +662,6 @@ struct action<open_bracket>
700662

701663
};
702664

703-
// TODO (Carlosespicur): Maybe a better approach is erase "arithmetic_expr"
704-
// after closing the bracket (I think it is more general)
705-
// template<>
706-
// struct action<close_bracket>
707-
// {
708-
// template<typename Input>
709-
// static void apply(
710-
// const Input& /*in*/,
711-
// Context* /*ctx*/,
712-
// std::map<std::string, std::string>& state,
713-
// std::vector<traits<DynamicData>::ref_type>& /*operands*/)
714-
// {
715-
// if (state.count)
716-
// state.erase("arithmetic_expr");
717-
// }
718-
719-
// };
720-
721665
template<>
722666
struct action<fixed_array_size>
723667
{
@@ -767,7 +711,6 @@ struct action<fixed_array_size>
767711

768712
};
769713

770-
// TODO (Carlosespicur): Perhaps the following action can be unified with load_stringsize_action
771714
template<>
772715
struct action<sequence_size>
773716
{
@@ -852,8 +795,6 @@ struct action<kw_wstring>
852795

853796
};
854797

855-
856-
857798
template<>
858799
struct action<open_ang_bracket>
859800
{
@@ -926,7 +867,6 @@ struct action<kw_sequence>
926867
std::map<std::string, std::string>& state,
927868
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
928869
{
929-
// debug_action("kw_sequence", in, state, 0);
930870
state["type"] = "sequence";
931871
// Set the default sequence size to LENGTH_UNLIMITED. In case of bounded sequence, it will be overrided later.
932872
state["sequence_size"] = std::to_string(LENGTH_UNLIMITED);
@@ -941,24 +881,6 @@ struct action<kw_sequence>
941881
}
942882
};
943883

944-
// template<>
945-
// struct action<sequence_type>
946-
// {
947-
// template<typename Input>
948-
// static void apply(
949-
// const Input& in,
950-
// Context* /*ctx*/,
951-
// std::map<std::string, std::string>& state,
952-
// std::vector<traits<DynamicData>::ref_type>& /*operands*/)
953-
// {
954-
// state["type"] = in.string();
955-
// // TODO (Carlosespicur): Implement sequence type parsing
956-
957-
// // Should "sequence_sizes" state key be bconfigured here or add an action<sequence_size>?
958-
// EPROSIMA_LOG_INFO(IDLPARSER, "[TODO] sequence_type parsing not supported: " << state["type"]);
959-
// }
960-
// };
961-
962884
template<>
963885
struct action<map_type>
964886
{
@@ -1091,7 +1013,6 @@ struct action<boolean_literal>
10911013
std::map<std::string, std::string>& state, \
10921014
std::vector<traits<DynamicData>::ref_type>& operands) \
10931015
{ \
1094-
debug_action(#Rule, in, state, operands.size()); \
10951016
if (state.count("arithmetic_expr")) \
10961017
{ \
10971018
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
@@ -1125,11 +1046,8 @@ struct action<boolean_literal>
11251046
DynamicData::_ref_type xdata {DynamicDataFactory::get_instance()->create_data(xtype)}; \
11261047
xdata->set_value(MEMBER_ID_INVALID, value); \
11271048
\
1128-
std::cout << "Before pushing..." << std::endl; \
1129-
debug_action(#Rule, in, state, operands.size()); \
11301049
if (state.count("arithmetic_expr")) \
11311050
{ \
1132-
std::cout << "Pushing back " << #id << " literal: " << in.string() << "\n"; \
11331051
operands.push_back(xdata); \
11341052
} \
11351053
} \
@@ -1732,7 +1650,6 @@ struct action<struct_def>
17321650
state.erase("struct_member_types");
17331651
state.erase("struct_member_names");
17341652
state.erase("current_struct_member_name");
1735-
// TODO (Carlosespicur): I think I should remove each unnecesary key after building the type.
17361653
state["type"] = "";
17371654
state["all_array_sizes"] = "";
17381655
state["current_array_sizes"] = "";
@@ -1741,7 +1658,7 @@ struct action<struct_def>
17411658

17421659
template<typename Input>
17431660
static void apply(
1744-
const Input& in/*in*/,
1661+
const Input& /*in*/,
17451662
Context* ctx,
17461663
std::map<std::string, std::string>& state,
17471664
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
@@ -1758,8 +1675,6 @@ struct action<struct_def>
17581675
}
17591676
cleanup_guard{state};
17601677

1761-
debug_action("struct_def", in, state, 0);
1762-
17631678
Module& module = ctx->module();
17641679
const std::string& struct_name = state["struct_name"];
17651680

@@ -1772,8 +1687,6 @@ struct action<struct_def>
17721687
std::vector<std::string> types = ctx->split_string(state["struct_member_types"], ';');
17731688
std::vector<std::string> names = ctx->split_string(state["struct_member_names"], ';');
17741689
std::vector<std::string> all_array_sizes = ctx->split_string(state["all_array_sizes"], ';');
1775-
// TODO (Carlosespicur): Probably here I need add a "sequence_sizes" key to state map
1776-
// i.e: state["sequence_sizes"] = "size_1;size_2;...;size_n";
17771690
std::vector<std::string> sequence_sizes = ctx->split_string(state["sequence_sizes"], ';');
17781691

17791692
for (size_t i = 0; i < types.size(); i++)
@@ -1875,12 +1788,11 @@ struct action<kw_union>
18751788
{
18761789
template<typename Input>
18771790
static void apply(
1878-
const Input& in /*in*/,
1791+
const Input& /*in*/,
18791792
Context* /*ctx*/,
18801793
std::map<std::string, std::string>& state,
18811794
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
18821795
{
1883-
debug_action("kw_union", in, state, 0);
18841796
// Create empty union states to indicate the start of parsing union
18851797
state["union_name"] = "";
18861798
state["union_discriminant"] = "";
@@ -1889,7 +1801,6 @@ struct action<kw_union>
18891801
state["union_member_types"] = "";
18901802
state["current_union_member_name"] = "";
18911803
state["sequence_sizes"] = "";
1892-
// state["union_expecting_member_name"] = "";
18931804
state["type"] = "";
18941805
}
18951806

@@ -2032,12 +1943,11 @@ struct action<union_def>
20321943
state.erase("union_member_types");
20331944
state.erase("union_member_names");
20341945
state.erase("sequence_sizes");
2035-
// state.erase("union_expecting_member_name");
20361946
}
20371947

20381948
template<typename Input>
20391949
static void apply(
2040-
const Input& in/*in*/,
1950+
const Input& /*in*/,
20411951
Context* ctx,
20421952
std::map<std::string, std::string>& state,
20431953
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
@@ -2054,7 +1964,6 @@ struct action<union_def>
20541964
}
20551965
cleanup_guard{state};
20561966

2057-
debug_action("union_def", in, state, 0);
20581967
Module& module = ctx->module();
20591968
const std::string& union_name = state["union_name"];
20601969

@@ -2063,7 +1972,7 @@ struct action<union_def>
20631972
DynamicType::_ref_type discriminant_type = ctx->get_type(state, state["union_discriminant"]);
20641973
if (!discriminant_type)
20651974
{
2066-
EPROSIMA_LOG_INFO(IDLPARSER, "[TODO] union type not supported: " << state["union_discriminant"]);
1975+
EPROSIMA_LOG_WARNING(IDLPARSER, "[TODO] union type not supported: " << state["union_discriminant"]);
20671976
return;
20681977
}
20691978
type_descriptor->kind(TK_UNION);
@@ -2194,8 +2103,6 @@ struct action<kw_typedef>
21942103
// Create empty alias states to indicate the start of parsing alias
21952104
state["alias"] = "";
21962105
state["current_array_sizes"] = "";
2197-
2198-
// TODO (Carlosespicur): Think about it is necessary to reset state["current_sequence_size"] here.
21992106
}
22002107

22012108
};
@@ -2221,7 +2128,7 @@ struct action<typedef_dcl>
22212128

22222129
template<typename Input>
22232130
static void apply(
2224-
const Input& in /*in*/,
2131+
const Input& /*in*/,
22252132
Context* ctx,
22262133
std::map<std::string, std::string>& state,
22272134
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
@@ -2238,8 +2145,6 @@ struct action<typedef_dcl>
22382145
}
22392146
cleanup_guard{state};
22402147

2241-
debug_action("typedef_dcl", in, state, 0);
2242-
22432148
Module& module = ctx->module();
22442149

22452150
std::string alias_name;
@@ -2271,10 +2176,8 @@ struct action<typedef_dcl>
22712176

22722177
if (!alias_type)
22732178
{
2274-
EPROSIMA_LOG_INFO(IDLPARSER, "[TODO] alias type not supported: " << state["type"]);
2179+
EPROSIMA_LOG_WARNING(IDLPARSER, "[TODO] alias type not supported: " << state["type"]);
22752180
return;
2276-
2277-
// throw std::runtime_error("Alias type not supported: " + state["type"]);
22782181
}
22792182

22802183
DynamicTypeBuilderFactory::_ref_type factory {DynamicTypeBuilderFactory::get_instance()};
@@ -2458,7 +2361,7 @@ class Parser
24582361
else
24592362
{
24602363
context_->success = false;
2461-
EPROSIMA_LOG_INFO(IDLPARSER, "IDL parsing failed.");
2364+
EPROSIMA_LOG_ERROR(IDLPARSER, "IDL parsing failed.");
24622365
return false;
24632366
}
24642367
}

0 commit comments

Comments
 (0)