Skip to content

Commit

Permalink
Updates wasm-bindgen and refactors readData() buffer handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Aug 23, 2020
1 parent cc77667 commit d3cc038
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cache: cargo
before_script:
if [[ $(cargo install --list | grep wasm-pack | wc -c) -eq 0 ]]; then cargo install wasm-pack; fi
script:
wasm-pack build --release
wasm-pack build --target web --release
before_deploy:
mv pkg/symatem_bg.wasm symatem.wasm
deploy:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2.59"
wasm-bindgen = "0.2.67"

[package.metadata.wasm-pack.profile.release]
wasm-opt = ["-Oz", "--enable-mutable-globals"]
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ pub fn creaseLength(namespace_identity: symbol::Identity, symbol_identity: symbo
}

#[wasm_bindgen]
pub fn readData(namespace_identity: symbol::Identity, symbol_identity: symbol::Identity, offset: usize, length: usize, dst: &mut [usize]) -> bool {
graph::read_data(symbol::Symbol(namespace_identity, symbol_identity), offset, length, dst)
pub fn readData(namespace_identity: symbol::Identity, symbol_identity: symbol::Identity, offset: usize, length: usize) -> Option<Vec<u8>> {
let mut dst: Vec<usize> = vec![0; (length+bitops::ARCHITECTURE_SIZE-1)/bitops::ARCHITECTURE_SIZE];
if graph::read_data(symbol::Symbol(namespace_identity, symbol_identity), offset, length, &mut dst) {
Some(unsafe { transmute_vec::<usize, u8>(dst) })
} else {
None
}
}

#[wasm_bindgen]
Expand Down

0 comments on commit d3cc038

Please sign in to comment.