From 9c7c74acf585e2faf1b6f865c2ee1f3426b72f10 Mon Sep 17 00:00:00 2001 From: methylDragon Date: Sun, 9 Apr 2023 22:34:08 -0700 Subject: [PATCH 1/2] Refactor serialization support to use allocators and refs Signed-off-by: methylDragon --- .../rmw/dynamic_message_type_support.h | 7 ++++-- rmw/include/rmw/error_handling.h | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/rmw/include/rmw/dynamic_message_type_support.h b/rmw/include/rmw/dynamic_message_type_support.h index 64c58d28..0135b500 100644 --- a/rmw/include/rmw/dynamic_message_type_support.h +++ b/rmw/include/rmw/dynamic_message_type_support.h @@ -20,6 +20,8 @@ extern "C" { #endif +#include + #include #include #include @@ -57,9 +59,10 @@ rmw_take_dynamic_message_with_info( RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t -rmw_get_serialization_support( +rmw_init_serialization_support( const char * serialization_lib_name, - rosidl_dynamic_typesupport_serialization_support_t ** serialization_support); // OUT + rcutils_allocator_t * allocator, + rosidl_dynamic_typesupport_serialization_support_t * serialization_support); // OUT // TODO(methylDragon): Nice to have only // RMW_PUBLIC diff --git a/rmw/include/rmw/error_handling.h b/rmw/include/rmw/error_handling.h index 66104a5c..63d7d2ba 100644 --- a/rmw/include/rmw/error_handling.h +++ b/rmw/include/rmw/error_handling.h @@ -175,6 +175,29 @@ typedef rcutils_error_state_t rmw_error_state_t; /// Reset the error state by clearing any previously set error state. #define rmw_reset_error rcutils_reset_error +/// Set the error message using RCUTILS_SET_ERROR_MSG and append the previous error. +/** + * If there is no previous error, has same behavior as RCUTILS_SET_ERROR_MSG. + * \param[in] msg The error message to be set. + */ +#define RMW_SET_ERROR_MSG_AND_APPEND_PREV_ERROR(msg) \ + RCUTILS_SET_ERROR_MSG_AND_APPEND_PREV_ERROR(msg) + +/// Set the error message with RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING and append the previous +/// error. +/** + * This function sets the error message using the given format string, and appends and resets the + * latest error string. + * The resulting formatted string is silently truncated at RCUTILS_ERROR_MESSAGE_MAX_LENGTH. + * + * If there is no previous error, has same behavior as RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING. + * + * \param[in] format_string The string to be used as the format of the error message. + * \param[in] ... Arguments for the format string. + */ +#define RMW_SET_ERROR_MSG_WITH_FORMAT_STRING_AND_APPEND_PREV_ERROR(format_string, ...) \ + RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING_AND_APPEND_PREV_ERROR(format_string, __VA_ARGS__) + #ifdef __cplusplus } #endif From 8f4b3adabd249f136673302e6f50fe6bb7f8cd10 Mon Sep 17 00:00:00 2001 From: methylDragon Date: Mon, 10 Apr 2023 11:29:19 -0700 Subject: [PATCH 2/2] Use rmw_serialization_support_init Signed-off-by: methylDragon --- rmw/include/rmw/dynamic_message_type_support.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw/include/rmw/dynamic_message_type_support.h b/rmw/include/rmw/dynamic_message_type_support.h index 0135b500..7d8b13da 100644 --- a/rmw/include/rmw/dynamic_message_type_support.h +++ b/rmw/include/rmw/dynamic_message_type_support.h @@ -59,7 +59,7 @@ rmw_take_dynamic_message_with_info( RMW_PUBLIC RMW_WARN_UNUSED rmw_ret_t -rmw_init_serialization_support( +rmw_serialization_support_init( const char * serialization_lib_name, rcutils_allocator_t * allocator, rosidl_dynamic_typesupport_serialization_support_t * serialization_support); // OUT