mirror of
https://github.com/status-im/evmc.git
synced 2025-02-23 16:38:06 +00:00
cpp: Rename literal suffixes: _addr -> _address, _b32 -> _bytes32
This commit is contained in:
parent
552bd956f2
commit
4ac70471ec
@ -22,8 +22,8 @@
|
|||||||
- Added: [[#359](https://github.com/ethereum/evmc/pull/359)]
|
- Added: [[#359](https://github.com/ethereum/evmc/pull/359)]
|
||||||
The C++ EVMC basic types `address` and `bytes32` have user defined literals.
|
The C++ EVMC basic types `address` and `bytes32` have user defined literals.
|
||||||
```cpp
|
```cpp
|
||||||
auto a = 0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359_addr;
|
auto a = 0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359_address;
|
||||||
auto b = 0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_b32;
|
auto b = 0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_bytes32;
|
||||||
```
|
```
|
||||||
- Changed: [[#293](https://github.com/ethereum/evmc/pull/293)]
|
- Changed: [[#293](https://github.com/ethereum/evmc/pull/293)]
|
||||||
In C++ API `evmc::result::raw()` renamed to `evmc::result::release_raw()`.
|
In C++ API `evmc::result::raw()` renamed to `evmc::result::release_raw()`.
|
||||||
|
@ -113,8 +113,8 @@ public:
|
|||||||
const int64_t current_block_number = get_tx_context().block_number;
|
const int64_t current_block_number = get_tx_context().block_number;
|
||||||
|
|
||||||
return (number < current_block_number && number >= current_block_number - 256) ?
|
return (number < current_block_number && number >= current_block_number - 256) ?
|
||||||
0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_b32 :
|
0xb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5fb10c8a5f_bytes32 :
|
||||||
0_b32;
|
0_bytes32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void emit_log(const evmc_address& addr,
|
void emit_log(const evmc_address& addr,
|
||||||
|
@ -238,14 +238,14 @@ constexpr T parse() noexcept
|
|||||||
|
|
||||||
/// Literal for evmc::address.
|
/// Literal for evmc::address.
|
||||||
template <char... Literal>
|
template <char... Literal>
|
||||||
constexpr address operator"" _addr() noexcept
|
constexpr address operator"" _address() noexcept
|
||||||
{
|
{
|
||||||
return internal::parse<address, Literal...>();
|
return internal::parse<address, Literal...>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Literal for evmc::bytes32.
|
/// Literal for evmc::bytes32.
|
||||||
template <char... Literal>
|
template <char... Literal>
|
||||||
constexpr bytes32 operator"" _b32() noexcept
|
constexpr bytes32 operator"" _bytes32() noexcept
|
||||||
{
|
{
|
||||||
return internal::parse<bytes32, Literal...>();
|
return internal::parse<bytes32, Literal...>();
|
||||||
}
|
}
|
||||||
|
@ -195,10 +195,11 @@ TEST(cpp, literals)
|
|||||||
using namespace evmc::literals;
|
using namespace evmc::literals;
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1910 /* Only for Visual Studio 2017+ */)
|
#if !defined(_MSC_VER) || (_MSC_VER >= 1910 /* Only for Visual Studio 2017+ */)
|
||||||
constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_addr;
|
constexpr auto address1 = 0xa0a1a2a3a4a5a6a7a8a9d0d1d2d3d4d5d6d7d8d9_address;
|
||||||
constexpr auto hash1 = 0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_b32;
|
constexpr auto hash1 =
|
||||||
constexpr auto zero_address = 0_addr;
|
0x01020304050607080910a1a2a3a4a5a6a7a8a9b0c1c2c3c4c5c6c7c8c9d0d1d2_bytes32;
|
||||||
constexpr auto zero_hash = 0_b32;
|
constexpr auto zero_address = 0_address;
|
||||||
|
constexpr auto zero_hash = 0_bytes32;
|
||||||
|
|
||||||
static_assert(address1.bytes[0] == 0xa0, "");
|
static_assert(address1.bytes[0] == 0xa0, "");
|
||||||
static_assert(address1.bytes[9] == 0xa9, "");
|
static_assert(address1.bytes[9] == 0xa9, "");
|
||||||
@ -211,15 +212,15 @@ TEST(cpp, literals)
|
|||||||
static_assert(zero_hash == evmc::bytes32{}, "");
|
static_assert(zero_hash == evmc::bytes32{}, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXPECT_EQ(0_addr, evmc::address{});
|
EXPECT_EQ(0_address, evmc::address{});
|
||||||
EXPECT_EQ(0_b32, evmc::bytes32{});
|
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,
|
evmc::address e1{{{0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
|
||||||
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}};
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9}}};
|
||||||
EXPECT_EQ(a1, e1);
|
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,
|
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,
|
0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xb0, 0xc1, 0xc2,
|
||||||
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};
|
0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xd0, 0xd1, 0xd2}}};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user