diff --git a/CHANGELOG.md b/CHANGELOG.md index b7fa236..bd93e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,8 +22,8 @@ - Added: [[#359](https://github.com/ethereum/evmc/pull/359)] The C++ EVMC basic types `address` and `bytes32` have user defined literals. ```cpp - auto a = 0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359_addr; - auto b = 0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_b32; + auto a = 0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359_address; + auto b = 0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_bytes32; ``` - Changed: [[#293](https://github.com/ethereum/evmc/pull/293)] In C++ API `evmc::result::raw()` renamed to `evmc::result::release_raw()`. diff --git a/examples/example_host.cpp b/examples/example_host.cpp index 36efc00..2ae34ab 100644 --- a/examples/example_host.cpp +++ b/examples/example_host.cpp @@ -113,8 +113,8 @@ public: const int64_t current_block_number = get_tx_context().block_number; return (number < current_block_number && number >= current_block_number - 256) ? - 0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_b32 : - 0_b32; + 0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_bytes32 : + 0_bytes32; } void emit_log(const evmc_address& addr, diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index 0c002fa..8933646 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -238,14 +238,14 @@ constexpr T parse() noexcept /// Literal for evmc::address. template -constexpr address operator"" _addr() noexcept +constexpr address operator"" _address() noexcept { return internal::parse(); } /// Literal for evmc::bytes32. template -constexpr bytes32 operator"" _b32() noexcept +constexpr bytes32 operator"" _bytes32() noexcept { return internal::parse(); } diff --git a/test/unittests/test_cpp.cpp b/test/unittests/test_cpp.cpp index 90c4f41..b08fa4c 100644 --- a/test/unittests/test_cpp.cpp +++ b/test/unittests/test_cpp.cpp @@ -195,10 +195,11 @@ TEST(cpp, literals) using namespace evmc::literals; #if !defined(_MSC_VER) || (_MSC_VER >= 1910 /* Only for Visual Studio 2017+ */) - constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_addr; - constexpr auto hash1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_b32; - constexpr auto zero_address = 0_addr; - constexpr auto zero_hash = 0_b32; + constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address; + constexpr auto hash1 = + 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32; + constexpr auto zero_address = 0_address; + constexpr auto zero_hash = 0_bytes32; static_assert(address1.bytes[0] == 0xa0, ""); static_assert(address1.bytes[9] == 0xa9, ""); @@ -211,15 +212,15 @@ TEST(cpp, literals) static_assert(zero_hash == evmc::bytes32{}, ""); #endif - EXPECT_EQ(0_addr, evmc::address{}); - EXPECT_EQ(0_b32, evmc::bytes32{}); + EXPECT_EQ(0_address, evmc::address{}); + EXPECT_EQ(0_bytes32, evmc::bytes32{}); - auto a1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_addr; + auto a1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address; evmc::address e1{{{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}}; EXPECT_EQ(a1, e1); - auto h1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_b32; + auto h1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32; evmc::bytes32 f1{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xb0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};