Skip to content

Commit

Permalink
[eclipse-iceoryx#210] Use _ptr_mut instead of _mut_ptr in C API
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Sep 27, 2024
1 parent 3a6b384 commit 77ab786
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions iceoryx2-ffi/ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/ffi/src/api/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Config>,
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/ffi/src/api/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`]
///
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/ffi/src/api/node_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/ffi/src/api/publish_subscribe_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/ffi/src/api/service_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 77ab786

Please sign in to comment.