Skip to content

Commit

Permalink
Wrap EVMC result
Browse files Browse the repository at this point in the history
  • Loading branch information
axic authored and jakelang committed Mar 13, 2019
1 parent 01660ef commit 57abc74
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 40 deletions.
1 change: 0 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ search = version = \"{current_version}\"

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

8 changes: 0 additions & 8 deletions bindings/rust/Cargo.toml

This file was deleted.

25 changes: 0 additions & 25 deletions bindings/rust/build.rs

This file was deleted.

1 change: 1 addition & 0 deletions bindings/rust/evmc-vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ edition = "2018"

[dependencies]
evmc-sys = { path = "../evmc-sys" }
libc = "0.2.48"
29 changes: 29 additions & 0 deletions bindings/rust/evmc-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,32 @@ pub use evmc_sys as ffi;
// TODO: Add convenient helpers for evmc_result
// TODO: Add convenient helpers for evmc_execute
// TODO: Add a derive macro here for creating evmc_create

//pub fn destroy_result(&mut evmc_result)

/// EVMC result structure.
pub struct EvmcResult(Box<ffi::evmc_result>);

impl EvmcResult {
pub fn release_result(self) {
if let Some(release_fn) = self.0.release {
unsafe {
release_fn(Box::into_raw(self.0));
}
}
}

pub fn set_release_fn(&mut self, f: extern "C" fn(*const ffi::evmc_result)) {
self.0.release = Some(f);
}

pub fn into_raw(self) -> *const ffi::evmc_result {
Box::into_raw(self.0)
}

pub fn set_status(&mut self, code: ffi::evmc_status_code) {}

pub fn set_gas_left(&mut self, gas: i64) {
self.0.gas_left = gas;
}
}
1 change: 0 additions & 1 deletion bindings/rust/evmc.h

This file was deleted.

5 changes: 0 additions & 5 deletions bindings/rust/src/lib.rs

This file was deleted.

0 comments on commit 57abc74

Please sign in to comment.