File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -491,20 +491,12 @@ dynamic_array_to_yaml(
491491 array_node);
492492 break ;
493493 case rosidl_typesupport_introspection_c__ROS_TYPE_MESSAGE:
494- // We do not know the specific type of the sequence because the type is not available at
495- // compile-time, but they all follow the same structure pattern, where a pointer to the data
496- // is first, followed by the element count, followed by the capacity
497494 RosMessage nested_member;
498495 nested_member.type_info = reinterpret_cast <const TypeInfo *>(member_info.members_ ->data );
499- uint8_t * element_data;
500- memcpy (&element_data, member_data, sizeof (void *));
501- size_t element_size;
502- element_size = nested_member.type_info ->size_of_ ;
503- size_t element_count;
504- element_count = static_cast <size_t >(member_data[sizeof (void *)]);
505- for (size_t ii = 0 ; ii < element_count; ++ii) {
506- nested_member.data = element_data + ii * element_size;
496+ for (size_t i = 0 ; i < member_info.size_function (member_data); i++) {
507497 // Recursively read the nested type into the array element in the YAML representation
498+ nested_member.data = reinterpret_cast <uint8_t *>(
499+ member_info.get_function (const_cast <uint8_t *>(member_data), i));
508500 array_node.push_back (dynmsg::c::message_to_yaml (nested_member));
509501 }
510502 break ;
Original file line number Diff line number Diff line change @@ -517,11 +517,10 @@ dynamic_array_to_yaml(
517517 case rosidl_typesupport_introspection_cpp::ROS_TYPE_MESSAGE:
518518 RosMessage_Cpp nested_member;
519519 nested_member.type_info = reinterpret_cast <const TypeInfo_Cpp *>(member_info.members_ ->data );
520- void * data;
521- data = reinterpret_cast <void *>(const_cast <uint8_t *>(member_data));
522- for (size_t i = 0 ; i < member_info.size_function (data); i++) {
520+ for (size_t i = 0 ; i < member_info.size_function (member_data); i++) {
523521 // Recursively read the nested type into the array element in the YAML representation
524- nested_member.data = reinterpret_cast <uint8_t *>(member_info.get_function (data, i));
522+ nested_member.data = reinterpret_cast <uint8_t *>(
523+ member_info.get_function (const_cast <uint8_t *>(member_data), i));
525524 array_node.push_back (message_to_yaml (nested_member));
526525 }
527526 break ;
You can’t perform that action at this time.
0 commit comments