From 594da7553e87d064937ec5c7281ffff388ac2eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 May 2019 16:51:37 +0200 Subject: [PATCH 1/2] cpp: Rename result::raw() to result::release_raw() --- include/evmc/evmc.hpp | 14 ++++++++++---- test/unittests/test_cpp.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index d460266..cffeeef 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -56,9 +56,15 @@ public: return *this; } - /// Returns the raw copy of evmc_result, - /// releases the ownership of the resources and invalidates this object. - evmc_result raw() noexcept + /// Releases the ownership and returns the raw copy of evmc_result. + /// + /// This method drops the ownership of the result + /// (result's resources are not going to be released when this object is destructed). + /// It is the caller's responsibility having the returned copy of the result to release it. + /// This object MUST NOT be used after this method is invoked. + /// + /// @return The copy of this object converted to raw evmc_result. + evmc_result release_raw() noexcept { const auto out = evmc_result{*this}; // Copy data. this->release = nullptr; // Disable releasing of this object. @@ -321,7 +327,7 @@ inline void selfdestruct(evmc_context* h, } inline evmc_result call(evmc_context* h, const evmc_message* msg) noexcept { - return static_cast(h)->call(*msg).raw(); + return static_cast(h)->call(*msg).release_raw(); } inline evmc_tx_context get_tx_context(evmc_context* h) noexcept { diff --git a/test/unittests/test_cpp.cpp b/test/unittests/test_cpp.cpp index cb813f5..b233d3f 100644 --- a/test/unittests/test_cpp.cpp +++ b/test/unittests/test_cpp.cpp @@ -141,7 +141,7 @@ TEST(cpp, result_raii) EXPECT_EQ(raii_result.gas_left, 0); raii_result.gas_left = -1; - auto raw_result2 = raii_result.raw(); + auto raw_result2 = raii_result.release_raw(); EXPECT_EQ(raw_result2.status_code, EVMC_INTERNAL_ERROR); EXPECT_EQ(raw_result.status_code, EVMC_INTERNAL_ERROR); EXPECT_EQ(raw_result2.gas_left, -1); From 3ffadec2c7d368419598b7e743cb58d63eddb7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Wed, 15 May 2019 16:55:40 +0200 Subject: [PATCH 2/2] changelog: Add entry about rename of result::raw() --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1acce5..968fa6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [6.3.0] - unreleased +- Changed: [[#293](https://github.com/ethereum/evmc/pull/293)] + In C++ API `evmc::result::raw()` renamed to `evmc::result::release_raw()`. - Fixed: [[#261](https://github.com/ethereum/evmc/issues/261), [#263](https://github.com/ethereum/evmc/pull/263)]