mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Address feedback on commit dab6ba1
This commit is contained in:
parent
dab6ba1df8
commit
37da9eba14
@ -402,7 +402,7 @@ are:
|
||||
* Imported types in a foreign module annotated with `#[wasm_bindgen]`
|
||||
* Borrowed exported structs (`&Foo` or `&mut Bar`)
|
||||
* The `JsValue` type and `&JsValue` (not mutable references)
|
||||
* Vectors and slices of supported integer types
|
||||
* Vectors and slices of supported integer types and of the `JsValue` type.
|
||||
|
||||
All of the above can also be returned except borrowed references. Strings are
|
||||
implemented with shim functions to copy data in/out of the Rust heap. That is, a
|
||||
|
@ -660,12 +660,12 @@ impl<'a> Context<'a> {
|
||||
if !self.exposed_globals.insert("get_array_js_value_from_wasm") {
|
||||
return
|
||||
}
|
||||
self.expose_get_array_u8_from_wasm();
|
||||
self.expose_get_array_u32_from_wasm();
|
||||
self.expose_get_object();
|
||||
self.globals.push_str(&format!("
|
||||
function getArrayJsValueFromWasm(ptr, len) {{
|
||||
const mem = getUint8Memory();
|
||||
const slice = mem.slice(ptr, ptr + len);
|
||||
const mem = getUint32Memory();
|
||||
const slice = mem.slice(ptr / 4, ptr / 4 + len);
|
||||
const result = []
|
||||
for (ptr in slice) {{
|
||||
result.push(getObject(ptr))
|
||||
@ -1569,7 +1569,7 @@ impl VectorType {
|
||||
VectorKind::U32 => "Uint32Array",
|
||||
VectorKind::F32 => "Float32Array",
|
||||
VectorKind::F64 => "Float64Array",
|
||||
VectorKind::JsValue => "object[]",
|
||||
VectorKind::JsValue => "any[]",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,8 +206,7 @@ fn returning_vector() {
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
|
||||
export function foo(): any { return { "foo": "bar" } }
|
||||
export function foo(): any { return { "foo": "bar" }; }
|
||||
|
||||
export function test() {
|
||||
const result = wasm.bar();
|
||||
|
Loading…
x
Reference in New Issue
Block a user