Skip to content

Commit 9f257dc

Browse files
authored
Merge pull request #3325 from randaz81/thrift_test3
Added new test for thrift + bugfix
2 parents cfe282e + 5fb47f7 commit 9f257dc

9 files changed

Lines changed: 2173 additions & 4 deletions

File tree

doc/release/v4_0_0.MD

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ YARP <yarp-4.0.> Release Notes
88

99

1010
A (partial) list of bug fixed and issues resolved in this release can be found
11-
[here](https://github.com/robotology/yarp/issues?q=label%3A%22Fixed+in%3A+YARP+yarp-3.12%22).
11+
[here](https://github.com/robotology/yarp/issues?q=label%3A%22Fixed+in%3A+YARP+yarp-4.0%22).
1212

1313
New Features
1414
----------------
@@ -32,6 +32,11 @@ Added new PortMonitor `throttleDown` to limit the bandwidth usage over a port co
3232
* `yarpmotorgui` can now use the option `reduce_bandwidth` to use `throttleDown` portmonitor to reduce bandwidth usage.
3333
* `yarpmotorgui` now handles the `braked` status from interface `IJointBrake`.
3434

35+
### IDL_Thrift
36+
37+
* improved generator to support services with multiple containers (lists, maps, sets)
38+
39+
3540
Deprecations and removals
3641
---------------------------
3742

src/commands/yarpidl_thrift/src/t_yarp_generator.cc

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,12 @@ void t_yarp_generator::generate_deserialize_container(std::ostringstream& f_cpp_
15761576
{
15771577
THRIFT_DEBUG_COMMENT(f_cpp_);
15781578

1579-
if (ttype->is_map()) {
1579+
if (ttype->is_map())
1580+
{
1581+
// Begin scope of _csize
1582+
f_cpp_ << indent_cpp() << "{\n";
1583+
indent_up_cpp();
1584+
15801585
f_cpp_ << indent_cpp() << "size_t _csize;\n";
15811586
// kttpe and vtype available
15821587
f_cpp_ << indent_cpp() << "yarp::os::idl::WireState _ktype;\n";
@@ -1595,7 +1600,16 @@ void t_yarp_generator::generate_deserialize_container(std::ostringstream& f_cpp_
15951600
// Read container end
15961601
f_cpp_ << indent_cpp() << "reader.readMapEnd();\n";
15971602

1598-
} else if (ttype->is_set()) {
1603+
// End scope of _csize
1604+
indent_down_cpp();
1605+
f_cpp_ << indent_cpp() << "}\n";
1606+
}
1607+
else if (ttype->is_set())
1608+
{
1609+
// Begin scope of _csize
1610+
f_cpp_ << indent_cpp() << "{\n";
1611+
indent_up_cpp();
1612+
15991613
f_cpp_ << indent_cpp() << "size_t _csize;\n";
16001614
f_cpp_ << indent_cpp() << "yarp::os::idl::WireState _etype;\n";
16011615
f_cpp_ << indent_cpp() << "reader.readSetBegin(_etype, _csize);\n";
@@ -1612,11 +1626,20 @@ void t_yarp_generator::generate_deserialize_container(std::ostringstream& f_cpp_
16121626
// Read container end
16131627
f_cpp_ << indent_cpp() << "reader.readSetEnd();\n";
16141628

1615-
} else if (ttype->is_list()) {
1629+
// End scope of _csize
1630+
indent_down_cpp();
1631+
f_cpp_ << indent_cpp() << "}\n";
1632+
}
1633+
else if (ttype->is_list())
1634+
{
16161635
t_container* tcontainer = static_cast<t_container*>(ttype);
16171636
auto* elem_type = static_cast<t_list*>(ttype)->get_elem_type();
16181637
bool use_push = tcontainer->has_cpp_name() || (static_cast<t_base_type*>(elem_type)->get_base() == t_base_type::TYPE_BOOL);
16191638

1639+
// Begin scope of _csize
1640+
f_cpp_ << indent_cpp() << "{\n";
1641+
indent_up_cpp();
1642+
16201643
f_cpp_ << indent_cpp() << "size_t _csize;\n";
16211644
f_cpp_ << indent_cpp() << "yarp::os::idl::WireState _etype;\n";
16221645
f_cpp_ << indent_cpp() << "reader.readListBegin(_etype, _csize);\n";
@@ -1671,6 +1694,10 @@ void t_yarp_generator::generate_deserialize_container(std::ostringstream& f_cpp_
16711694

16721695
// Read container end
16731696
f_cpp_ << indent_cpp() << "reader.readListEnd();\n";
1697+
1698+
// End scope of _csize
1699+
indent_down_cpp();
1700+
f_cpp_ << indent_cpp() << "}\n";
16741701
}
16751702
}
16761703

src/commands/yarpidl_thrift/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
add_subdirectory(test1)
55
add_subdirectory(test2)
6+
add_subdirectory(test3)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: 2026-2026 Istituto Italiano di Tecnologia (IIT)
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
include (Catch)
5+
include(YarpCatchUtils)
6+
include(YarpChooseIDL)
7+
8+
yarp_choose_idl(TEST3_THRIFT testdata.thrift)
9+
10+
add_executable(harness_thrift_test3)
11+
12+
target_sources(harness_thrift_test3
13+
PRIVATE
14+
main.cpp
15+
${TEST3_THRIFT_GEN_FILES}
16+
)
17+
18+
target_link_libraries(harness_thrift_test3
19+
PRIVATE
20+
YARP_harness
21+
YARP::YARP_os
22+
)
23+
24+
target_include_directories(harness_thrift_test3
25+
PUBLIC ${TEST3_THRIFT_BUILD_INTERFACE_INCLUDE_DIRS}
26+
)
27+
28+
set_property(TARGET harness_thrift_test3 PROPERTY FOLDER "Test")
29+
yarp_catch_discover_tests(harness_thrift_test3)

0 commit comments

Comments
 (0)