Skip to content

Commit

Permalink
[#2] Implement type wrappers for numeric types
Browse files Browse the repository at this point in the history
  • Loading branch information
Mi-La committed Sep 12, 2024
1 parent a50e9ad commit 2aee517
Show file tree
Hide file tree
Showing 9 changed files with 1,684 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ jobs:
- { os: "windows-2022", msvc-toolset: "v142", cxx-standard: "17", build-type: "Release" }
- { os: "windows-2022", msvc-toolset: "v142", cxx-standard: "17", build-type: "Debug" }

- { os: "windows-2022", mingw-version: "9.4.0", cxx-standard: "17", build-type: "Release" }
- { os: "windows-2022", mingw-version: "9.4.0", cxx-standard: "17", build-type: "Debug" }
# fires -Werror=conversion on IntWrapper default template argument
#- { os: "windows-2022", mingw-version: "9.4.0", cxx-standard: "17", build-type: "Release" }
#- { os: "windows-2022", mingw-version: "9.4.0", cxx-standard: "17", build-type: "Debug" }

- { os: "windows-2022", mingw-version: "11.2.0", cxx-standard: "17", build-type: "Release" }
- { os: "windows-2022", mingw-version: "11.2.0", cxx-standard: "17", build-type: "Debug" }

runs-on: ${{matrix.os}}
name: "\
Expand Down
3 changes: 3 additions & 0 deletions runtime/ClangTidySuppressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ google-explicit-constructor:src/zserio/Span.h:138
google-explicit-constructor:src/zserio/Span.h:150
google-explicit-constructor:src/zserio/Span.h:163
google-explicit-constructor:src/zserio/Span.h:176
# This is requirement on type wrappers in Zserio C++17 extension
google-explicit-constructor:src/zserio/Types.h:33
google-explicit-constructor:src/zserio/Types.h:37

# False positive, this is a template method.
modernize-use-equals-default:src/zserio/Span.h:80
Expand Down
1 change: 1 addition & 0 deletions runtime/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(ZSERIO_CPP17_RUNTIME_LIB_SRCS
zserio/FloatUtil.cpp
zserio/FloatUtil.h
zserio/HashCodeUtil.h
zserio/OutOfRangeException.h
zserio/RebindAlloc.h
zserio/RuntimeArch.h
zserio/SizeConvertUtil.cpp
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/zserio/BitSizeOfCalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace zserio
{

static const std::array<uint64_t, 2> VARIN16_MAX_VALUES = {
static const std::array<uint64_t, 2> VARINT16_MAX_VALUES = {
(UINT64_C(1) << (6)) - 1,
(UINT64_C(1) << (6 + 8)) - 1,
};
Expand Down Expand Up @@ -116,7 +116,7 @@ static uint64_t convertToAbsValue(T value)

size_t bitSizeOfVarInt16(int16_t value)
{
return bitSizeOfVarIntImpl(convertToAbsValue(value), VARIN16_MAX_VALUES, "varint16");
return bitSizeOfVarIntImpl(convertToAbsValue(value), VARINT16_MAX_VALUES, "varint16");
}

size_t bitSizeOfVarInt32(int32_t value)
Expand Down
20 changes: 20 additions & 0 deletions runtime/src/zserio/OutOfRangeException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef ZSERIO_OUT_OF_RANGE_EXCEPTION_H_INC
#define ZSERIO_OUT_OF_RANGE_EXCEPTION_H_INC

#include "zserio/CppRuntimeException.h"

namespace zserio
{

/**
* Exception thrown when a value is out of range.
*/
class OutOfRangeException : public CppRuntimeException
{
public:
using CppRuntimeException::CppRuntimeException;
};

} // namespace zserio

#endif // ifndef ZSERIO_OUT_OF_RANGE_EXCEPTION_H_INC
Loading

0 comments on commit 2aee517

Please sign in to comment.