From 77ab7866d0f925befd1fc64d59756aa3b12770f2 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Sat, 28 Sep 2024 00:49:39 +0200 Subject: [PATCH] [#210] Use _ptr_mut instead of _mut_ptr in C API --- iceoryx2-ffi/ffi/README.md | 8 ++++---- iceoryx2-ffi/ffi/src/api/config.rs | 2 +- iceoryx2-ffi/ffi/src/api/node.rs | 2 +- iceoryx2-ffi/ffi/src/api/node_name.rs | 2 +- iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs | 2 +- iceoryx2-ffi/ffi/src/api/service_name.rs | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/iceoryx2-ffi/ffi/README.md b/iceoryx2-ffi/ffi/README.md index 946ec74e2..8e6e19136 100644 --- a/iceoryx2-ffi/ffi/README.md +++ b/iceoryx2-ffi/ffi/README.md @@ -11,8 +11,8 @@ `pub type iox2_foo_ref_h = *mut iox2_foo_ref_h_t` * immutable pointer to the Rust type end with a `_ptr` and are a type definition like `pub type iox2_foo_ptr = *const Foo` -* mutable pointer to the Rust type end with a `_mut_ptr` and are a type - definition like `pub type iox2_foo_mut_ptr = *mut Foo` +* mutable pointer to the Rust type end with a `_ptr_mut` and are a type + definition like `pub type iox2_foo_ptr_mut = *mut Foo` * `enums` ends with a `_e` ## Pattern for Type Erasure @@ -59,7 +59,7 @@ When the owning handle is passed to a function, the ownership of the underlying data is moved to that specific function and the `*_h` handles as well as all the `*_ptr` related to that handle are invalid. Accessing the handles or pointer afterwards lead to undefined behavior. The only exception are the `iox2_cast_*` -functions which can be used to get `_ptr` and `_mut_ptr` pointer the the Rust +functions which can be used to get `_ptr` and `_ptr_mut` pointer the the Rust type or a non-owning `_ref_h` handle to the C struct. The corresponding handle and pointer are defined like this @@ -73,7 +73,7 @@ pub type iox2_foo_ref_h = *mut iox2_foo_ref_h_t; pub type iox2_foo_ptr = *const Foo; -pub type iox2_foo_mut_ptr = *mut Foo; +pub type iox2_foo_ptr_mut = *mut Foo; ``` The `_h` handle is in general created by a builder and the `_ptr` pointer are in diff --git a/iceoryx2-ffi/ffi/src/api/config.rs b/iceoryx2-ffi/ffi/src/api/config.rs index 4874689de..f10a699f8 100644 --- a/iceoryx2-ffi/ffi/src/api/config.rs +++ b/iceoryx2-ffi/ffi/src/api/config.rs @@ -64,7 +64,7 @@ impl IntoCInt for ConfigCreationError { /// The immutable pointer to the underlying `Config` pub type iox2_config_ptr = *const Config; /// The mutable pointer to the underlying `Config` -pub type iox2_config_mut_ptr = *mut Config; +pub type iox2_config_ptr_mut = *mut Config; pub(super) struct ConfigOwner { pub(crate) value: ManuallyDrop, diff --git a/iceoryx2-ffi/ffi/src/api/node.rs b/iceoryx2-ffi/ffi/src/api/node.rs index 41bb9cc23..18bd15d92 100644 --- a/iceoryx2-ffi/ffi/src/api/node.rs +++ b/iceoryx2-ffi/ffi/src/api/node.rs @@ -150,7 +150,7 @@ pub enum iox2_node_state_e { /// The immutable pointer to the underlying `NodeId` pub type iox2_node_id_ptr = *const NodeId; /// The mutable pointer to the underlying `NodeId` -pub type iox2_node_id_mut_ptr = *mut NodeId; +pub type iox2_node_id_ptr_mut = *mut NodeId; /// The callback for [`iox2_node_list`] /// diff --git a/iceoryx2-ffi/ffi/src/api/node_name.rs b/iceoryx2-ffi/ffi/src/api/node_name.rs index 42afb3578..e5cc510ce 100644 --- a/iceoryx2-ffi/ffi/src/api/node_name.rs +++ b/iceoryx2-ffi/ffi/src/api/node_name.rs @@ -49,7 +49,7 @@ pub type iox2_node_name_ref_h = *mut iox2_node_name_ref_h_t; /// The immutable pointer to the underlying `NodeName` pub type iox2_node_name_ptr = *const NodeName; /// The mutable pointer to the underlying `NodeName` -pub type iox2_node_name_mut_ptr = *mut NodeName; +pub type iox2_node_name_ptr_mut = *mut NodeName; impl HandleToType for iox2_node_name_h { type Target = *mut iox2_node_name_t; diff --git a/iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs b/iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs index 600424ec6..9abd60489 100644 --- a/iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs +++ b/iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs @@ -59,7 +59,7 @@ pub type iox2_publish_subscribe_header_ref_h = *mut iox2_publish_subscribe_heade /// The immutable pointer to the underlying `publish_subscribe::Header` pub type iox2_publish_subscribe_header_ptr = *const Header; /// The mutable pointer to the underlying `publish_subscribe::Header` -pub type iox2_publish_subscribe_header_mut_ptr = *mut Header; +pub type iox2_publish_subscribe_header_ptr_mut = *mut Header; impl HandleToType for iox2_publish_subscribe_header_h { type Target = *mut iox2_publish_subscribe_header_t; diff --git a/iceoryx2-ffi/ffi/src/api/service_name.rs b/iceoryx2-ffi/ffi/src/api/service_name.rs index 129808101..8bd828b91 100644 --- a/iceoryx2-ffi/ffi/src/api/service_name.rs +++ b/iceoryx2-ffi/ffi/src/api/service_name.rs @@ -49,7 +49,7 @@ pub type iox2_service_name_ref_h = *mut iox2_service_name_ref_h_t; /// The immutable pointer to the underlying `ServiceName` pub type iox2_service_name_ptr = *const ServiceName; /// The mutable pointer to the underlying `ServiceName` -pub type iox2_service_name_mut_ptr = *mut ServiceName; +pub type iox2_service_name_ptr_mut = *mut ServiceName; impl HandleToType for iox2_service_name_h { type Target = *mut iox2_service_name_t;