Skip to content

Commit

Permalink
rust: Procedural macro for automatic VM declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelang committed Jun 4, 2019
1 parent d7c6d08 commit 6d6d249
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 57 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"
]
10 changes: 10 additions & 0 deletions bindings/rust/evmc-declare-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "evmc-declare-tests"
version = "6.3.0-dev"
authors = ["Jake Lang <jak3lang@gmail.com>"]
edition = "2018"

[dependencies]
evmc-declare = { path = "../evmc-declare" }
evmc-sys = { path = "../evmc-sys" }
evmc-vm = { path = "../evmc-vm" }
20 changes: 20 additions & 0 deletions bindings/rust/evmc-declare-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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")]
pub struct FooVM {
a: i32,
}

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

fn execute(&self, code: &[u8], context: &ExecutionContext) -> ExecutionResult {
ExecutionResult::new(evmc_sys::evmc_status_code::EVMC_SUCCESS, 235117, None)
}
}
20 changes: 20 additions & 0 deletions bindings/rust/evmc-declare/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "evmc-declare"
version = "6.3.0-dev"
authors = ["Jake Lang <jak3lang@gmail.com>"]
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 6d6d249

Please sign in to comment.