mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Migrate sr-primitives, sr-sandbox, sr-std and sr-version to the 2018 edition (#1694)
This commit is contained in:
committed by
Gav Wood
parent
4e3eace15f
commit
3a4dda7beb
@@ -3,15 +3,16 @@ name = "sr-sandbox"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
build = "build.rs"
|
||||
edition = "2018"
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
||||
[dependencies]
|
||||
wasmi = { version = "0.4.3", optional = true }
|
||||
substrate-primitives = { path = "../primitives", default-features = false }
|
||||
sr-std = { path = "../sr-std", default-features = false }
|
||||
parity-codec = { version = "3.0", default-features = false }
|
||||
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
|
||||
codec = { package = "parity-codec", version = "3.0", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "~0.7.4"
|
||||
@@ -21,9 +22,9 @@ assert_matches = "1.1"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"wasmi",
|
||||
"substrate-primitives/std",
|
||||
"sr-std/std",
|
||||
"parity-codec/std",
|
||||
"primitives/std",
|
||||
"rstd/std",
|
||||
"codec/std",
|
||||
]
|
||||
nightly = []
|
||||
strict = []
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
//! Set a nightly feature
|
||||
|
||||
extern crate rustc_version;
|
||||
use rustc_version::{version, version_meta, Channel};
|
||||
|
||||
fn main() {
|
||||
|
||||
@@ -39,19 +39,6 @@
|
||||
#![cfg_attr(not(feature = "std"), feature(core_intrinsics))]
|
||||
#![cfg_attr(not(feature = "std"), feature(alloc))]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), macro_use)]
|
||||
extern crate sr_std as rstd;
|
||||
extern crate substrate_primitives as primitives;
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate parity_codec as codec;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate wabt;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate assert_matches;
|
||||
|
||||
use rstd::prelude::*;
|
||||
|
||||
pub use primitives::sandbox::{TypedValue, ReturnValue, HostError};
|
||||
|
||||
@@ -14,17 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
extern crate wasmi;
|
||||
|
||||
use rstd::collections::btree_map::BTreeMap;
|
||||
use rstd::fmt;
|
||||
|
||||
use self::wasmi::{
|
||||
use wasmi::{
|
||||
Externals, FuncInstance, FuncRef, GlobalDescriptor, GlobalRef, ImportResolver,
|
||||
MemoryDescriptor, MemoryInstance, MemoryRef, Module, ModuleInstance, ModuleRef,
|
||||
RuntimeArgs, RuntimeValue, Signature, TableDescriptor, TableRef, Trap, TrapKind
|
||||
};
|
||||
use self::wasmi::memory_units::Pages;
|
||||
use wasmi::memory_units::Pages;
|
||||
use super::{Error, TypedValue, ReturnValue, HostFuncType, HostError};
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -90,7 +88,7 @@ impl fmt::Display for DummyHostError {
|
||||
}
|
||||
}
|
||||
|
||||
impl self::wasmi::HostError for DummyHostError {
|
||||
impl wasmi::HostError for DummyHostError {
|
||||
}
|
||||
|
||||
fn from_runtime_value(v: RuntimeValue) -> TypedValue {
|
||||
@@ -103,7 +101,7 @@ fn from_runtime_value(v: RuntimeValue) -> TypedValue {
|
||||
}
|
||||
|
||||
fn to_runtime_value(v: TypedValue) -> RuntimeValue {
|
||||
use self::wasmi::nan_preserving_float::{F32, F64};
|
||||
use wasmi::nan_preserving_float::{F32, F64};
|
||||
match v {
|
||||
TypedValue::I32(v) => RuntimeValue::I32(v as i32),
|
||||
TypedValue::I64(v) => RuntimeValue::I64(v as i64),
|
||||
@@ -309,7 +307,8 @@ impl<T> Instance<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use wabt;
|
||||
use ::{Error, TypedValue, ReturnValue, HostError, EnvironmentDefinitionBuilder, Instance};
|
||||
use crate::{Error, TypedValue, ReturnValue, HostError, EnvironmentDefinitionBuilder, Instance};
|
||||
use assert_matches::assert_matches;
|
||||
|
||||
fn execute_sandboxed(code: &[u8], args: &[TypedValue]) -> Result<ReturnValue, HostError> {
|
||||
struct State {
|
||||
|
||||
Reference in New Issue
Block a user