Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yangbo Long <yangbo.long.mav@gmail.com>
  • Loading branch information
YangboLong committed Dec 22, 2024
1 parent f5e72a8 commit 37687ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 58 deletions.
65 changes: 8 additions & 57 deletions src/cpp/fastdds/xtypes/dynamic_types/idl_parser/IdlParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,11 @@ struct action<semicolon>
{ \
template<typename Input> \
static void apply( \
const Input& in, \
const Input& /*in*/, \
Context* /*ctx*/, \
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& /*operands*/) \
{ \
std::cout << "load_type_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
state["type"] = std::string(#id); \
if (state["type"] == "string" || state["type"] == "wstring") \
{ \
Expand Down Expand Up @@ -541,14 +538,11 @@ struct action<open_ang_bracket>
{ \
template<typename Input> \
static void apply( \
const Input& in, \
const Input& /*in*/, \
Context* /*ctx*/, \
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << "load_stringsize_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
DynamicData::_ref_type xdata; \
if (!operands.empty()) \
{ \
Expand Down Expand Up @@ -682,9 +676,6 @@ struct action<boolean_literal>
std::map<std::string, std::string>& state,
std::vector<traits<DynamicData>::ref_type>& operands)
{
std::cout << "boolean_literal: " << typeid(boolean_literal).name()
<< " " << in.string() << std::endl;

if (state.count("arithmetic_expr"))
{
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{"bool"};
Expand Down Expand Up @@ -733,9 +724,6 @@ struct action<boolean_literal>
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << "load_literal_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
if (state.count("arithmetic_expr")) \
{ \
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
Expand Down Expand Up @@ -794,8 +782,6 @@ load_literal_action(string_literal, string, std::string, TK_STRING8, set_string_
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << #Rule << ": " << typeid(Rule).name() << " " << in.string() << std::endl; \
\
if (state.count("arithmetic_expr")) \
{ \
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
Expand Down Expand Up @@ -835,9 +821,6 @@ struct action<wide_string_literal>
std::map<std::string, std::string>& state,
std::vector<traits<DynamicData>::ref_type>& operands)
{
std::cout << "wide_string_literal: " << typeid(wide_string_literal).name()
<< " " << in.string() << std::endl;

if (state.count("arithmetic_expr"))
{
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{"wstring"};
Expand Down Expand Up @@ -865,14 +848,11 @@ struct action<wide_string_literal>
{ \
template<typename Input> \
static void apply( \
const Input& in, \
const Input& /*in*/, \
Context* /*ctx*/, \
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << "float_op_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
if (state.count("arithmetic_expr")) \
{ \
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
Expand All @@ -891,17 +871,11 @@ struct action<wide_string_literal>
{ \
int64_t value = promote<int64_t>(s2) operation promote<int64_t>(s1); \
xdata->set_int64_value(MEMBER_ID_INVALID, value); \
std::cout << "=========" << std::endl; \
std::cout << #operation << ": " << value << std::endl; \
std::cout << "=========" << std::endl; \
} \
else if (TK_FLOAT128 == pt) \
{ \
long double value = promote<long double>(s2) operation promote<long double>(s1); \
xdata->set_float128_value(MEMBER_ID_INVALID, value); \
std::cout << "=========" << std::endl; \
std::cout << #operation << ": " << value << std::endl; \
std::cout << "=========" << std::endl; \
} \
else \
{ \
Expand All @@ -926,14 +900,11 @@ struct action<wide_string_literal>
{ \
template<typename Input> \
static void apply( \
const Input& in, \
const Input& /*in*/, \
Context* /*ctx*/, \
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << "int_op_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
if (state.count("arithmetic_expr")) \
{ \
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
Expand All @@ -952,9 +923,6 @@ struct action<wide_string_literal>
{ \
int64_t value = promote<int64_t>(s2) operation promote<int64_t>(s1); \
xdata->set_int64_value(MEMBER_ID_INVALID, value); \
std::cout << "=========" << std::endl; \
std::cout << #operation << ": " << value << std::endl; \
std::cout << "=========" << std::endl; \
} \
else \
{ \
Expand All @@ -979,14 +947,11 @@ struct action<wide_string_literal>
{ \
template<typename Input> \
static void apply( \
const Input& in, \
const Input& /*in*/, \
Context* /*ctx*/, \
std::map<std::string, std::string>& state, \
std::vector<traits<DynamicData>::ref_type>& operands) \
{ \
std::cout << "bool_op_action: " << typeid(Rule).name() << " " \
<< in.string() << std::endl; \
\
if (state.count("arithmetic_expr")) \
{ \
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{#id}; \
Expand All @@ -1005,17 +970,11 @@ struct action<wide_string_literal>
{ \
int64_t value = promote<int64_t>(s2) operation promote<int64_t>(s1); \
xdata->set_int64_value(MEMBER_ID_INVALID, value); \
std::cout << "=========" << std::endl; \
std::cout << #operation << ": " << value << std::endl; \
std::cout << "=========" << std::endl; \
} \
else if (TK_BOOLEAN == pt) \
{ \
bool value = promote<bool>(s2) logical_op promote<bool>(s1); \
xdata->set_boolean_value(MEMBER_ID_INVALID, value); \
std::cout << "=========" << std::endl; \
std::cout << #logical_op << ": " << value << std::endl; \
std::cout << "=========" << std::endl; \
} \
else \
{ \
Expand Down Expand Up @@ -1050,14 +1009,11 @@ struct action<minus_exec>
{
template<typename Input>
static void apply(
const Input& in,
const Input& /*in*/,
Context* /*ctx*/,
std::map<std::string, std::string>& state,
std::vector<traits<DynamicData>::ref_type>& operands)
{
std::cout << "minus_exec: " << typeid(minus_exec).name() << " "
<< in.string() << std::endl;

if (state.count("arithmetic_expr"))
{
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{"minus"};
Expand Down Expand Up @@ -1091,14 +1047,12 @@ struct action<plus_exec>
{
template<typename Input>
static void apply(
const Input& in,
const Input& /*in*/,
Context* /*ctx*/,
std::map<std::string, std::string>& state,
std::vector<traits<DynamicData>::ref_type>& /*operands*/)
{
// noop
std::cout << "plus_exec: " << typeid(plus_exec).name() << " "
<< in.string() << std::endl;
if (state.count("arithmetic_expr"))
{
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{"plus"};
Expand All @@ -1112,14 +1066,11 @@ struct action<inv_exec>
{
template<typename Input>
static void apply(
const Input& in,
const Input& /*in*/,
Context* /*ctx*/,
std::map<std::string, std::string>& state,
std::vector<traits<DynamicData>::ref_type>& operands)
{
std::cout << "inv_exec: " << typeid(inv_exec).name() << " "
<< in.string() << std::endl;

if (state.count("arithmetic_expr"))
{
state["arithmetic_expr"] += (state["arithmetic_expr"].empty() ? "" : ";") + std::string{"inv"};
Expand Down
13 changes: 12 additions & 1 deletion test/feature/idl_parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ if(WIN32)
-D_WIN32_WINNT=0x0601
-D_CRT_SECURE_NO_WARNINGS
)

find_program(PREPROCESSOR_EXEC cl.exe)
if(PREPROCESSOR_EXEC)
message(STATUS "Found preprocessor: ${PREPROCESSOR_EXEC}")
get_filename_component(PREPROCESSOR_DIR ${PREPROCESSOR_EXEC} DIRECTORY)
set(TEST_ENVIRONMENT_PATH "${PREPROCESSOR_DIR};$ENV{PATH}")
message(STATUS "Added preprocessor directory to test environment PATH: ${TEST_ENVIRONMENT_PATH}")
set(IDLPARSERTESTS_ENV_PROPERTIES ENVIRONMENT "PATH=${TEST_ENVIRONMENT_PATH}")
else()
message(FATAL_ERROR "Preprocessor not found. Some of IdlParserTests will fail.")
endif()
endif()

add_executable(IdlParserTests IdlParserTests.cpp)
Expand All @@ -35,7 +46,7 @@ target_link_libraries(IdlParserTests
fastcdr
fastdds
)
gtest_discover_tests(IdlParserTests)
gtest_discover_tests(IdlParserTests PROPERTIES ${IDLPARSERTESTS_ENV_PROPERTIES})

message(STATUS "Copying IDL directory from ${PROJECT_SOURCE_DIR}/thirdparty/dds-types-test/IDL for idl_parser testing")
add_custom_command(
Expand Down

0 comments on commit 37687ff

Please sign in to comment.