Skip to content

Commit

Permalink
[eclipse-iceoryx#458] Adjust language bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jan 13, 2025
1 parent 693c0c2 commit 576b204
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 66 deletions.
115 changes: 50 additions & 65 deletions iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ constexpr auto from<int, iox2::SemanticStringError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::SemanticStringError, iox2_semantic_string_error_e>(const iox2::SemanticStringError value) noexcept
-> iox2_semantic_string_error_e {
constexpr auto from<iox2::SemanticStringError, iox2_semantic_string_error_e>(
const iox2::SemanticStringError value) noexcept -> iox2_semantic_string_error_e {
switch (value) {
case iox2::SemanticStringError::InvalidContent:
return iox2_semantic_string_error_e_INVALID_CONTENT;
Expand Down Expand Up @@ -86,8 +85,8 @@ constexpr auto from<int, iox2::ServiceType>(const int value) noexcept -> iox2::S
}

template <>
constexpr auto from<iox2::ServiceType, iox2_service_type_e>(const iox2::ServiceType value) noexcept
-> iox2_service_type_e {
constexpr auto
from<iox2::ServiceType, iox2_service_type_e>(const iox2::ServiceType value) noexcept -> iox2_service_type_e {
switch (value) {
case iox2::ServiceType::Ipc:
return iox2_service_type_e_IPC;
Expand All @@ -112,9 +111,8 @@ constexpr auto from<int, iox2::NodeCreationFailure>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::NodeCreationFailure, iox2_node_creation_failure_e>(const iox2::NodeCreationFailure value) noexcept
-> iox2_node_creation_failure_e {
constexpr auto from<iox2::NodeCreationFailure, iox2_node_creation_failure_e>(
const iox2::NodeCreationFailure value) noexcept -> iox2_node_creation_failure_e {
switch (value) {
case iox2::NodeCreationFailure::InsufficientPermissions:
return iox2_node_creation_failure_e_INSUFFICIENT_PERMISSIONS;
Expand Down Expand Up @@ -145,9 +143,8 @@ constexpr auto from<int, iox2::CallbackProgression>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::CallbackProgression, iox2_callback_progression_e>(const iox2::CallbackProgression value) noexcept
-> iox2_callback_progression_e {
constexpr auto from<iox2::CallbackProgression, iox2_callback_progression_e>(
const iox2::CallbackProgression value) noexcept -> iox2_callback_progression_e {
switch (value) {
case iox2::CallbackProgression::Continue:
return iox2_callback_progression_e_CONTINUE;
Expand Down Expand Up @@ -261,9 +258,8 @@ constexpr auto from<int, iox2::ServiceDetailsError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::ServiceDetailsError, iox2_service_details_error_e>(const iox2::ServiceDetailsError value) noexcept
-> iox2_service_details_error_e {
constexpr auto from<iox2::ServiceDetailsError, iox2_service_details_error_e>(
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;
Expand Down Expand Up @@ -348,9 +344,8 @@ constexpr auto from<int, iox2::EventOpenOrCreateError>(const int value) noexcept
}

template <>
constexpr auto
from<iox2::EventOpenOrCreateError, iox2_event_open_or_create_error_e>(const iox2::EventOpenOrCreateError value) noexcept
-> iox2_event_open_or_create_error_e {
constexpr auto from<iox2::EventOpenOrCreateError, iox2_event_open_or_create_error_e>(
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;
Expand Down Expand Up @@ -501,9 +496,8 @@ constexpr auto from<int, iox2::EventCreateError>(const int value) noexcept -> io
}

template <>
constexpr auto
from<iox2::EventCreateError, iox2_event_open_or_create_error_e>(const iox2::EventCreateError value) noexcept
-> iox2_event_open_or_create_error_e {
constexpr auto from<iox2::EventCreateError, iox2_event_open_or_create_error_e>(
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;
Expand Down Expand Up @@ -677,14 +671,15 @@ constexpr auto from<iox2::PublishSubscribeOpenError, iox2_pub_sub_open_or_create
}

template <>
inline auto from<iox2::PublishSubscribeOpenError, const char*>(const iox2::PublishSubscribeOpenError value) noexcept
-> const char* {
inline auto
from<iox2::PublishSubscribeOpenError, const char*>(const iox2::PublishSubscribeOpenError value) noexcept -> const
char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

template <>
constexpr auto from<int, iox2::PublishSubscribeCreateError>(const int value) noexcept
-> iox2::PublishSubscribeCreateError {
constexpr auto
from<int, iox2::PublishSubscribeCreateError>(const int value) noexcept -> iox2::PublishSubscribeCreateError {
const auto error = static_cast<iox2_pub_sub_open_or_create_error_e>(value);
switch (error) {
case iox2_pub_sub_open_or_create_error_e_C_SERVICE_IN_CORRUPTED_STATE:
Expand Down Expand Up @@ -730,8 +725,9 @@ constexpr auto from<iox2::PublishSubscribeCreateError, iox2_pub_sub_open_or_crea
}

template <>
inline auto from<iox2::PublishSubscribeCreateError, const char*>(const iox2::PublishSubscribeCreateError value) noexcept
-> const char* {
inline auto
from<iox2::PublishSubscribeCreateError, const char*>(const iox2::PublishSubscribeCreateError value) noexcept -> const
char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

Expand Down Expand Up @@ -795,9 +791,8 @@ constexpr auto from<iox2::PublishSubscribeOpenOrCreateError, iox2_pub_sub_open_o
}

template <>
inline auto
from<iox2::PublishSubscribeOpenOrCreateError, const char*>(const iox2::PublishSubscribeOpenOrCreateError value) noexcept
-> const char* {
inline auto from<iox2::PublishSubscribeOpenOrCreateError, const char*>(
const iox2::PublishSubscribeOpenOrCreateError value) noexcept -> const char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

Expand All @@ -813,9 +808,8 @@ constexpr auto from<int, iox2::NotifierCreateError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::NotifierCreateError, iox2_notifier_create_error_e>(const iox2::NotifierCreateError value) noexcept
-> iox2_notifier_create_error_e {
constexpr auto from<iox2::NotifierCreateError, iox2_notifier_create_error_e>(
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;
Expand Down Expand Up @@ -844,9 +838,8 @@ constexpr auto from<int, iox2::ListenerCreateError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::ListenerCreateError, iox2_listener_create_error_e>(const iox2::ListenerCreateError value) noexcept
-> iox2_listener_create_error_e {
constexpr auto from<iox2::ListenerCreateError, iox2_listener_create_error_e>(
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;
Expand Down Expand Up @@ -879,9 +872,8 @@ constexpr auto from<int, iox2::NotifierNotifyError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::NotifierNotifyError, iox2_notifier_notify_error_e>(const iox2::NotifierNotifyError value) noexcept
-> iox2_notifier_notify_error_e {
constexpr auto from<iox2::NotifierNotifyError, iox2_notifier_notify_error_e>(
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;
Expand Down Expand Up @@ -949,9 +941,8 @@ constexpr auto from<int, iox2::PublisherCreateError>(const int value) noexcept -
}

template <>
constexpr auto
from<iox2::PublisherCreateError, iox2_publisher_create_error_e>(const iox2::PublisherCreateError value) noexcept
-> iox2_publisher_create_error_e {
constexpr auto from<iox2::PublisherCreateError, iox2_publisher_create_error_e>(
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;
Expand Down Expand Up @@ -982,9 +973,8 @@ constexpr auto from<int, iox2::SubscriberCreateError>(const int value) noexcept
}

template <>
constexpr auto
from<iox2::SubscriberCreateError, iox2_subscriber_create_error_e>(const iox2::SubscriberCreateError value) noexcept
-> iox2_subscriber_create_error_e {
constexpr auto from<iox2::SubscriberCreateError, iox2_subscriber_create_error_e>(
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;
Expand Down Expand Up @@ -1025,9 +1015,8 @@ constexpr auto from<int, iox2::PublisherSendError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::PublisherSendError, iox2_publisher_send_error_e>(const iox2::PublisherSendError value) noexcept
-> iox2_publisher_send_error_e {
constexpr auto from<iox2::PublisherSendError, iox2_publisher_send_error_e>(
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;
Expand Down Expand Up @@ -1069,9 +1058,8 @@ constexpr auto from<int, iox2::SubscriberReceiveError>(const int value) noexcept
}

template <>
constexpr auto
from<iox2::SubscriberReceiveError, iox2_subscriber_receive_error_e>(const iox2::SubscriberReceiveError value) noexcept
-> iox2_subscriber_receive_error_e {
constexpr auto from<iox2::SubscriberReceiveError, iox2_subscriber_receive_error_e>(
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;
Expand Down Expand Up @@ -1108,9 +1096,8 @@ constexpr auto from<int, iox2::PublisherLoanError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::PublisherLoanError, iox2_publisher_loan_error_e>(const iox2::PublisherLoanError value) noexcept
-> iox2_publisher_loan_error_e {
constexpr auto from<iox2::PublisherLoanError, iox2_publisher_loan_error_e>(
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;
Expand Down Expand Up @@ -1262,9 +1249,8 @@ constexpr auto from<int, iox2::ConfigCreationError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::ConfigCreationError, iox2_config_creation_error_e>(const iox2::ConfigCreationError value) noexcept
-> iox2_config_creation_error_e {
constexpr auto from<iox2::ConfigCreationError, iox2_config_creation_error_e>(
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;
Expand Down Expand Up @@ -1335,9 +1321,8 @@ constexpr auto from<int, iox2::WaitSetCreateError>(const int value) noexcept ->
}

template <>
constexpr auto
from<iox2::WaitSetCreateError, iox2_waitset_create_error_e>(const iox2::WaitSetCreateError value) noexcept
-> iox2_waitset_create_error_e {
constexpr auto from<iox2::WaitSetCreateError, iox2_waitset_create_error_e>(
const iox2::WaitSetCreateError value) noexcept -> iox2_waitset_create_error_e {
switch (value) {
case iox2::WaitSetCreateError::InternalError:
return iox2_waitset_create_error_e_INTERNAL_ERROR;
Expand Down Expand Up @@ -1401,9 +1386,8 @@ constexpr auto from<int, iox2::WaitSetAttachmentError>(const int value) noexcept
}

template <>
constexpr auto
from<iox2::WaitSetAttachmentError, iox2_waitset_attachment_error_e>(const iox2::WaitSetAttachmentError value) noexcept
-> iox2_waitset_attachment_error_e {
constexpr auto from<iox2::WaitSetAttachmentError, iox2_waitset_attachment_error_e>(
const iox2::WaitSetAttachmentError value) noexcept -> iox2_waitset_attachment_error_e {
switch (value) {
case iox2::WaitSetAttachmentError::AlreadyAttached:
return iox2_waitset_attachment_error_e_ALREADY_ATTACHED;
Expand Down Expand Up @@ -1466,9 +1450,8 @@ inline auto from<iox2::WaitSetRunError, const char*>(const iox2::WaitSetRunError
}

template <>
constexpr auto
from<iox2::SignalHandlingMode, iox2_signal_handling_mode_e>(const iox2::SignalHandlingMode value) noexcept
-> iox2_signal_handling_mode_e {
constexpr auto from<iox2::SignalHandlingMode, iox2_signal_handling_mode_e>(
const iox2::SignalHandlingMode value) noexcept -> iox2_signal_handling_mode_e {
switch (value) {
case iox2::SignalHandlingMode::Disabled:
return iox2_signal_handling_mode_e_DISABLED;
Expand Down Expand Up @@ -1519,6 +1502,8 @@ constexpr auto from<int, iox2::NodeCleanupFailure>(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();
Expand Down
2 changes: 2 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions iceoryx2-ffi/ffi/src/api/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down

0 comments on commit 576b204

Please sign in to comment.