Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1900 Refactor byte_t to be a distinct type
Browse files Browse the repository at this point in the history
Signed-off-by: Ziad Mostafa <ziad.mostafa@apex.ai>
  • Loading branch information
zmostafa committed Feb 27, 2023
1 parent d51180d commit 213d661
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 11 deletions.
13 changes: 13 additions & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
- Remove `algorithm::uniqueMergeSortedContainers` from `algorithm.hpp`
- Move `std::string` conversion function to `iceoryx_dust` [\#1612](https://github.com/eclipse-iceoryx/iceoryx/issues/1612)
- The posix call `unlink` is directly used in `UnixDomainSocket` [\#1622](https://github.com/eclipse-iceoryx/iceoryx/issues/1622)
- Make iox::byte_t a distinct type [\#1900](https://github.com/eclipse-iceoryx/iceoryx/issues/1900)

**Workflow:**

Expand Down Expand Up @@ -1033,3 +1034,15 @@
// after
iox::access_rights foo { iox::perms::owner_all | iox::perms::group_read };
```
47. Renaming `byte_t` to `byte`
`byte` is not a simple type alias, now it is a distinct type like c++17 `std::byte`.
The type `byte` does not support any arithmetic operations nor has member functions.

```cpp
//before
iox::byte_t m_size;

//after
iox::byte m_size;
```

2 changes: 1 addition & 1 deletion iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
| class | internal | description |
|:---------------------:|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`type_traits` | | Extended support for evaluating types on compile-time. |
|`types` | | Declares essential building block types like `byte_t`. |
|`types` | | Declares essential building block types like `byte`. |
|`attributes` | | C++17 and C++20 attributes are sometimes available through compiler extensions. The attribute macros defined in here (like `IOX_FALLTHROUGH`, `IOX_MAYBE_UNUSED` ... ) make sure that we are able to use them if the compiler supports it. |
|`algorithm` | | Implements `min` and `max` for an arbitrary number of values of the same type. For instance `min(1,2,3,4,5);` |
|`size` | | Helper functions to determine the size in generic ways |
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/container/include/iox/uninitialized_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct ZeroedBuffer
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : required as low level building block, encapsulated in abstraction and not directly used
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, hicpp-avoid-c-arrays)
byte_t data[sizeof(ElementType)];
byte data[sizeof(ElementType)];
};
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : required as low level building block, encapsulated in abstraction and not directly used
Expand All @@ -57,7 +57,7 @@ struct NonZeroedBuffer
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : required as low level building block, encapsulated in abstraction and not directly used
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, hicpp-avoid-c-arrays)
byte_t data[sizeof(ElementType)];
byte data[sizeof(ElementType)];
};
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : required as low level building block, encapsulated in abstraction and not directly used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class storable_function<Capacity, signature<ReturnType, Args...>> final

// AXIVION Next Construct AutosarC++19_03-A18.1.1 : safe access is guaranteed since the c-array is wrapped inside the storable_function
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, hicpp-avoid-c-arrays)
byte_t m_storage[Capacity]; // storage for the callable
byte m_storage[Capacity]; // storage for the callable
void* m_callable{nullptr}; // pointer to stored type-erased callable
ReturnType (*m_invoker)(void*, Args&&...){nullptr}; // indirection to invoke the stored callable,
// nullptr if no callable is stored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace iox
{
namespace posix
{
using byte_t = uint8_t;

enum class SharedMemoryObjectError
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ namespace iox
/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/iceoryx_hoofs_types.hpp' instead")]]
namespace cxx
{
/// @deprecated use 'iox::byte_t' instead of 'iox::cxx::byte_t'
using iox::byte_t;
/// @deprecated use `iox::byte` instead of `iox::cxx::byte_t`
using byte_t = byte;

} // namespace cxx
namespace log
{
Expand Down
5 changes: 4 additions & 1 deletion iceoryx_hoofs/primitives/include/iox/iceoryx_hoofs_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@

namespace iox
{
using byte_t = uint8_t;

enum class byte : uint8_t
{
};

// AXIVION Next Construct AutosarC++19_03-M2.10.1 : log is a sensible namespace for a logger; furthermore it is in the
// iox namespace and when used as function the compiler will complain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ struct is_in_place_type<in_place_type<T>> : std::true_type
{
};

using byte_t = uint8_t;
template <typename TypeToCheck, typename T, typename... Targs>
struct does_contain_type
{
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/vocabulary/include/iox/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class optional final : public FunctionalInterface<optional<T>, T, void>
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : required as low level building block, encapsulated in abstraction and not directly used
// NOLINTNEXTLINE(hicpp-avoid-c-arrays, cppcoreguidelines-avoid-c-arrays)
byte_t data[sizeof(T)];
byte data[sizeof(T)];
};
// AXIVION Next Construct AutosarC++19_03-A1.1.1 : object size depends on template parameter and has to be taken care of at the specific template instantiation
element_t m_data;
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_hoofs/vocabulary/include/iox/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "iox/algorithm.hpp"
#include "iox/detail/variant_internal.hpp"
#include "iox/iceoryx_hoofs_types.hpp"

#include <cstdint>
#include <iostream>
Expand Down Expand Up @@ -265,7 +266,7 @@ class variant final
// AXIVION Next Construct AutosarC++19_03-M0.1.3 : data provides the actual storage and is accessed via m_storage since &m_storage.data = &m_storage
// AXIVION Next Construct AutosarC++19_03-A18.1.1 : safe access is guaranteed since the c-array is wrapped inside the variant class
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays)
internal::byte_t data[TYPE_SIZE];
iox::byte data[TYPE_SIZE];
};
storage_t m_storage{};
uint64_t m_type_index{INVALID_VARIANT_INDEX};
Expand Down

0 comments on commit 213d661

Please sign in to comment.