From 759e67a1c69027e2d8829867121f23ab46f6fa17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 30 Aug 2018 18:27:44 +0200 Subject: [PATCH] Rename examplevm to example-vm --- appveyor.yml | 2 +- circle.yml | 4 ++-- examples/CMakeLists.txt | 10 +++++----- examples/example.c | 6 +++--- examples/{examplevm.c => example_vm.c} | 20 ++++++++++++-------- examples/{examplevm.h => example_vm.h} | 2 +- 6 files changed, 24 insertions(+), 20 deletions(-) rename examples/{examplevm.c => example_vm.c} (88%) rename examples/{examplevm.h => example_vm.h} (79%) diff --git a/appveyor.yml b/appveyor.yml index 6d9fe58..40b8a65 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -54,5 +54,5 @@ after_build: if ($env:GENERATOR) { cd C:\projects\evmc\build\test Release\evmc-test.exe - C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-examplevm.dll + C:\install\bin\evmc-vmtester.exe C:\install\bin\evmc-example-vm.dll } diff --git a/circle.yml b/circle.yml index 20f521f..a46f450 100644 --- a/circle.yml +++ b/circle.yml @@ -54,8 +54,8 @@ jobs: cmake ~/project/examples/use_instructions_in_cmake -DCMAKE_PREFIX_PATH=~/install cmake --build . - run: - name: "Run evmc-vmtester libevmc-examplevm.so" - command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-examplevm.so + name: "Run evmc-vmtester libevmc-example-vm.so" + command: ~/install/bin/evmc-vmtester ~/install/lib/libevmc-example-vm.so build-clang-3.8: <<: *build diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5a140d0..3f0c90b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,16 +15,16 @@ add_library(evmc-example-host STATIC example_host.cpp) target_link_libraries(evmc-example-host PRIVATE evmc) -add_library(evmc-examplevm examplevm.c) -target_link_libraries(evmc-examplevm PRIVATE evmc) -set_source_files_properties(examplevm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION}) +add_library(evmc-example-vm example_vm.c) +target_link_libraries(evmc-example-vm PRIVATE evmc) +set_source_files_properties(example_vm.c PROPERTIES COMPILE_DEFINITIONS PROJECT_VERSION=${PROJECT_VERSION}) add_executable(evmc-example example.c) -target_link_libraries(evmc-example PRIVATE evmc-example-host evmc-examplevm evmc) +target_link_libraries(evmc-example PRIVATE evmc-example-host evmc-example-vm evmc) -install(TARGETS evmc-examplevm +install(TARGETS evmc-example-vm ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} diff --git a/examples/example.c b/examples/example.c index 4bb3e7a..fcf47ce 100644 --- a/examples/example.c +++ b/examples/example.c @@ -4,7 +4,7 @@ */ #include "example_host.h" -#include "examplevm.h" +#include "example_vm.h" #include @@ -13,10 +13,10 @@ int main() { - struct evmc_instance* vm = evmc_create_examplevm(); + struct evmc_instance* vm = evmc_create_example_vm(); if (!evmc_is_abi_compatible(vm)) return 1; - // EVM bytecode goes here. This is one of the examples examplevm.c + // EVM bytecode goes here. This is one of the examples. const uint8_t code[] = "\x30\x60\x00\x52\x59\x60\x00\xf3"; const size_t code_size = sizeof(code); const struct evmc_uint256be code_hash = {.bytes = {1, 2, 3}}; diff --git a/examples/examplevm.c b/examples/example_vm.c similarity index 88% rename from examples/examplevm.c rename to examples/example_vm.c index 757ca80..b04a95e 100644 --- a/examples/examplevm.c +++ b/examples/example_vm.c @@ -1,4 +1,8 @@ -#include "examplevm.h" +/* EVMC: Ethereum Client-VM Connector API. + * Copyright 2018 The EVMC Authors. + * Licensed under the Apache License, Version 2.0. See the LICENSE file. + */ +#include "example_vm.h" #include #include @@ -11,7 +15,7 @@ #define PROJECT_VERSION 0.0.0 #endif -struct examplevm +struct example_vm { struct evmc_instance instance; int verbose; @@ -29,7 +33,7 @@ static void destroy(struct evmc_instance* evm) /// VMs are allowed to omit this function implementation. static int set_option(struct evmc_instance* instance, char const* name, char const* value) { - struct examplevm* vm = (struct examplevm*)instance; + struct example_vm* vm = (struct example_vm*)instance; if (strcmp(name, "verbose") == 0) { long int v = strtol(value, NULL, 0); @@ -71,7 +75,7 @@ static struct evmc_result execute(struct evmc_instance* instance, return ret; } - struct examplevm* vm = (struct examplevm*)instance; + struct example_vm* vm = (struct example_vm*)instance; // Simulate executing by checking for some code patterns. // Solidity inline assembly is used in the examples instead of EVM bytecode. @@ -125,23 +129,23 @@ static void set_tracer(struct evmc_instance* instance, evmc_trace_callback callback, struct evmc_tracer_context* context) { - struct examplevm* vm = (struct examplevm*)instance; + struct example_vm* vm = (struct example_vm*)instance; vm->trace_callback = callback; vm->tracer_context = context; } -struct evmc_instance* evmc_create_examplevm() +struct evmc_instance* evmc_create_example_vm() { struct evmc_instance init = { .abi_version = EVMC_ABI_VERSION, - .name = "examplevm", + .name = "example_vm", .version = STR(PROJECT_VERSION), .destroy = destroy, .execute = execute, .set_option = set_option, .set_tracer = set_tracer, }; - struct examplevm* vm = calloc(1, sizeof(struct examplevm)); + struct example_vm* vm = calloc(1, sizeof(struct example_vm)); struct evmc_instance* interface = &vm->instance; memcpy(interface, &init, sizeof(init)); return interface; diff --git a/examples/examplevm.h b/examples/example_vm.h similarity index 79% rename from examples/examplevm.h rename to examples/example_vm.h index b201587..7fa057e 100644 --- a/examples/examplevm.h +++ b/examples/example_vm.h @@ -11,4 +11,4 @@ /** * Creates EVMC Example VM. */ -EVMC_EXPORT struct evmc_instance* evmc_create_examplevm(void); +EVMC_EXPORT struct evmc_instance* evmc_create_example_vm(void);