Return result from call_fn

This changes the evmc_call_fn signature to return evmc_result object instead of getting result as an output parameter.
This commit is contained in:
Paweł Bylica 2018-08-29 23:00:11 +02:00
parent 6768aa888e
commit 3c86a6b934
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
4 changed files with 14 additions and 17 deletions

View File

@ -208,7 +208,7 @@ func emitLog(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pData unsafe.Poi
}
//export call
func call(pResult *C.struct_evmc_result, pCtx unsafe.Pointer, msg *C.struct_evmc_message) {
func call(pCtx unsafe.Pointer, msg *C.struct_evmc_message) C.struct_evmc_result {
idx := int((*C.struct_extended_context)(pCtx).index)
ctx := getHostContext(idx)
@ -234,5 +234,5 @@ func call(pResult *C.struct_evmc_result, pCtx unsafe.Pointer, msg *C.struct_evmc
result.release = (C.evmc_release_result_fn)(C.evmc_go_free_result_output)
}
*pResult = result
return result
}

View File

@ -118,13 +118,12 @@ static void selfdestruct(struct evmc_context* context,
printf("\n");
}
static void call(struct evmc_result* result,
struct evmc_context* context,
const struct evmc_message* msg)
static struct evmc_result call(struct evmc_context* context, const struct evmc_message* msg)
{
(void)context;
printf("EVM-C: CALL (depth: %d)\n", msg->depth);
result->status_code = EVMC_FAILURE;
struct evmc_result result = {.status_code = EVMC_FAILURE};
return result;
}
static void get_tx_context(struct evmc_tx_context* result, struct evmc_context* context)

View File

@ -574,16 +574,12 @@ typedef void (*evmc_emit_log_fn)(struct evmc_context* context,
/**
* Pointer to the callback function supporting EVM calls.
*
* @param[out] result The result of the call. The result object is not
* initialized by the EVM, the Client MUST correctly
* initialize all expected fields of the structure.
* @param context The pointer to the Host execution context.
* @see ::evmc_context.
* @param msg Call parameters. @see ::evmc_message.
* @param context The pointer to the Host execution context.
* @param msg The call parameters.
* @return The result of the call.
*/
typedef void (*evmc_call_fn)(struct evmc_result* result,
struct evmc_context* context,
const struct evmc_message* msg);
typedef struct evmc_result (*evmc_call_fn)(struct evmc_context* context,
const struct evmc_message* msg);
/**
* The context interface.

View File

@ -88,11 +88,13 @@ static void selfdestruct(evmc_context* context,
(void)beneficiary;
}
static void call(evmc_result* result, evmc_context* context, const evmc_message* msg)
static evmc_result call(evmc_context* context, const evmc_message* msg)
{
(void)context;
(void)msg;
result->status_code = EVMC_FAILURE;
evmc_result result{};
result.status_code = EVMC_FAILURE;
return result;
}
static void get_tx_context(evmc_tx_context* result, evmc_context* context)