mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-24 18:21:33 +00:00
Add WebIDL support for the ArrayBuffer
type
Should help enable a slew of new bindings as well.
This commit is contained in:
@ -12,8 +12,9 @@ path = 'lib.rs'
|
||||
wasm-bindgen-webidl = { path = '../webidl' }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = { path = '../test' }
|
||||
js-sys = { path = '../js-sys' }
|
||||
wasm-bindgen = { path = '../..' }
|
||||
wasm-bindgen-test = { path = '../test' }
|
||||
|
||||
[[test]]
|
||||
name = 'wasm'
|
||||
|
8
crates/webidl-tests/array_buffer.js
Normal file
8
crates/webidl-tests/array_buffer.js
Normal file
@ -0,0 +1,8 @@
|
||||
global.ArrayBufferTest = class {
|
||||
getBuffer() {
|
||||
return new ArrayBuffer(3);
|
||||
}
|
||||
setBuffer(x) {
|
||||
// ...
|
||||
}
|
||||
};
|
11
crates/webidl-tests/array_buffer.rs
Normal file
11
crates/webidl-tests/array_buffer.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/array_buffer.rs"));
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn take_and_return_a_bunch_of_slices() {
|
||||
let f = ArrayBufferTest::new().unwrap();
|
||||
let x = f.get_buffer();
|
||||
f.set_buffer(None);
|
||||
f.set_buffer(Some(x));
|
||||
}
|
5
crates/webidl-tests/array_buffer.webidl
vendored
Normal file
5
crates/webidl-tests/array_buffer.webidl
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
[Constructor]
|
||||
interface ArrayBufferTest {
|
||||
ArrayBuffer getBuffer();
|
||||
void setBuffer(ArrayBuffer? b);
|
||||
};
|
@ -1,8 +1,9 @@
|
||||
extern crate wasm_bindgen_webidl;
|
||||
|
||||
use std::fs;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let idls = fs::read_dir(".")
|
||||
@ -41,6 +42,10 @@ fn main() {
|
||||
}}
|
||||
"#, js_file.display(), i));
|
||||
|
||||
fs::write(out_file, generated_rust).unwrap();
|
||||
fs::write(&out_file, generated_rust).unwrap();
|
||||
|
||||
// Attempt to run rustfmt, but don't worry if it fails or if it isn't
|
||||
// installed, this is just to help with debugging
|
||||
drop(Command::new("rustfmt").arg(&out_file).status());
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
extern crate js_sys;
|
||||
extern crate wasm_bindgen;
|
||||
extern crate wasm_bindgen_test;
|
||||
|
||||
pub mod array;
|
||||
pub mod array_buffer;
|
||||
pub mod consts;
|
||||
pub mod enums;
|
||||
pub mod simple;
|
||||
pub mod throws;
|
||||
pub mod array;
|
||||
|
Reference in New Issue
Block a user