Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust: Attribute-style procedural macro to generate EVMC FFI code with user-defined data #262

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
axic marked this conversation as resolved.
Show resolved Hide resolved
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"
jakelang marked this conversation as resolved.
Show resolved Hide resolved
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