Skip to content

Commit

Permalink
Merge pull request #942 from alexcrichton/parity-wasm-public
Browse files Browse the repository at this point in the history
Update parity-wasm dependency
  • Loading branch information
alexcrichton authored Oct 8, 2018
2 parents a40b27d + 79e4324 commit 6a9ad2e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 38 deletions.
2 changes: 1 addition & 1 deletion crates/cli-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Shared support for the wasm-bindgen-cli package, an internal dependency
[dependencies]
base64 = "0.9"
failure = "0.1.2"
parity-wasm = "0.32"
parity-wasm = "0.34"
serde = "1.0"
serde_json = "1.0"
tempfile = "3.0"
Expand Down
36 changes: 3 additions & 33 deletions crates/cli-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern crate wasm_bindgen_gc;
extern crate failure;
extern crate wasm_bindgen_wasm_interpreter as wasm_interpreter;

use std::any::Any;
use std::collections::BTreeSet;
use std::env;
use std::fs;
Expand Down Expand Up @@ -40,7 +39,6 @@ pub struct Bindgen {

enum Input {
Path(PathBuf),
Bytes(Vec<u8>, String),
Module(Module, String),
None,
}
Expand Down Expand Up @@ -68,33 +66,10 @@ impl Bindgen {
}

/// Explicitly specify the already parsed input module.
///
/// Note that this API is a little wonky to avoid tying itself with a public
/// dependency on the `parity-wasm` crate, what we currently use to parse
/// wasm mdoules.
///
/// If the `module` argument is a `parity_wasm::Module` then it will be used
/// directly. Otherwise it will be passed to `into_bytes` to serialize the
/// module to a vector of bytes, and this will deserialize the module later.
///
/// Note that even if the argument passed in is a `parity_wasm::Module` it
/// doesn't mean that this won't invoke `into_bytes`, if the `parity_wasm`
/// crate versions are different we'll have to go through serialization.
pub fn input_module<T: Any>(
&mut self,
name: &str,
mut module: T,
into_bytes: impl FnOnce(T) -> Vec<u8>,
) -> &mut Bindgen {
pub fn input_module(&mut self, name: &str, module: Module) -> &mut Bindgen {
let name = name.to_string();
if let Some(module) = (&mut module as &mut Any).downcast_mut::<Module>() {
let blank = Module::new(Vec::new());
self.input = Input::Module(mem::replace(module, blank), name);
return self;
}

self.input = Input::Bytes(into_bytes(module), name);
self
self.input = Input::Module(module, name);
return self;
}

pub fn nodejs(&mut self, node: bool) -> &mut Bindgen {
Expand Down Expand Up @@ -153,11 +128,6 @@ impl Bindgen {
let blank_module = Module::new(Vec::new());
(mem::replace(m, blank_module), &name[..])
}
Input::Bytes(ref b, ref name) => {
let module = parity_wasm::deserialize_buffer::<Module>(&b)
.context("failed to parse input file as wasm")?;
(module, &name[..])
}
Input::Path(ref path) => {
let contents = fs::read(&path)
.with_context(|_| format!("failed to read `{}`", path.display()))?;
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ docopt = "1.0"
env_logger = "0.5"
failure = "0.1.2"
log = "0.4"
parity-wasm = "0.32"
parity-wasm = "0.34"
rouille = { version = "2.1.0", default-features = false }
serde = "1.0"
serde_derive = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn rmain() -> Result<(), Error> {
let mut b = Bindgen::new();
b.debug(debug)
.nodejs(node)
.input_module(module, wasm, |w| parity_wasm::serialize(w).unwrap())
.input_module(module, wasm)
.keep_debug(false)
.generate(&tmpdir)
.context("executing `wasm-bindgen` over the wasm file")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/gc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Support for removing unused items from a wasm executable
"""

[dependencies]
parity-wasm = "0.32"
parity-wasm = "0.34"
log = "0.4"
rustc-demangle = "0.1.9"
1 change: 1 addition & 0 deletions crates/gc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl<'a> LiveContext<'a> {
ValueType::I64 => {}
ValueType::F32 => {}
ValueType::F64 => {}
ValueType::V128 => {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/wasm-interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Micro-interpreter optimized for wasm-bindgen's use case
"""

[dependencies]
parity-wasm = "0.32"
parity-wasm = "0.34"

[dev-dependencies]
tempfile = "3"

0 comments on commit 6a9ad2e

Please sign in to comment.