Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into latest-submodules-dengket
  • Loading branch information
TingDaoK committed Oct 16, 2025
commit 15860552ba0b7a4381adc26fc32c014f78996a30
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ jobs:
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }}

windows-lean:
runs-on: windows-2025 # latest
env:
CFLAGS: "-DWIN32_LEAN_AND_MEAN"
CXXFLAGS: "-DWIN32_LEAN_AND_MEAN"
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.CRT_CI_ROLE }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}
- name: Build ${{ env.PACKAGE_NAME }} + consumers
run: |
python -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder.pyz')"
python builder.pyz build -p ${{ env.PACKAGE_NAME }}

windows-vc17:
runs-on: windows-2025 # latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.34.0
0.34.5
14 changes: 14 additions & 0 deletions include/aws/crt/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,19 @@ namespace Aws
struct IsSpecializationOf<Primary<Args...>, Primary> : std::true_type
{
};

/**
* Forms the logical conjunction of the type traits Args..., effectively performing a logical AND on the
* sequence of traits.
*/
template <typename... Args> struct Conjunction : std::true_type
{
};

template <typename Arg, typename... Args>
struct Conjunction<Arg, Args...> : std::conditional<Arg::value, Conjunction<Args...>, std::false_type>::type
{
};

} // namespace Crt
} // namespace Aws
929 changes: 567 additions & 362 deletions include/aws/crt/Variant.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/cbor/Cbor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ namespace Aws
*
*****************************************************/
CborDecoder::CborDecoder(ByteCursor src, Crt::Allocator *allocator) noexcept
: m_lastError(AWS_ERROR_SUCCESS)
{
m_decoder = aws_cbor_decoder_new(allocator, src);
}
Expand Down
9 changes: 8 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ add_test_case(OptionalEmplace)
add_test_case(OptionalCopyAndMoveSemantics)
add_test_case(VariantCompiles)
add_test_case(VariantConstructor)
add_test_case(VariantOperatorEquals)
add_test_case(VariantAssignmentOperator)
add_test_case(VariantWithMoveOnlyUnderlyingType)
add_test_case(VariantWithCopyOnlyUnderlyingType)
add_test_case(VariantWithNoDefaultConstructibleUnderlyingType)
add_test_case(VariantExceptionSafety_DefaultConstructor)
add_test_case(VariantExceptionSafety_MoveConstructor)
add_test_case(VariantExceptionSafety_CopyConstructor)
add_test_case(VariantEmplace)
add_test_case(VariantVisitor)
add_test_case(StreamTestCreateDestroyWrapper)
Expand Down Expand Up @@ -310,6 +316,7 @@ endif()

add_test_case(CborSanityTest)
add_test_case(CborTimeStampTest)
add_test_case(CborLastErrorTest)

generate_cpp_test_driver(${TEST_BINARY_NAME})

Expand Down
17 changes: 17 additions & 0 deletions tests/CborTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,20 @@ static int s_CborTimeStampTest(struct aws_allocator *allocator, void *ctx)
}

AWS_TEST_CASE(CborTimeStampTest, s_CborTimeStampTest)

static int s_CborLastErrorTest(struct aws_allocator *allocator, void *ctx)
{
/**
* Test the last error is initialzed correctly.
*/
(void)ctx;
{
ApiHandle apiHandle(allocator);
Cbor::CborDecoder decoder({});
ASSERT_INT_EQUALS(decoder.LastError(), AWS_ERROR_UNKNOWN);
}

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(CborLastErrorTest, s_CborLastErrorTest)
197 changes: 194 additions & 3 deletions tests/VariantTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
#include <aws/crt/Variant.h>
#include <aws/testing/aws_test_harness.h>

#if defined(_WIN32)
# define AWS_VARIANTTEST_WINDOWS_API __declspec(dllexport)
#else
# define AWS_VARIANTTEST_WINDOWS_API
#endif

const char *s_variant_test_str = "This is a string, that should be long enough to avoid small string optimizations";

static int s_VariantBasicOperandsCompile(struct aws_allocator *allocator, void *ctx)
Expand Down Expand Up @@ -170,7 +176,7 @@ static int s_VariantConstructor(struct aws_allocator *allocator, void *ctx)

AWS_TEST_CASE(VariantConstructor, s_VariantConstructor)

static int s_VariantOperatorEquals(struct aws_allocator *allocator, void *ctx)
static int s_VariantAssignmentOperator(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;
{
Expand Down Expand Up @@ -214,7 +220,192 @@ static int s_VariantOperatorEquals(struct aws_allocator *allocator, void *ctx)
return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantOperatorEquals, s_VariantOperatorEquals)
AWS_TEST_CASE(VariantAssignmentOperator, s_VariantAssignmentOperator)

// Test Variant with move-only underlying type.
// If it compiles, it's considered success.
static int s_VariantWithMoveOnlyUnderlyingType(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct MoveOnlyTestType
{
MoveOnlyTestType() = default;

MoveOnlyTestType(MoveOnlyTestType &&) = default;
MoveOnlyTestType &operator=(MoveOnlyTestType &&) = default;

MoveOnlyTestType(const MoveOnlyTestType &) = delete;
MoveOnlyTestType &operator=(const MoveOnlyTestType &) = delete;
};

using MoveOnlyVariant = Aws::Crt::Variant<MoveOnlyTestType>;

/* Regression test.
* The __declspec(dllexport) directive exports class member function on Windows platform. We enable it when
* building shared libraries. In the past, this directive caused msvc to generate special copy members for classes
* containing Crt::Variant with move-only underlying types, which led to compile-time errors. */
struct AWS_VARIANTTEST_WINDOWS_API MoveOnlyVariantTestResult
{
MoveOnlyVariant m_result;
};

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantWithMoveOnlyUnderlyingType, s_VariantWithMoveOnlyUnderlyingType)

// Test Variant with copy-only underlying type.
// If it compiles, it's considered success.
static int s_VariantWithCopyOnlyUnderlyingType(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct CopyOnlyTestType
{
CopyOnlyTestType() = default;

CopyOnlyTestType(CopyOnlyTestType &&) = default;
CopyOnlyTestType &operator=(CopyOnlyTestType &&) = default;

CopyOnlyTestType(const CopyOnlyTestType &) = delete;
CopyOnlyTestType &operator=(const CopyOnlyTestType &) = delete;
};

using CopyOnlyVariant = Aws::Crt::Variant<CopyOnlyTestType>;

/* Regression test.
* The __declspec(dllexport) directive exports class member function on Windows platform. We enable it when
* building shared libraries. In the past, this directive caused msvc to generate special copy members for classes
* containing Crt::Variant with copy-only underlying types, which led to compile-time errors. */
struct AWS_VARIANTTEST_WINDOWS_API CopyOnlyVariantTestResult
{
CopyOnlyVariant m_result;
};

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantWithCopyOnlyUnderlyingType, s_VariantWithCopyOnlyUnderlyingType)

// Test Variant with underlying type without default constructor.
// If it compiles, it's considered success.
static int s_VariantWithNoDefaultConstructibleUnderlyingType(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct NoDefaultConstructibleTestType
{
explicit NoDefaultConstructibleTestType(int) {}
NoDefaultConstructibleTestType() = delete;
};

using NoDefaultConstructibleVariant = Aws::Crt::Variant<NoDefaultConstructibleTestType>;

struct AWS_VARIANTTEST_WINDOWS_API NoDefaultConstructibleVariantTestResult
{
NoDefaultConstructibleVariant m_result;
};

NoDefaultConstructibleTestType testType(1);
NoDefaultConstructibleVariant variant(testType);
NoDefaultConstructibleVariantTestResult testResult{variant};

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantWithNoDefaultConstructibleUnderlyingType, s_VariantWithNoDefaultConstructibleUnderlyingType)

static int s_VariantExceptionSafety_DefaultConstructor(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct NothrowDefaultConstructibleTestType
{
NothrowDefaultConstructibleTestType() noexcept {}
NothrowDefaultConstructibleTestType(const NothrowDefaultConstructibleTestType &) noexcept(false) {}
NothrowDefaultConstructibleTestType(NothrowDefaultConstructibleTestType &&) noexcept(false) {}
};

using NothrowDefaultConstructibleVariant = Aws::Crt::Variant<NothrowDefaultConstructibleTestType>;

ASSERT_TRUE(std::is_nothrow_constructible<NothrowDefaultConstructibleVariant>::value);
ASSERT_FALSE((
std::is_nothrow_constructible<NothrowDefaultConstructibleVariant, const NothrowDefaultConstructibleTestType &>::
value));
ASSERT_FALSE(
(std::is_nothrow_constructible<NothrowDefaultConstructibleVariant, NothrowDefaultConstructibleTestType &&>::
value));

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantExceptionSafety_DefaultConstructor, s_VariantExceptionSafety_DefaultConstructor)

static int s_VariantExceptionSafety_MoveConstructor(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct NothrowMoveConstructibleTestType
{
NothrowMoveConstructibleTestType(NothrowMoveConstructibleTestType &&) noexcept {}

NothrowMoveConstructibleTestType() noexcept(false) {}
NothrowMoveConstructibleTestType(const NothrowMoveConstructibleTestType &) noexcept(false) {}
};

using NothrowMoveConstructibleVariant = Aws::Crt::Variant<NothrowMoveConstructibleTestType>;

ASSERT_TRUE(
(std::is_nothrow_constructible<NothrowMoveConstructibleVariant, NothrowMoveConstructibleTestType &&>::value));
ASSERT_FALSE(std::is_nothrow_constructible<NothrowMoveConstructibleVariant>::value);
ASSERT_FALSE(
(std::is_nothrow_constructible<NothrowMoveConstructibleVariant, const NothrowMoveConstructibleTestType &>::
value));

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantExceptionSafety_MoveConstructor, s_VariantExceptionSafety_MoveConstructor)

static int s_VariantExceptionSafety_CopyConstructor(struct aws_allocator *allocator, void *ctx)
{
(void)ctx;

Aws::Crt::ApiHandle apiHandle(allocator);

struct NothrowCopyConstructibleTestType
{
NothrowCopyConstructibleTestType(const NothrowCopyConstructibleTestType &) noexcept {}

NothrowCopyConstructibleTestType() noexcept(false) {}
NothrowCopyConstructibleTestType(NothrowCopyConstructibleTestType &&) noexcept(false) {}
};

using NothrowCopyConstructibleVariant = Aws::Crt::Variant<NothrowCopyConstructibleTestType>;

ASSERT_TRUE(
(std::is_nothrow_constructible<NothrowCopyConstructibleVariant, const NothrowCopyConstructibleTestType &>::
value));

ASSERT_FALSE(std::is_nothrow_constructible<NothrowCopyConstructibleVariant>::value);
ASSERT_FALSE(
(std::is_nothrow_constructible<NothrowCopyConstructibleVariant, NothrowCopyConstructibleTestType &&>::value));

return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantExceptionSafety_CopyConstructor, s_VariantExceptionSafety_CopyConstructor)

struct TestStringOnlyVisitor
{
Expand Down Expand Up @@ -364,4 +555,4 @@ static int s_VariantVisitor(struct aws_allocator *allocator, void *ctx)
return AWS_OP_SUCCESS;
}

AWS_TEST_CASE(VariantVisitor, s_VariantVisitor)
AWS_TEST_CASE(VariantVisitor, s_VariantVisitor)
You are viewing a condensed version of this merge commit. You can view the full changes here.