mirror of https://github.com/status-im/evmc.git
Move Result Optional Storage functions to helpers.h
This commit is contained in:
parent
f92f1cf92c
commit
488bd5ad9d
|
@ -393,40 +393,6 @@ struct evmc_result
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* The union representing evmc_result "optional data".
|
||||
*
|
||||
* The evmc_result struct contains 24 bytes of optional data that can be
|
||||
* reused by the object creator if the object does not contain
|
||||
* evmc_result::create_address.
|
||||
*
|
||||
* An EVM implementation MAY use this memory to keep additional data
|
||||
* when returning result from ::evmc_execute_fn.
|
||||
* The host application MAY use this memory to keep additional data
|
||||
* when returning result of performed calls from ::evmc_call_fn.
|
||||
*
|
||||
* @see evmc_get_optional_data(), evmc_get_const_optional_data().
|
||||
*/
|
||||
union evmc_result_optional_data
|
||||
{
|
||||
uint8_t bytes[24]; /**< 24 bytes of optional data. */
|
||||
void* pointer; /**< Optional pointer. */
|
||||
};
|
||||
|
||||
/** Provides read-write access to evmc_result "optional data". */
|
||||
static inline union evmc_result_optional_data* evmc_get_optional_data(struct evmc_result* result)
|
||||
{
|
||||
return (union evmc_result_optional_data*)&result->create_address;
|
||||
}
|
||||
|
||||
/** Provides read-only access to evmc_result "optional data". */
|
||||
static inline const union evmc_result_optional_data* evmc_get_const_optional_data(
|
||||
const struct evmc_result* result)
|
||||
{
|
||||
return (const union evmc_result_optional_data*)&result->create_address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check account existence callback function
|
||||
*
|
||||
|
|
|
@ -51,4 +51,53 @@ static inline void evmc_release_result(struct evmc_result* result)
|
|||
result->release(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helpers for optional storage of evmc_result.
|
||||
*
|
||||
* In some contexts (i.e. evmc_result::create_address is unused) objects of
|
||||
* type evmc_result contains a memory storage that MAY be used by the object
|
||||
* owner. This group defines helper types and functions for accessing
|
||||
* the optional storage.
|
||||
*
|
||||
* @defgroup result_optional_storage Result Optional Storage
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The union representing evmc_result "optional storage".
|
||||
*
|
||||
* The evmc_result struct contains 24 bytes of optional storage that can be
|
||||
* reused by the object creator if the object does not contain
|
||||
* evmc_result::create_address.
|
||||
*
|
||||
* A VM implementation MAY use this memory to keep additional data
|
||||
* when returning result from evmc_execute_fn().
|
||||
* The host application MAY use this memory to keep additional data
|
||||
* when returning result of performed calls from evmc_call_fn().
|
||||
*
|
||||
* @see evmc_get_optional_storage(), evmc_get_const_optional_storage().
|
||||
*/
|
||||
union evmc_result_optional_storage
|
||||
{
|
||||
uint8_t bytes[24]; /**< 24 bytes of optional storage. */
|
||||
void* pointer; /**< Optional pointer. */
|
||||
};
|
||||
|
||||
/** Provides read-write access to evmc_result "optional storage". */
|
||||
static inline union evmc_result_optional_storage* evmc_get_optional_storage(
|
||||
struct evmc_result* result)
|
||||
{
|
||||
return (union evmc_result_optional_storage*)&result->create_address;
|
||||
}
|
||||
|
||||
/** Provides read-only access to evmc_result "optional storage". */
|
||||
static inline const union evmc_result_optional_storage* evmc_get_const_optional_storage(
|
||||
const struct evmc_result* result)
|
||||
{
|
||||
return (const union evmc_result_optional_storage*)&result->create_address;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "vmtester.hpp"
|
||||
|
||||
#include <evmc/helpers.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
// Compile time checks:
|
||||
|
@ -22,7 +24,7 @@ static_assert(sizeof(evmc_revision) == sizeof(int), "Enum `evmc_revision` is not
|
|||
|
||||
static constexpr size_t optionalDataSize =
|
||||
sizeof(evmc_result) - offsetof(evmc_result, create_address);
|
||||
static_assert(optionalDataSize == sizeof(evmc_result_optional_data), "");
|
||||
static_assert(optionalDataSize == sizeof(evmc_result_optional_storage), "");
|
||||
|
||||
TEST_F(evmc_vm_test, abi_version_match)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue