Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use {size,get}_function introspection functions #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions dynmsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ add_library(dynmsg STATIC
src/message_reading_c.cpp
src/message_reading_cpp.cpp
src/typesupport.cpp
src/vector_utils.cpp
src/string_utils.cpp
src/yaml_utils.cpp
)
Expand Down Expand Up @@ -89,9 +88,6 @@ if(BUILD_TESTING)
ament_add_gtest(wide_strings test/test_wide_strings.cpp)
target_link_libraries(wide_strings dynmsg)

ament_add_gtest(test_vector_utils test/test_vector_utils.cpp)
target_link_libraries(test_vector_utils dynmsg)

ament_add_gtest(test_typesupport test/test_typesupport.cpp)
target_link_libraries(test_typesupport dynmsg)
ament_target_dependencies(test_typesupport std_msgs)
Expand Down
36 changes: 0 additions & 36 deletions dynmsg/include/dynmsg/vector_utils.hpp

This file was deleted.

14 changes: 3 additions & 11 deletions dynmsg/src/message_reading_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,20 +491,12 @@ dynamic_array_to_yaml(
array_node);
break;
case rosidl_typesupport_introspection_c__ROS_TYPE_MESSAGE:
// We do not know the specific type of the sequence because the type is not available at
// compile-time, but they all follow the same structure pattern, where a pointer to the data
// is first, followed by the element count, followed by the capacity
RosMessage nested_member;
nested_member.type_info = reinterpret_cast<const TypeInfo *>(member_info.members_->data);
uint8_t * element_data;
memcpy(&element_data, member_data, sizeof(void *));
size_t element_size;
element_size = nested_member.type_info->size_of_;
size_t element_count;
element_count = static_cast<size_t>(member_data[sizeof(void *)]);
for (size_t ii = 0; ii < element_count; ++ii) {
nested_member.data = element_data + ii * element_size;
for (size_t i = 0; i < member_info.size_function(member_data); i++) {
// Recursively read the nested type into the array element in the YAML representation
nested_member.data = reinterpret_cast<uint8_t *>(
member_info.get_function(const_cast<uint8_t *>(member_data), i));
array_node.push_back(dynmsg::c::message_to_yaml(nested_member));
}
break;
Expand Down
16 changes: 3 additions & 13 deletions dynmsg/src/message_reading_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "dynmsg/message_reading.hpp"
#include "dynmsg/string_utils.hpp"
#include "dynmsg/typesupport.hpp"
#include "dynmsg/vector_utils.hpp"

namespace dynmsg
{
Expand Down Expand Up @@ -516,21 +515,12 @@ dynamic_array_to_yaml(
array_node);
break;
case rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
// We do not know the specific type of the sequence because the type is not available at
// compile-time, but we know it's a vector and we know the size of the contained type.
RosMessage_Cpp nested_member;
nested_member.type_info = reinterpret_cast<const TypeInfo_Cpp *>(member_info.members_->data);
uint8_t * element_data;
memcpy(&element_data, member_data, sizeof(void *));
size_t element_size;
element_size = nested_member.type_info->size_of_;
size_t element_count;
element_count = dynmsg::get_vector_size(member_data, element_size);
DYNMSG_DEBUG(std::cout << "\telement_size=" << element_size << std::endl);
DYNMSG_DEBUG(std::cout << "\telement_count=" << element_count << std::endl);
for (size_t ii = 0; ii < element_count; ++ii) {
nested_member.data = element_data + ii * element_size;
for (size_t i = 0; i < member_info.size_function(member_data); i++) {
// Recursively read the nested type into the array element in the YAML representation
nested_member.data = reinterpret_cast<uint8_t *>(
member_info.get_function(const_cast<uint8_t *>(member_data), i));
array_node.push_back(message_to_yaml(nested_member));
}
break;
Expand Down
61 changes: 0 additions & 61 deletions dynmsg/src/vector_utils.cpp

This file was deleted.

69 changes: 0 additions & 69 deletions dynmsg/test/test_vector_utils.cpp

This file was deleted.