diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ab99c107d..c418072a2 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -29,4 +29,3 @@ search = version = \"{current_version}\" [bumpversion:file:bindings/rust/evmc-vm/Cargo.toml] search = version = \"{current_version}\" - diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml deleted file mode 100644 index 188d7bce0..000000000 --- a/bindings/rust/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "evmc-sys" -version = "0.0.0" -authors = ["Alex Beregszaszi "] -edition = "2018" - -[build-dependencies] -bindgen = "0.30.0" diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs deleted file mode 100644 index 35915897a..000000000 --- a/bindings/rust/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -extern crate bindgen; - -use std::env; -use std::path::PathBuf; - -fn gen_bindings() { - let bindings = bindgen::Builder::default() - .header("evmc.h") - // See https://github.com/rust-lang-nursery/rust-bindgen/issues/947 - .trust_clang_mangling(false) - .generate_comments(true) - // https://github.com/rust-lang-nursery/rust-bindgen/issues/947#issuecomment-327100002 - .layout_tests(false) - .generate() - .expect("Unable to generate bindings"); - - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - bindings - .write_to_file(out_path.join("bindings.rs")) - .expect("Couldn't write bindings!"); -} - -fn main() { - gen_bindings(); -} diff --git a/bindings/rust/evmc-vm/Cargo.toml b/bindings/rust/evmc-vm/Cargo.toml index 95cc2be3a..5a3ae959a 100644 --- a/bindings/rust/evmc-vm/Cargo.toml +++ b/bindings/rust/evmc-vm/Cargo.toml @@ -9,3 +9,4 @@ edition = "2018" [dependencies] evmc-sys = { path = "../evmc-sys" } +libc = "0.2.48" diff --git a/bindings/rust/evmc-vm/src/lib.rs b/bindings/rust/evmc-vm/src/lib.rs index 37a7e1f8a..95c746622 100644 --- a/bindings/rust/evmc-vm/src/lib.rs +++ b/bindings/rust/evmc-vm/src/lib.rs @@ -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); + +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; + } +} diff --git a/bindings/rust/evmc.h b/bindings/rust/evmc.h deleted file mode 120000 index 32ffe53b4..000000000 --- a/bindings/rust/evmc.h +++ /dev/null @@ -1 +0,0 @@ -../../include/evmc/evmc.h \ No newline at end of file diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs deleted file mode 100644 index a38a13a81..000000000 --- a/bindings/rust/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![allow(non_upper_case_globals)] -#![allow(non_camel_case_types)] -#![allow(non_snake_case)] - -include!(concat!(env!("OUT_DIR"), "/bindings.rs"));