mirror of https://github.com/status-im/evmc.git
Change naming convention for "create" function
Now should be prefixed with "evmc_create_".
This commit is contained in:
parent
630d8be405
commit
c5c34599b9
|
@ -5,8 +5,8 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/// Prototype from examplevm.c
|
||||
struct evmc_instance* examplevm_create(void);
|
||||
#include "examplevm/examplevm.h"
|
||||
|
||||
|
||||
struct evmc_uint256be balance(struct evmc_context* context,
|
||||
const struct evmc_address* address)
|
||||
|
@ -139,7 +139,7 @@ static const struct evmc_context_fn_table ctx_fn_table = {
|
|||
|
||||
/// Example how the API is supposed to be used.
|
||||
int main(int argc, char *argv[]) {
|
||||
struct evmc_instance* jit = examplevm_create();
|
||||
struct evmc_instance* jit = evmc_create_examplevm();
|
||||
if (jit->abi_version != EVMC_ABI_VERSION)
|
||||
return 1; // Incompatible ABI version.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <evmc.h>
|
||||
#include "examplevm.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
|
@ -109,7 +109,7 @@ static struct evmc_result execute(struct evmc_instance* instance, struct evmc_co
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct evmc_instance* examplevm_create()
|
||||
struct evmc_instance* evmc_create_examplevm()
|
||||
{
|
||||
struct evmc_instance init = {
|
||||
.abi_version = EVMC_ABI_VERSION,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* EVMC: Ethereum Client-VM Connector API.
|
||||
* Copyright 2018 Pawel Bylica.
|
||||
* Licensed under the MIT License. See the LICENSE file.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <evmc.h>
|
||||
|
||||
/**
|
||||
* Creates EVMC Example VM.
|
||||
*/
|
||||
struct evmc_instance* evmc_create_examplevm(void);
|
|
@ -576,11 +576,11 @@ struct evmc_instance
|
|||
/// Example of a function creating an instance of an example EVM implementation.
|
||||
///
|
||||
/// Each EVM implementation MUST provide a function returning an EVM instance.
|
||||
/// The function SHOULD be named `<vm-name>_create(void)`.
|
||||
/// The function SHOULD be named `evmc_create_<vm-name>(void)`.
|
||||
///
|
||||
/// @return EVM instance or NULL indicating instance creation failure.
|
||||
///
|
||||
/// struct evmc_instance* examplevm_create(void);
|
||||
/// struct evmc_instance* evmc_create_examplevm(void);
|
||||
|
||||
|
||||
#if __cplusplus
|
||||
|
|
|
@ -26,12 +26,12 @@ namespace
|
|||
{
|
||||
boost::function<evmc_create_fn> create_fn;
|
||||
|
||||
bool ends_with(const std::string& str, const std::string& ending)
|
||||
bool starts_with(const std::string& str, const std::string& prefix)
|
||||
{
|
||||
if (str.size() < ending.size())
|
||||
if (str.size() < prefix.size())
|
||||
return false;
|
||||
|
||||
return std::equal(ending.rbegin(), ending.rend(), str.rbegin());
|
||||
return std::equal(prefix.begin(), prefix.end(), str.begin());
|
||||
}
|
||||
|
||||
std::unique_ptr<evmc_instance, evmc_destroy_fn> create_vm()
|
||||
|
@ -79,10 +79,10 @@ int main(int argc, char* argv[])
|
|||
|
||||
auto symbols = dll::library_info{vm_path}.symbols();
|
||||
auto it = std::find_if(symbols.begin(), symbols.end(),
|
||||
[](const std::string& symbol) { return ends_with(symbol, "_create"); });
|
||||
[](const std::string& symbol) { return starts_with(symbol, "evmc_create_"); });
|
||||
if (it == symbols.end())
|
||||
{
|
||||
std::cerr << "EVMC create function not found it " << vm_path.string() << "\n";
|
||||
std::cerr << "EVMC create function not found in " << vm_path.string() << "\n";
|
||||
return 2;
|
||||
}
|
||||
const std::string& create_fn_name = *it;
|
||||
|
|
Loading…
Reference in New Issue