From 576b204d245ade68c2bb3b1dcd67c15948d774f6 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Mon, 13 Jan 2025 15:39:41 +0100 Subject: [PATCH] [#458] Adjust language bindings --- .../cxx/include/iox2/enum_translation.hpp | 115 ++++++++---------- .../cxx/include/iox2/node_failure_enums.hpp | 2 + iceoryx2-ffi/ffi/src/api/node.rs | 3 + iceoryx2/src/node/mod.rs | 2 +- 4 files changed, 56 insertions(+), 66 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp b/iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp index 1a3d28631..fd7d21262 100644 --- a/iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp @@ -53,9 +53,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::SemanticStringError value) noexcept - -> iox2_semantic_string_error_e { +constexpr auto from( + const iox2::SemanticStringError value) noexcept -> iox2_semantic_string_error_e { switch (value) { case iox2::SemanticStringError::InvalidContent: return iox2_semantic_string_error_e_INVALID_CONTENT; @@ -86,8 +85,8 @@ constexpr auto from(const int value) noexcept -> iox2::S } template <> -constexpr auto from(const iox2::ServiceType value) noexcept - -> iox2_service_type_e { +constexpr auto +from(const iox2::ServiceType value) noexcept -> iox2_service_type_e { switch (value) { case iox2::ServiceType::Ipc: return iox2_service_type_e_IPC; @@ -112,9 +111,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::NodeCreationFailure value) noexcept - -> iox2_node_creation_failure_e { +constexpr auto from( + const iox2::NodeCreationFailure value) noexcept -> iox2_node_creation_failure_e { switch (value) { case iox2::NodeCreationFailure::InsufficientPermissions: return iox2_node_creation_failure_e_INSUFFICIENT_PERMISSIONS; @@ -145,9 +143,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::CallbackProgression value) noexcept - -> iox2_callback_progression_e { +constexpr auto from( + const iox2::CallbackProgression value) noexcept -> iox2_callback_progression_e { switch (value) { case iox2::CallbackProgression::Continue: return iox2_callback_progression_e_CONTINUE; @@ -261,9 +258,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::ServiceDetailsError value) noexcept - -> iox2_service_details_error_e { +constexpr auto from( + const iox2::ServiceDetailsError value) noexcept -> iox2_service_details_error_e { switch (value) { case iox2::ServiceDetailsError::FailedToOpenStaticServiceInfo: return iox2_service_details_error_e_FAILED_TO_OPEN_STATIC_SERVICE_INFO; @@ -348,9 +344,8 @@ constexpr auto from(const int value) noexcept } template <> -constexpr auto -from(const iox2::EventOpenOrCreateError value) noexcept - -> iox2_event_open_or_create_error_e { +constexpr auto from( + const iox2::EventOpenOrCreateError value) noexcept -> iox2_event_open_or_create_error_e { switch (value) { case iox2::EventOpenOrCreateError::OpenDoesNotExist: return iox2_event_open_or_create_error_e_O_DOES_NOT_EXIST; @@ -501,9 +496,8 @@ constexpr auto from(const int value) noexcept -> io } template <> -constexpr auto -from(const iox2::EventCreateError value) noexcept - -> iox2_event_open_or_create_error_e { +constexpr auto from( + const iox2::EventCreateError value) noexcept -> iox2_event_open_or_create_error_e { switch (value) { case iox2::EventCreateError::InsufficientPermissions: return iox2_event_open_or_create_error_e_C_INSUFFICIENT_PERMISSIONS; @@ -677,14 +671,15 @@ constexpr auto from -inline auto from(const iox2::PublishSubscribeOpenError value) noexcept - -> const char* { +inline auto +from(const iox2::PublishSubscribeOpenError value) noexcept -> const + char* { return iox2_pub_sub_open_or_create_error_string(iox::into(value)); } template <> -constexpr auto from(const int value) noexcept - -> iox2::PublishSubscribeCreateError { +constexpr auto +from(const int value) noexcept -> iox2::PublishSubscribeCreateError { const auto error = static_cast(value); switch (error) { case iox2_pub_sub_open_or_create_error_e_C_SERVICE_IN_CORRUPTED_STATE: @@ -730,8 +725,9 @@ constexpr auto from -inline auto from(const iox2::PublishSubscribeCreateError value) noexcept - -> const char* { +inline auto +from(const iox2::PublishSubscribeCreateError value) noexcept -> const + char* { return iox2_pub_sub_open_or_create_error_string(iox::into(value)); } @@ -795,9 +791,8 @@ constexpr auto from -inline auto -from(const iox2::PublishSubscribeOpenOrCreateError value) noexcept - -> const char* { +inline auto from( + const iox2::PublishSubscribeOpenOrCreateError value) noexcept -> const char* { return iox2_pub_sub_open_or_create_error_string(iox::into(value)); } @@ -813,9 +808,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::NotifierCreateError value) noexcept - -> iox2_notifier_create_error_e { +constexpr auto from( + const iox2::NotifierCreateError value) noexcept -> iox2_notifier_create_error_e { switch (value) { case iox2::NotifierCreateError::ExceedsMaxSupportedNotifiers: return iox2_notifier_create_error_e_EXCEEDS_MAX_SUPPORTED_NOTIFIERS; @@ -844,9 +838,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::ListenerCreateError value) noexcept - -> iox2_listener_create_error_e { +constexpr auto from( + const iox2::ListenerCreateError value) noexcept -> iox2_listener_create_error_e { switch (value) { case iox2::ListenerCreateError::ExceedsMaxSupportedListeners: return iox2_listener_create_error_e_EXCEEDS_MAX_SUPPORTED_LISTENERS; @@ -879,9 +872,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::NotifierNotifyError value) noexcept - -> iox2_notifier_notify_error_e { +constexpr auto from( + const iox2::NotifierNotifyError value) noexcept -> iox2_notifier_notify_error_e { switch (value) { case iox2::NotifierNotifyError::EventIdOutOfBounds: return iox2_notifier_notify_error_e_EVENT_ID_OUT_OF_BOUNDS; @@ -949,9 +941,8 @@ constexpr auto from(const int value) noexcept - } template <> -constexpr auto -from(const iox2::PublisherCreateError value) noexcept - -> iox2_publisher_create_error_e { +constexpr auto from( + const iox2::PublisherCreateError value) noexcept -> iox2_publisher_create_error_e { switch (value) { case iox2::PublisherCreateError::ExceedsMaxSupportedPublishers: return iox2_publisher_create_error_e_EXCEEDS_MAX_SUPPORTED_PUBLISHERS; @@ -982,9 +973,8 @@ constexpr auto from(const int value) noexcept } template <> -constexpr auto -from(const iox2::SubscriberCreateError value) noexcept - -> iox2_subscriber_create_error_e { +constexpr auto from( + const iox2::SubscriberCreateError value) noexcept -> iox2_subscriber_create_error_e { switch (value) { case iox2::SubscriberCreateError::BufferSizeExceedsMaxSupportedBufferSizeOfService: return iox2_subscriber_create_error_e_BUFFER_SIZE_EXCEEDS_MAX_SUPPORTED_BUFFER_SIZE_OF_SERVICE; @@ -1025,9 +1015,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::PublisherSendError value) noexcept - -> iox2_publisher_send_error_e { +constexpr auto from( + const iox2::PublisherSendError value) noexcept -> iox2_publisher_send_error_e { switch (value) { case iox2::PublisherSendError::ConnectionBrokenSincePublisherNoLongerExists: return iox2_publisher_send_error_e_CONNECTION_BROKEN_SINCE_PUBLISHER_NO_LONGER_EXISTS; @@ -1069,9 +1058,8 @@ constexpr auto from(const int value) noexcept } template <> -constexpr auto -from(const iox2::SubscriberReceiveError value) noexcept - -> iox2_subscriber_receive_error_e { +constexpr auto from( + const iox2::SubscriberReceiveError value) noexcept -> iox2_subscriber_receive_error_e { switch (value) { case iox2::SubscriberReceiveError::FailedToEstablishConnection: return iox2_subscriber_receive_error_e_FAILED_TO_ESTABLISH_CONNECTION; @@ -1108,9 +1096,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::PublisherLoanError value) noexcept - -> iox2_publisher_loan_error_e { +constexpr auto from( + const iox2::PublisherLoanError value) noexcept -> iox2_publisher_loan_error_e { switch (value) { case iox2::PublisherLoanError::ExceedsMaxLoanedSamples: return iox2_publisher_loan_error_e_EXCEEDS_MAX_LOANED_SAMPLES; @@ -1262,9 +1249,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::ConfigCreationError value) noexcept - -> iox2_config_creation_error_e { +constexpr auto from( + const iox2::ConfigCreationError value) noexcept -> iox2_config_creation_error_e { switch (value) { case iox2::ConfigCreationError::FailedToOpenConfigFile: return iox2_config_creation_error_e_FAILED_TO_OPEN_CONFIG_FILE; @@ -1335,9 +1321,8 @@ constexpr auto from(const int value) noexcept -> } template <> -constexpr auto -from(const iox2::WaitSetCreateError value) noexcept - -> iox2_waitset_create_error_e { +constexpr auto from( + const iox2::WaitSetCreateError value) noexcept -> iox2_waitset_create_error_e { switch (value) { case iox2::WaitSetCreateError::InternalError: return iox2_waitset_create_error_e_INTERNAL_ERROR; @@ -1401,9 +1386,8 @@ constexpr auto from(const int value) noexcept } template <> -constexpr auto -from(const iox2::WaitSetAttachmentError value) noexcept - -> iox2_waitset_attachment_error_e { +constexpr auto from( + const iox2::WaitSetAttachmentError value) noexcept -> iox2_waitset_attachment_error_e { switch (value) { case iox2::WaitSetAttachmentError::AlreadyAttached: return iox2_waitset_attachment_error_e_ALREADY_ATTACHED; @@ -1466,9 +1450,8 @@ inline auto from(const iox2::WaitSetRunError } template <> -constexpr auto -from(const iox2::SignalHandlingMode value) noexcept - -> iox2_signal_handling_mode_e { +constexpr auto from( + const iox2::SignalHandlingMode value) noexcept -> iox2_signal_handling_mode_e { switch (value) { case iox2::SignalHandlingMode::Disabled: return iox2_signal_handling_mode_e_DISABLED; @@ -1519,6 +1502,8 @@ constexpr auto from(const int value) noexcept -> return iox2::NodeCleanupFailure::InternalError; case iox2_node_cleanup_failure_e_INSUFFICIENT_PERMISSIONS: return iox2::NodeCleanupFailure::InsufficientPermissions; + case iox2_node_cleanup_failure_e_VERSION_MISMATCH: + return iox2::NodeCleanupFailure::VersionMismatch; } IOX_UNREACHABLE(); diff --git a/iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp b/iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp index f8d6ecf87..50e0384cd 100644 --- a/iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp @@ -46,6 +46,8 @@ enum class NodeCleanupFailure : uint8_t { /// The stale resources of a dead [`Node`] could not be removed since the process does not have sufficient /// permissions. InsufficientPermissions, + /// Trying to cleanup resources from a [`Node`] node which was using a different iceoryx2 version. + VersionMismatch, }; } // namespace iox2 diff --git a/iceoryx2-ffi/ffi/src/api/node.rs b/iceoryx2-ffi/ffi/src/api/node.rs index 8f5b85965..f323d6899 100644 --- a/iceoryx2-ffi/ffi/src/api/node.rs +++ b/iceoryx2-ffi/ffi/src/api/node.rs @@ -88,6 +88,8 @@ pub enum iox2_node_cleanup_failure_e { INTERNAL_ERROR, /// The stale resources of a dead node could not be removed since the process does not have sufficient permissions. INSUFFICIENT_PERMISSIONS, + /// Trying to cleanup resources from a dead node which was using a different iceoryx2 version. + VERSION_MISMATCH, } impl IntoCInt for NodeCleanupFailure { @@ -98,6 +100,7 @@ impl IntoCInt for NodeCleanupFailure { NodeCleanupFailure::InsufficientPermissions => { iox2_node_cleanup_failure_e::INSUFFICIENT_PERMISSIONS } + NodeCleanupFailure::VersionMismatch => iox2_node_cleanup_failure_e::VERSION_MISMATCH, }) as c_int } } diff --git a/iceoryx2/src/node/mod.rs b/iceoryx2/src/node/mod.rs index a909a372d..0053b20dd 100644 --- a/iceoryx2/src/node/mod.rs +++ b/iceoryx2/src/node/mod.rs @@ -269,7 +269,7 @@ pub enum NodeCleanupFailure { InternalError, /// The stale resources of a dead [`Node`] could not be removed since the process does not have sufficient permissions. InsufficientPermissions, - /// Trying to cleanup resources from a dead node which was using a different iceoryx2 version. + /// Trying to cleanup resources from a dead [`Node`] which was using a different iceoryx2 version. VersionMismatch, }