Skip to content

Commit

Permalink
Merge pull request #262 from ethereum/rust-proc-macro
Browse files Browse the repository at this point in the history
Rust: Attribute-style procedural macro to generate EVMC FFI code with user-defined data
  • Loading branch information
jakelang authored Jun 4, 2019
2 parents d7c6d08 + 2e14aa2 commit 9510206
Show file tree
Hide file tree
Showing 13 changed files with 527 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ search = version = \"{current_version}\"
[bumpversion:file:bindings/rust/evmc-vm/Cargo.toml]
search = version = \"{current_version}\"

[bumpversion:file:bindings/rust/evmc-declare/Cargo.toml]
search = version = \"{current_version}\"

[bumpversion:file:bindings/rust/evmc-declare-tests/Cargo.toml]
search = version = \"{current_version}\"

[bumpversion:file:docs/EVMC.md]
serialize = {major}
search = ABI version {current_version}
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
members = [
"bindings/rust/evmc-sys",
"bindings/rust/evmc-vm",
"bindings/rust/evmc-declare",
"bindings/rust/evmc-declare-tests",
"examples/example-rust-vm"
]
3 changes: 3 additions & 0 deletions bindings/rust/evmc-declare-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
**/*.rs.bk
/Cargo.lock
18 changes: 18 additions & 0 deletions bindings/rust/evmc-declare-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.

[package]
name = "evmc-declare-tests"
version = "6.3.0-dev"
authors = ["Jake Lang <jak3lang@gmail.com>"]
license = "Apache-2.0"
repository = "https://github.com/ethereum/evmc"
description = "Bindings to EVMC (VM declare macro) -- Test crate"
edition = "2018"
publish = false

[dependencies]
evmc-declare = { path = "../evmc-declare" }
evmc-sys = { path = "../evmc-sys" }
evmc-vm = { path = "../evmc-vm" }
25 changes: 25 additions & 0 deletions bindings/rust/evmc-declare-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* EVMC: Ethereum Client-VM Connector API.
* Copyright 2019 The EVMC Authors.
* Licensed under the Apache License, Version 2.0.
*/

use evmc_vm::EvmcVm;
use evmc_vm::ExecutionContext;
use evmc_vm::ExecutionResult;
#[macro_use]
use evmc_declare::evmc_declare_vm;

#[evmc_declare_vm("Foo VM", "ewasm, evm", "1.42-alpha.gamma.starship")]
pub struct FooVM {
a: i32,
}

impl EvmcVm for FooVM {
fn init() -> Self {
FooVM { a: 105023 }
}

fn execute(&self, code: &[u8], context: &ExecutionContext) -> ExecutionResult {
ExecutionResult::success(1337, None)
}
}
3 changes: 3 additions & 0 deletions bindings/rust/evmc-declare/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
**/*.rs.bk
/Cargo.lock
27 changes: 27 additions & 0 deletions bindings/rust/evmc-declare/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# EVMC: Ethereum Client-VM Connector API.
# Copyright 2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.

[package]
name = "evmc-declare"
version = "6.3.0-dev"
authors = ["Jake Lang <jak3lang@gmail.com>"]
license = "Apache-2.0"
repository = "https://github.com/ethereum/evmc"
description = "Bindings to EVMC (VM declare macro)"
edition = "2018"

[dependencies]
quote = "0.6.12"
heck = "0.3.1"
proc-macro2 = "0.4.29"

# For documentation examples
evmc-vm = { path = "../evmc-vm" }

[dependencies.syn]
version = "0.15.33"
features = ["full"]

[lib]
proc-macro = true
Loading

0 comments on commit 9510206

Please sign in to comment.