From 62fb8af976c6afaea8cff9944b3698996219e043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 24 Apr 2019 19:03:00 +0200 Subject: [PATCH] cpp: Rename evmc::vm to evmc::VM --- CHANGELOG.md | 2 ++ include/evmc/evmc.hpp | 20 ++++++++++---------- test/unittests/test_cpp.cpp | 18 +++++++++--------- test/vmtester/vmtester.cpp | 4 ++-- test/vmtester/vmtester.hpp | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 851f96815..018f1ff6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning]. ### Changed +- The `evmc::vm` renamed to `evmc::VM` in C++ API. + [[#252](https://github.com/ethereum/evmc/pull/252)] - Previously deprecated `helpers.hpp` header file has been removed. [[#410](https://github.com/ethereum/evmc/pull/410)] diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index 4806e046b..2796b07e5 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -338,31 +338,31 @@ class result : private evmc_result /// /// This is a RAII wrapper for evmc_instance and objects of this type /// automatically destroys the VM instance. -class vm +class VM { public: - vm() noexcept = default; + VM() noexcept = default; /// Converting constructor from evmc_instance. - explicit vm(evmc_instance* instance) noexcept : m_instance{instance} {} + explicit VM(evmc_instance* instance) noexcept : m_instance{instance} {} /// Destructor responsible for automatically destroying the VM instance. - ~vm() noexcept + ~VM() noexcept { if (m_instance) m_instance->destroy(m_instance); } - vm(const vm&) = delete; - vm& operator=(const vm&) = delete; + VM(const VM&) = delete; + VM& operator=(const VM&) = delete; /// Move constructor. - vm(vm&& other) noexcept : m_instance{other.m_instance} { other.m_instance = nullptr; } + VM(VM&& other) noexcept : m_instance{other.m_instance} { other.m_instance = nullptr; } /// Move assignment operator. - vm& operator=(vm&& other) noexcept + VM& operator=(VM&& other) noexcept { - this->~vm(); + this->~VM(); m_instance = other.m_instance; other.m_instance = nullptr; return *this; @@ -370,7 +370,7 @@ class vm /// The constructor that captures a VM instance and configures the instance /// with provided list of options. - vm(evmc_instance* instance, + VM(evmc_instance* instance, std::initializer_list> options) noexcept : m_instance{instance} { diff --git a/test/unittests/test_cpp.cpp b/test/unittests/test_cpp.cpp index 64d24acc8..17486f606 100644 --- a/test/unittests/test_cpp.cpp +++ b/test/unittests/test_cpp.cpp @@ -255,7 +255,7 @@ TEST(cpp, result) TEST(cpp, vm) { - auto vm = evmc::vm{evmc_create_example_vm()}; + auto vm = evmc::VM{evmc_create_example_vm()}; EXPECT_TRUE(vm.is_abi_compatible()); auto r = vm.set_option("verbose", "3"); @@ -277,13 +277,13 @@ TEST(cpp, vm_set_option) nullptr, nullptr, nullptr, nullptr}; raw_instance.destroy = [](evmc_instance*) {}; - auto vm = evmc::vm{&raw_instance}; + auto vm = evmc::VM{&raw_instance}; EXPECT_EQ(vm.set_option("1", "2"), EVMC_SET_OPTION_INVALID_NAME); } TEST(cpp, vm_null) { - evmc::vm vm; + evmc::VM vm; EXPECT_FALSE(vm); EXPECT_TRUE(!vm); } @@ -300,25 +300,25 @@ TEST(cpp, vm_move) auto v1 = template_instance; auto v2 = template_instance; - auto vm1 = evmc::vm{&v1}; + auto vm1 = evmc::VM{&v1}; EXPECT_TRUE(vm1); - vm1 = evmc::vm{&v2}; + vm1 = evmc::VM{&v2}; EXPECT_TRUE(vm1); } EXPECT_EQ(destroy_counter, 2); { auto v1 = template_instance; - auto vm1 = evmc::vm{&v1}; + auto vm1 = evmc::VM{&v1}; EXPECT_TRUE(vm1); - vm1 = evmc::vm{}; + vm1 = evmc::VM{}; EXPECT_FALSE(vm1); } EXPECT_EQ(destroy_counter, 3); { auto v1 = template_instance; - auto vm1 = evmc::vm{&v1}; + auto vm1 = evmc::VM{&v1}; EXPECT_TRUE(vm1); auto vm2 = std::move(vm1); EXPECT_TRUE(vm2); @@ -333,7 +333,7 @@ TEST(cpp, vm_move) // Moving to itself will destroy the VM and reset the evmc::vm. auto v1 = template_instance; - auto vm1 = evmc::vm{&v1}; + auto vm1 = evmc::VM{&v1}; auto& vm1_ref = vm1; vm1 = std::move(vm1_ref); EXPECT_EQ(destroy_counter, 5); // Already destroyed. diff --git a/test/vmtester/vmtester.cpp b/test/vmtester/vmtester.cpp index aa8b8a324..e3855bb50 100644 --- a/test/vmtester/vmtester.cpp +++ b/test/vmtester/vmtester.cpp @@ -9,12 +9,12 @@ #include evmc_instance* evmc_vm_test::vm; -evmc::vm evmc_vm_test::owned_vm; +evmc::VM evmc_vm_test::owned_vm; void evmc_vm_test::init_vm(evmc_instance* owned_vm_instance) noexcept { vm = owned_vm_instance; - owned_vm = evmc::vm{owned_vm_instance}; + owned_vm = evmc::VM{owned_vm_instance}; } class cli_parser diff --git a/test/vmtester/vmtester.hpp b/test/vmtester/vmtester.hpp index 57cca0865..6407abc3a 100644 --- a/test/vmtester/vmtester.hpp +++ b/test/vmtester/vmtester.hpp @@ -17,7 +17,7 @@ class evmc_vm_test : public ::testing::Test static evmc_instance* vm; /// The C++ RAII wrapper of the loaded VM instance. - static evmc::vm owned_vm; + static evmc::VM owned_vm; void SetUp() override { ASSERT_TRUE(vm != nullptr) << "VM instance not loaded"; } };