From 9d1c330a8d0e03edfdf27f919a11e722116a7cf8 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 22 Apr 2020 12:58:53 +0200 Subject: [PATCH 1/6] Commented action, message, service typesupport and message bounds Signed-off-by: ahcorde --- .../action_type_support_struct.h | 8 +++++ .../rosidl_runtime_c/message_bounds_struct.h | 29 +++++++++++++++++++ .../message_type_support_struct.h | 29 +++++++++++++++++++ .../service_type_support_struct.h | 29 +++++++++++++++++++ 4 files changed, 95 insertions(+) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h index 5bd1ad393..0de6dd586 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h @@ -27,6 +27,8 @@ extern "C" typedef struct rosidl_action_type_support_t rosidl_action_type_support_t; +/// Contains rosidl action type support data. Actions are build based on services +/// (goal, result and cancel) and message (feedback and status). struct rosidl_action_type_support_t { const rosidl_service_type_support_t * goal_service_type_support; @@ -36,6 +38,12 @@ struct rosidl_action_type_support_t const rosidl_message_type_support_t * status_message_type_support; }; +/// Macro to get the action type support. +/* + * \param PkgName name of the package that contains the action + * \param Name action name + * \return a rosidl_action_type_support_t struct if founded, otherwise NULL. + */ #define ROSIDL_GET_ACTION_TYPE_SUPPORT(PkgName, Name) \ ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( \ rosidl_typesupport_c, PkgName, action, Name)() diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/message_bounds_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/message_bounds_struct.h index 731ca7a20..4b73197e9 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/message_bounds_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/message_bounds_struct.h @@ -28,21 +28,50 @@ typedef struct rosidl_message_bounds_t rosidl_message_bounds_t; typedef const rosidl_message_bounds_t * (* rosidl_message_bounds_handle_function)( const rosidl_message_bounds_t *, const char *); +/// Contains rosidl message bounds data struct rosidl_message_bounds_t { + /// String identifier for the type_support. const char * typesupport_identifier; + /// pointer to type support handle function const void * data; + /// pointer to type support handle function. rosidl_message_bounds_handle_function func; }; +/// Get the message bounds handle specific to this identifier. +/** + * If the identifier is the same as this handle's identifier, then the handle is + * simply returned, otherwise it returns zero. + * + * \param handle Handle to service type support + * \param identifier The identifier to get the handle for + * \return The associated message bounds handle if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_bounds_t * get_message_bounds_handle( const rosidl_message_bounds_t * handle, const char * identifier); +/// Get the message bounds handle function specific to this identifier. +/** + * If the identifier is the same as this handle funtion's identifier, then the handle is + * simply returned, otherwise it returns zero. + * + * \param handle Handle to service type support + * \param identifier The identifier to get the handle function for + * \return The associated message bounds handle function if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_bounds_t * get_message_bounds_handle_function( const rosidl_message_bounds_t * handle, const char * identifier); +/// Macro to get the message bounds. +/* + * \param PkgName Name of the package that contains the message + * \param MsgSubfolder name of the subfolder (foe example: msg) + * \param MsgName message name + * \return a rosidl_message_bounds_t struct if founded, otherwise NULL. + */ #define ROSIDL_GET_MSG_BOUNDS(PkgName, MsgSubfolder, MsgName) \ ROSIDL_BOUNDS_INTERFACE__MESSAGE_SYMBOL_NAME( \ rosidl_typesupport_c, PkgName, MsgSubfolder, MsgName)() diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h index da000672e..0b7a09ecb 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h @@ -28,21 +28,50 @@ typedef struct rosidl_message_type_support_t rosidl_message_type_support_t; typedef const rosidl_message_type_support_t * (* rosidl_message_typesupport_handle_function)( const rosidl_message_type_support_t *, const char *); +/// Contains rosidl message type support data struct rosidl_message_type_support_t { + /// String identifier for the type_support. const char * typesupport_identifier; + /// pointer to type support handle function const void * data; + /// pointer to type support handle function rosidl_message_typesupport_handle_function func; }; +/// Get the message type support handle specific to this identifier. +/** + * If the identifier is the same as this handle's typesupport_identifier, then the handle is + * simply returned, otherwise it returns zero. + * + * \param handle Handle to message type support + * \param identifier The typesupport identifier to get the handle function for + * \return The associated message typesupport handle if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_type_support_t * get_message_typesupport_handle( const rosidl_message_type_support_t * handle, const char * identifier); +// Get the message type support handle function specific to this identifier. +/** + * If the identifier is the same as this handle's typesupport_identifier, then the handle is + * simply returned, otherwise it returns NULL. + * + * \param handle Handle to message type support + * \param identifier The typesupport identifier to get the handle function for + * \return The associated message typesupport handle if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_type_support_t * get_message_typesupport_handle_function( const rosidl_message_type_support_t * handle, const char * identifier); +/// Macro to get the message typesupport +/* + * \param PkgName Name of the package that contains the message + * \param MsgSubfolder name of the subfolder (foe example: msg) + * \param MsgName message name + * \return a rosidl_message_type_support_t struct if founded, otherwise NULL. + */ #define ROSIDL_GET_MSG_TYPE_SUPPORT(PkgName, MsgSubfolder, MsgName) \ ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME( \ rosidl_typesupport_c, PkgName, MsgSubfolder, MsgName)() diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h index d240c3828..9319a9612 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h @@ -29,21 +29,50 @@ typedef struct rosidl_service_type_support_t rosidl_service_type_support_t; typedef const rosidl_service_type_support_t * (* rosidl_service_typesupport_handle_function)( const rosidl_service_type_support_t *, const char *); +/// Contains rosidl service type support data struct rosidl_service_type_support_t { + /// String identifier for the type_support. const char * typesupport_identifier; + /// pointer to type support handle function const void * data; + /// pointer to type support handle function rosidl_service_typesupport_handle_function func; }; +/// Get the service type support handle specific to this identifier. +/** + * If the identifier is the same as this handle's typesupport_identifier, then the handle is + * simply returned, otherwise it returns zero. + * + * \param handle Handle to service type support + * \param identifier The typesupport identifier to get the handle function for + * \return The associated message typesupport handle if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_service_type_support_t * get_service_typesupport_handle( const rosidl_service_type_support_t * handle, const char * identifier); +/// Get the service type support handle function specific to this identifier. +/** + * If the identifier is the same as this handle's typesupport_identifier, then the handle is + * simply returned, otherwise it returns zero. + * + * \param handle Handle to service type support + * \param identifier The typesupport identifier to get the handle function for + * \return The associated message typesupport handle if found, otherwise NULL + */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_service_type_support_t * get_service_typesupport_handle_function( const rosidl_service_type_support_t * handle, const char * identifier); +/// Macro to get the service typesupport +/* + * \param PkgName Name of the package that contains the service + * \param SrvSubfolder name of the subfolder (for example: srv) + * \param SrvName service name + * \return a rosidl_service_type_support_t struct if founded, otherwise NULL. + */ #define ROSIDL_GET_SRV_TYPE_SUPPORT(PkgName, SrvSubfolder, SrvName) \ ROSIDL_TYPESUPPORT_INTERFACE__SERVICE_SYMBOL_NAME( \ rosidl_typesupport_c, PkgName, SrvSubfolder, SrvName)() From 1f6add1d87411611e48be13b81c6a0d2664abe1b Mon Sep 17 00:00:00 2001 From: ahcorde Date: Tue, 28 Apr 2020 12:09:44 +0200 Subject: [PATCH 2/6] Added feedback Signed-off-by: ahcorde --- .../action_type_support_struct.h | 10 ++++++---- .../message_type_support_struct.h | 20 +++++++++---------- .../include/rosidl_runtime_c/sequence_bound.h | 17 ++++++++-------- .../service_type_support_struct.h | 18 ++++++++--------- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h index 0de6dd586..c41e21544 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h @@ -27,8 +27,10 @@ extern "C" typedef struct rosidl_action_type_support_t rosidl_action_type_support_t; -/// Contains rosidl action type support data. Actions are build based on services -/// (goal, result and cancel) and message (feedback and status). +/// Contains rosidl action type support data. +/* + * Actions are build based on services(goal, result and cancel) and message (feedback and status). + */ struct rosidl_action_type_support_t { const rosidl_service_type_support_t * goal_service_type_support; @@ -38,11 +40,11 @@ struct rosidl_action_type_support_t const rosidl_message_type_support_t * status_message_type_support; }; -/// Macro to get the action type support. +/// Get the action type support given a provided action and package. /* * \param PkgName name of the package that contains the action * \param Name action name - * \return a rosidl_action_type_support_t struct if founded, otherwise NULL. + * \return a rosidl_action_type_support_t struct if found, otherwise NULL. */ #define ROSIDL_GET_ACTION_TYPE_SUPPORT(PkgName, Name) \ ROSIDL_TYPESUPPORT_INTERFACE__ACTION_SYMBOL_NAME( \ diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h index 0b7a09ecb..b5edc9a8b 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h @@ -33,20 +33,19 @@ struct rosidl_message_type_support_t { /// String identifier for the type_support. const char * typesupport_identifier; - /// pointer to type support handle function + /// Pointer to type support handle function const void * data; - /// pointer to type support handle function rosidl_message_typesupport_handle_function func; }; /// Get the message type support handle specific to this identifier. /** - * If the identifier is the same as this handle's typesupport_identifier, then the handle is - * simply returned, otherwise it returns zero. + * The handle's message typesupport identifier function is returned or if the parameters are NULL + * then an assert will happen. * * \param handle Handle to message type support * \param identifier The typesupport identifier to get the handle function for - * \return The associated message typesupport handle if found, otherwise NULL + * \return The associated message typesupport handle function. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_type_support_t * get_message_typesupport_handle( @@ -54,21 +53,22 @@ const rosidl_message_type_support_t * get_message_typesupport_handle( // Get the message type support handle function specific to this identifier. /** - * If the identifier is the same as this handle's typesupport_identifier, then the handle is - * simply returned, otherwise it returns NULL. + * If the identifier is the same as this handle's typesupport_identifier the handle is simply + * returned or if the parameters are NULL then an assert will happen. * * \param handle Handle to message type support * \param identifier The typesupport identifier to get the handle function for - * \return The associated message typesupport handle if found, otherwise NULL + * \return if the identifier match's the handle's identifier then the handle's function + * is returned. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_message_type_support_t * get_message_typesupport_handle_function( const rosidl_message_type_support_t * handle, const char * identifier); -/// Macro to get the message typesupport +/// Get the message type support given a provided action and package. /* * \param PkgName Name of the package that contains the message - * \param MsgSubfolder name of the subfolder (foe example: msg) + * \param MsgSubfolder name of the subfolder (for example: msg) * \param MsgName message name * \return a rosidl_message_type_support_t struct if founded, otherwise NULL. */ diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h b/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h index 4843d4c7b..bce6ab5d7 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/sequence_bound.h @@ -32,19 +32,19 @@ struct rosidl_runtime_c__Sequence__bound { /// String identifier for the type_support. const char * typesupport_identifier; - /// pointer to type support handle function + /// Pointer to type support handle function const void * data; rosidl_runtime_c__bound_handle_function func; }; /// Get the message bounds handle specific to this identifier. /** - * If the identifier is the same as this handle's identifier, then the handle is - * simply returned, otherwise it returns zero. + * The handle's sequence bound is simply returned or if the parameters are NULL then an assert + * will happen. * * \param handle Handle to service type support * \param identifier The identifier to get the handle for - * \return The associated message bounds handle if found, otherwise NULL + * \return The associated sequence bound handle function. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle( @@ -52,18 +52,19 @@ const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle( /// Get the message bounds handle function specific to this identifier. /** - * If the identifier is the same as this handle funtion's identifier, then the handle is - * simply returned, otherwise it returns zero. + * If the identifier is the same as this handle function's identifier the handle is simply returned + * or if the parameters are NULL then an assert will happen. * * \param handle Handle to service type support * \param identifier The identifier to get the handle function for - * \return The associated message bounds handle function if found, otherwise NULL + * \return if the identifier match's the handle's identifier then the handle's function + * is returned. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_runtime_c__Sequence__bound * get_sequence_bound_handle_function( const rosidl_runtime_c__Sequence__bound * handle, const char * identifier); -/// Macro to get the message bounds. +/// Get the sequence bounds given a provided action and package. /* * \param PkgName Name of the package that contains the message * \param MsgSubfolder name of the subfolder (foe example: msg) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h index 9319a9612..bc9d1153e 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h @@ -34,20 +34,19 @@ struct rosidl_service_type_support_t { /// String identifier for the type_support. const char * typesupport_identifier; - /// pointer to type support handle function + /// Pointer to type support handle function const void * data; - /// pointer to type support handle function rosidl_service_typesupport_handle_function func; }; /// Get the service type support handle specific to this identifier. /** - * If the identifier is the same as this handle's typesupport_identifier, then the handle is - * simply returned, otherwise it returns zero. + * The handle's message typesupport identifier function is returned or if the parameters are NULL + * then an assert will happen. * * \param handle Handle to service type support * \param identifier The typesupport identifier to get the handle function for - * \return The associated message typesupport handle if found, otherwise NULL + * \return The associated service typesupport handle function. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_service_type_support_t * get_service_typesupport_handle( @@ -55,18 +54,19 @@ const rosidl_service_type_support_t * get_service_typesupport_handle( /// Get the service type support handle function specific to this identifier. /** - * If the identifier is the same as this handle's typesupport_identifier, then the handle is - * simply returned, otherwise it returns zero. +* If the identifier is the same as this handle's typesupport_identifier the handle is simply +* returned or if the parameters are NULL then an assert will happen. * * \param handle Handle to service type support * \param identifier The typesupport identifier to get the handle function for - * \return The associated message typesupport handle if found, otherwise NULL + * \return if the identifier match's the handle's identifier then the handle's function + * is returned. */ ROSIDL_GENERATOR_C_PUBLIC const rosidl_service_type_support_t * get_service_typesupport_handle_function( const rosidl_service_type_support_t * handle, const char * identifier); -/// Macro to get the service typesupport +/// Get the service type support given a provided action and package. /* * \param PkgName Name of the package that contains the service * \param SrvSubfolder name of the subfolder (for example: srv) From d585e9027c37a03a01e9f7495673d5e5a65f79fd Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 29 Apr 2020 17:44:54 +0200 Subject: [PATCH 3/6] Comment string functions Signed-off-by: ahcorde --- .../rosidl_runtime_c/string_functions.h | 76 ++++++++++++- .../rosidl_runtime_c/u16string_functions.h | 103 ++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h index f2a7db0e5..55c0baca3 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h @@ -26,44 +26,118 @@ extern "C" #endif /// Initialize a rosidl_runtime_c__String structure. -/* The contents of rosidl_runtime_c__String are initialized to a single null character ('\0'). +/* + * The contents of rosidl_runtime_c__String are initialized to a single null character ('\0'). * The string initially has size 0 and capacity 1. * Size represents the size of the contents of the string, while capacity represents the overall * storage of the string (counting the null terminator). * All strings must be null-terminated. + * The rosidl_runtime_c__String structure should be deallocated using the given function + * rosidl_runtime_c__String__fini() when it is no longer needed. + * + * \param[inout] str a pointer to a rosidl_runtime_c__String structure + * \return true if successful, false if the passed string pointer is null + * or the memory allocation failed */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__String__init(rosidl_runtime_c__String * str); +/// Deallocate the memory of the rosidl_runtime_c__String structure. +/* +* Calling the function with an already deallocated sequence is a no-op. +* +* \param[inout] str a pointer to a rosidl_runtime_c__String structure to be finalized +*/ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__String__fini(rosidl_runtime_c__String * str); +/// Assign the c string pointer of n characters to the rosidl_runtime_c__String structure. +/* + * + * This function returns `false` if memory cannot be allocated, + * if the input c string pointer is null or if the size is higher than SIZE_MAX. + * In both cases no error message is set. + * + * \param[inout] str a pointer to a string structure + * \param[in] value c string pointer to be assigned + * \param[in] n size of the value string + * \return true if successful, false if the passed string pointer is null + * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__String__assignn( rosidl_runtime_c__String * str, const char * value, size_t n); +/// Assign the c string pointer to the rosidl_runtime_c__String structure. +/* + * + * This function is identical to rosidl_runtime_c__String__assignn() except the length of the + * c string does not have to be given and therefore the c string must be null terminated. + * + * \see rosidl_runtime_c__String__assignn() + * + * \param[inout] str a pointer to a rosidl_runtime_c__String structure + * \param[in] value c string pointer to be assigned + * \return true if successful, false if the passed string pointer is null + * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__String__assign( rosidl_runtime_c__String * str, const char * value); +/// Initialize a rosidl_runtime_c__String__Sequence__init structure. +/* + * The rosidl_runtime_c__String__Sequence is initialized with the size passed to the function. + * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function + * rosidl_runtime_c__String__Sequence__fini() when it is no longer needed. + * + * \param[inout] sequence a pointer to a string sequence + * \param[in] size represents the size of the string sequence + * \return true if successful, false if the passed string pointer is null + * or the memory allocation failed + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__String__Sequence__init( rosidl_runtime_c__String__Sequence * sequence, size_t size); +/// Deallocate the memory of the string sequence structure. +/* + * Calling the function with an already deallocated sequence is a no-op. + * + * \param[inout] sequence a pointer to a string sequence to be finalized + */ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__String__Sequence__fini( rosidl_runtime_c__String__Sequence * sequence); +/// Create a rosidl_runtime_c__String__Sequence structure with a specific size. +/* + * The string sequence initially has size and capacity equal to the size argument passed to the + * function. + * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function + * rosidl_runtime_c__String__Sequence__destroy() when it is no longer needed. + * + * \param[in] size of the desired string sequence + * \return a string sequence if initialization was successfully, otherwise NULL. + */ ROSIDL_GENERATOR_C_PUBLIC rosidl_runtime_c__String__Sequence * rosidl_runtime_c__String__Sequence__create(size_t size); +/// Destroy a rosidl_runtime_c__String__Sequence structure. +/* + * Calling the function with an already deallocated sequence is a no-op. + * + * \param[inout] sequence a pointer to a string sequence to be finalized + */ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__String__Sequence__destroy( diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h index eddf29a73..b6989c6b9 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h @@ -31,53 +31,156 @@ extern "C" * Size represents the size of the contents of the string, while capacity represents the overall * storage of the string (counting the null terminator). * All strings must be null-terminated. + * The rosidl_runtime_c__U16String structure should be deallocated using the given function + * rosidl_runtime_c__U16String__fini() when it is no longer needed. + * + * \param[inout] str a pointer to a U16 string structure + * \return true if successful, false if the passed string pointer is null + * or the memory allocation failed */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__init(rosidl_runtime_c__U16String * str); +/// Deallocate the memory of the rosidl_runtime_c__U16String structure. +/* +* Calling the function with an already deallocated sequence is a no-op. +* +* \param[inout] str a pointer to a U16 string structure to be finalized +*/ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__U16String__fini(rosidl_runtime_c__U16String * str); +/// Assign the uint16_t value of n characters to the rosidl_runtime_c__U16String structure. +/* + * + * This function returns `false` if memory cannot be allocated, + * if the input uint16_t pointer is null or if the size is higher than SIZE_MAX. + * In both cases no error message is set. + * + * \param[inout] str a pointer to a U16 string structure + * \param[in] value uint16_t pointer to be assigned + * \param[in] n size of the value string + * \return true if successful, false if the passed string pointer is null + * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__assignn( rosidl_runtime_c__U16String * str, const uint16_t * value, size_t n); +/// Assign the c string pointer value of n characters to the rosidl_runtime_c__U16String structure. +/* + * + * This function is identical to rosidl_runtime_c__U16String__assignn() except the type of the + * value is c string pointer + * + * \see rosidl_runtime_c__U16String__assignn() + * + * \param[inout] str a pointer to a U16 string structure + * \param[in] value c string pointer to be assigned + * \param[in] n size of the value string + * \return true if successful, false if the passed string pointer is null + * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__assignn_from_char( rosidl_runtime_c__U16String * str, const char * value, size_t n); +/// Assign the uint16_t pointer to the rosidl_runtime_c__U16String structure. +/* + * + * This function is identical to rosidl_runtime_c__U16String__assignn() except the length of the + * uint16_t does not have to be given. + * + * \see rosidl_runtime_c__U16String__assignn() + * + * \param[inout] str a pointer to a rosidl_runtime_c__U16String structure + * \param[in] value to be assigned + * \return true if successful, false if the passed string pointer is null + * or if the passed value pointer is null or if the size is higher than SIZE_MAX + * or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__assign( rosidl_runtime_c__U16String * str, const uint16_t * value); +/// Get the length of the uint16_t pointer. +/* + * This function returns the length of the input value pointer. + * + * \param[in] value to calculate the length + * \return the size of the input value pointer or zero if the pointer is NULL + */ ROSIDL_GENERATOR_C_PUBLIC size_t rosidl_runtime_c__U16String__len(const uint16_t * value); +/// Resize the uint16_t pointer. +/* + * This function resize the input value pointer. + * + * \param[in] value to calculate the length + * \return true if successful, false if the passed string pointer is null + * or if the size is higher than SIZE_MAX or if the memory reallocation failed. + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__resize( rosidl_runtime_c__U16String * str, size_t n); +/// Initialize a U16 string sequence structure. +/* + * The rosidl_runtime_c__U16String__Sequence is initialized to the size passed to the function. + * The U16 string sequence structure should be deallocated using the given + * function rosidl_runtime_c__U16String__Sequence__fini() when it is no longer needed. + * + * \param[inout] sequence a pointer to a U16 string sequence structure + * \param[in] size represents the size of the U16 string + * \return true if successful, false if the passed string pointer is null + * or the memory allocation failed + */ ROSIDL_GENERATOR_C_PUBLIC bool rosidl_runtime_c__U16String__Sequence__init( rosidl_runtime_c__U16String__Sequence * sequence, size_t size); +/// Deallocate the memory of the string sequence structure. +/* + * Calling the function with an already deallocated sequence is a no-op. + * + * \param[inout] sequence a pointer to a U16 string to be finalized + */ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__U16String__Sequence__fini( rosidl_runtime_c__U16String__Sequence * sequence); +/// Create a U16 string sequence structure with a specific size. +/* + * The U16 string sequence initially has size and capacity equal to the size + * argument. + * The U16 string sequence structure should be deallocated using the given + * function rosidl_runtime_c__U16String__Sequence__destroy() when it is no longer needed. + * + * \param[in] size of the desired U16 string + * \return a U16 string sequence if initialization was successfully, otherwise NULL. + */ ROSIDL_GENERATOR_C_PUBLIC rosidl_runtime_c__U16String__Sequence * rosidl_runtime_c__U16String__Sequence__create(size_t size); +/// Destroy a U16 string sequence structure. +/* + * Calling the function with an already deallocated sequence is a no-op. + * + * \param[inout] sequence a pointer to a U16 string sequence to be finalized + */ ROSIDL_GENERATOR_C_PUBLIC void rosidl_runtime_c__U16String__Sequence__destroy( From 0487a6f34a4c98818d56ba6641fb4c4a55602e92 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 29 Apr 2020 18:29:48 +0200 Subject: [PATCH 4/6] Added feedback Signed-off-by: ahcorde --- .../include/rosidl_runtime_c/action_type_support_struct.h | 2 +- .../include/rosidl_runtime_c/message_type_support_struct.h | 3 ++- .../include/rosidl_runtime_c/service_type_support_struct.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h index c41e21544..801a771ed 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/action_type_support_struct.h @@ -29,7 +29,7 @@ typedef struct rosidl_action_type_support_t rosidl_action_type_support_t; /// Contains rosidl action type support data. /* - * Actions are build based on services(goal, result and cancel) and message (feedback and status). + * Actions are built based on services(goal, result and cancel) and message (feedback and status). */ struct rosidl_action_type_support_t { diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h index b5edc9a8b..c587e673b 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/message_type_support_struct.h @@ -33,8 +33,9 @@ struct rosidl_message_type_support_t { /// String identifier for the type_support. const char * typesupport_identifier; - /// Pointer to type support handle function + /// Pointer to the message type support library const void * data; + /// Pointer to the message type support handler function rosidl_message_typesupport_handle_function func; }; diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h index bc9d1153e..368c94f03 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/service_type_support_struct.h @@ -34,8 +34,9 @@ struct rosidl_service_type_support_t { /// String identifier for the type_support. const char * typesupport_identifier; - /// Pointer to type support handle function + /// Pointer to the service type support library const void * data; + /// Pointer to the service type support handler function rosidl_service_typesupport_handle_function func; }; From 5cdf0f43ffead12d1d1e2d93b12f9d109cc23de6 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Thu, 30 Apr 2020 10:04:57 +0200 Subject: [PATCH 5/6] Added feedback Signed-off-by: ahcorde --- .../include/rosidl_runtime_c/string_functions.h | 7 ++----- .../rosidl_runtime_c/u16string_functions.h | 17 +++++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h index 55c0baca3..9c6640e40 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h @@ -34,6 +34,7 @@ extern "C" * All strings must be null-terminated. * The rosidl_runtime_c__String structure should be deallocated using the given function * rosidl_runtime_c__String__fini() when it is no longer needed. + * Call this function with an already initialized string will leak memory. * * \param[inout] str a pointer to a rosidl_runtime_c__String structure * \return true if successful, false if the passed string pointer is null @@ -55,11 +56,6 @@ rosidl_runtime_c__String__fini(rosidl_runtime_c__String * str); /// Assign the c string pointer of n characters to the rosidl_runtime_c__String structure. /* - * - * This function returns `false` if memory cannot be allocated, - * if the input c string pointer is null or if the size is higher than SIZE_MAX. - * In both cases no error message is set. - * * \param[inout] str a pointer to a string structure * \param[in] value c string pointer to be assigned * \param[in] n size of the value string @@ -96,6 +92,7 @@ rosidl_runtime_c__String__assign( * The rosidl_runtime_c__String__Sequence is initialized with the size passed to the function. * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function * rosidl_runtime_c__String__Sequence__fini() when it is no longer needed. + * Call this function with an already initialized string sequence will leak memory. * * \param[inout] sequence a pointer to a string sequence * \param[in] size represents the size of the string sequence diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h index b6989c6b9..73d07979d 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h @@ -33,6 +33,7 @@ extern "C" * All strings must be null-terminated. * The rosidl_runtime_c__U16String structure should be deallocated using the given function * rosidl_runtime_c__U16String__fini() when it is no longer needed. + * Call this function with an already initialized U16 string will leak memory. * * \param[inout] str a pointer to a U16 string structure * \return true if successful, false if the passed string pointer is null @@ -54,13 +55,12 @@ rosidl_runtime_c__U16String__fini(rosidl_runtime_c__U16String * str); /// Assign the uint16_t value of n characters to the rosidl_runtime_c__U16String structure. /* - * * This function returns `false` if memory cannot be allocated, * if the input uint16_t pointer is null or if the size is higher than SIZE_MAX. * In both cases no error message is set. * * \param[inout] str a pointer to a U16 string structure - * \param[in] value uint16_t pointer to be assigned + * \param[in] value points to a sequence of 16 bit chars * \param[in] n size of the value string * \return true if successful, false if the passed string pointer is null * or if the passed value pointer is null or if the size is higher than SIZE_MAX @@ -73,14 +73,13 @@ rosidl_runtime_c__U16String__assignn( /// Assign the c string pointer value of n characters to the rosidl_runtime_c__U16String structure. /* - * * This function is identical to rosidl_runtime_c__U16String__assignn() except the type of the * value is c string pointer * * \see rosidl_runtime_c__U16String__assignn() * * \param[inout] str a pointer to a U16 string structure - * \param[in] value c string pointer to be assigned + * \param[in] value points to a sequence of 16 bit chars * \param[in] n size of the value string * \return true if successful, false if the passed string pointer is null * or if the passed value pointer is null or if the size is higher than SIZE_MAX @@ -93,14 +92,14 @@ rosidl_runtime_c__U16String__assignn_from_char( /// Assign the uint16_t pointer to the rosidl_runtime_c__U16String structure. /* - * * This function is identical to rosidl_runtime_c__U16String__assignn() except the length of the * uint16_t does not have to be given. + * rosidl_runtime_c__U16String__len() is being used to determine the length of the passed string. * * \see rosidl_runtime_c__U16String__assignn() * * \param[inout] str a pointer to a rosidl_runtime_c__U16String structure - * \param[in] value to be assigned + * \param[in] value points to a sequence of 16 bit chars * \return true if successful, false if the passed string pointer is null * or if the passed value pointer is null or if the size is higher than SIZE_MAX * or if the memory reallocation failed. @@ -114,7 +113,8 @@ rosidl_runtime_c__U16String__assign( /* * This function returns the length of the input value pointer. * - * \param[in] value to calculate the length + * \param[in] value points to a sequence of 16 bit chars for which the first null char is + * determined * \return the size of the input value pointer or zero if the pointer is NULL */ ROSIDL_GENERATOR_C_PUBLIC @@ -125,7 +125,7 @@ rosidl_runtime_c__U16String__len(const uint16_t * value); /* * This function resize the input value pointer. * - * \param[in] value to calculate the length + * \param[in] n the new size of the internal buffer * \return true if successful, false if the passed string pointer is null * or if the size is higher than SIZE_MAX or if the memory reallocation failed. */ @@ -139,6 +139,7 @@ rosidl_runtime_c__U16String__resize( * The rosidl_runtime_c__U16String__Sequence is initialized to the size passed to the function. * The U16 string sequence structure should be deallocated using the given * function rosidl_runtime_c__U16String__Sequence__fini() when it is no longer needed. + * Call this function with an already initialized U16 string sequence structure will leak memory. * * \param[inout] sequence a pointer to a U16 string sequence structure * \param[in] size represents the size of the U16 string From fe400595300e61ffeef3b156c244270339d7ef63 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Thu, 30 Apr 2020 19:49:36 +0200 Subject: [PATCH 6/6] Fixed wording Signed-off-by: ahcorde --- .../include/rosidl_runtime_c/string_functions.h | 6 ++++-- .../include/rosidl_runtime_c/u16string_functions.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h index 9c6640e40..72a0066ce 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/string_functions.h @@ -34,7 +34,8 @@ extern "C" * All strings must be null-terminated. * The rosidl_runtime_c__String structure should be deallocated using the given function * rosidl_runtime_c__String__fini() when it is no longer needed. - * Call this function with an already initialized string will leak memory. + * Calling this function with an already initialized U16 string sequence structure will leak + * memory. * * \param[inout] str a pointer to a rosidl_runtime_c__String structure * \return true if successful, false if the passed string pointer is null @@ -92,7 +93,8 @@ rosidl_runtime_c__String__assign( * The rosidl_runtime_c__String__Sequence is initialized with the size passed to the function. * The rosidl_runtime_c__String__Sequence structure should be deallocated using the given function * rosidl_runtime_c__String__Sequence__fini() when it is no longer needed. - * Call this function with an already initialized string sequence will leak memory. + * Calling this function with an already initialized U16 string sequence structure will leak + * memory. * * \param[inout] sequence a pointer to a string sequence * \param[in] size represents the size of the string sequence diff --git a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h index 73d07979d..4207fc47a 100644 --- a/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h +++ b/rosidl_runtime_c/include/rosidl_runtime_c/u16string_functions.h @@ -33,7 +33,8 @@ extern "C" * All strings must be null-terminated. * The rosidl_runtime_c__U16String structure should be deallocated using the given function * rosidl_runtime_c__U16String__fini() when it is no longer needed. - * Call this function with an already initialized U16 string will leak memory. + * Calling this function with an already initialized U16 string sequence structure will leak + * memory. * * \param[inout] str a pointer to a U16 string structure * \return true if successful, false if the passed string pointer is null @@ -139,7 +140,8 @@ rosidl_runtime_c__U16String__resize( * The rosidl_runtime_c__U16String__Sequence is initialized to the size passed to the function. * The U16 string sequence structure should be deallocated using the given * function rosidl_runtime_c__U16String__Sequence__fini() when it is no longer needed. - * Call this function with an already initialized U16 string sequence structure will leak memory. + * Calling this function with an already initialized U16 string sequence structure will leak + * memory. * * \param[inout] sequence a pointer to a U16 string sequence structure * \param[in] size represents the size of the U16 string