mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-24 18:43:33 +03:00
Remove support for the version
attribute
First added in #161 this never ended up panning out, so let's remove the experimental suport which isn't actually used by anything today and hold off on any other changes until an RFC happens.
This commit is contained in:
parent
7f8d510f3d
commit
d5b81595ec
@ -56,7 +56,6 @@ pub enum MethodSelf {
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]
|
||||
pub struct Import {
|
||||
pub module: Option<String>,
|
||||
pub version: Option<String>,
|
||||
pub js_namespace: Option<Ident>,
|
||||
pub kind: ImportKind,
|
||||
}
|
||||
@ -301,33 +300,8 @@ impl Variant {
|
||||
|
||||
impl Import {
|
||||
fn shared(&self) -> Result<shared::Import, Diagnostic> {
|
||||
match (&self.module, &self.version) {
|
||||
(&Some(ref m), None) if m.starts_with("./") => {}
|
||||
(&Some(ref m), &Some(_)) if m.starts_with("./") => {
|
||||
panic!(
|
||||
"when a module path starts with `./` that indicates \
|
||||
that a local file is being imported so the `version` \
|
||||
key cannot also be specified"
|
||||
);
|
||||
}
|
||||
(&Some(_), &Some(_)) => {}
|
||||
(&Some(_), &None) => panic!(
|
||||
"when the `module` directive doesn't start with `./` \
|
||||
then it's interpreted as an NPM package which requires \
|
||||
a `version` to be specified as well, try using \
|
||||
#[wasm_bindgen(module = \"...\", version = \"...\")]"
|
||||
),
|
||||
(&None, &Some(_)) => {
|
||||
panic!(
|
||||
"the #[wasm_bindgen(version = \"...\")] attribute can only \
|
||||
be used when `module = \"...\"` is also specified"
|
||||
);
|
||||
}
|
||||
(&None, &None) => {}
|
||||
}
|
||||
Ok(shared::Import {
|
||||
module: self.module.clone(),
|
||||
version: self.version.clone(),
|
||||
js_namespace: self.js_namespace.as_ref().map(|s| s.to_string()),
|
||||
kind: self.kind.shared(),
|
||||
})
|
||||
|
@ -94,7 +94,6 @@ pub fn ident_ty(ident: Ident) -> syn::Type {
|
||||
pub fn wrap_import_function(function: ast::ImportFunction) -> ast::Import {
|
||||
ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
js_namespace: None,
|
||||
kind: ast::ImportKind::Function(function),
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ base64 = "0.9"
|
||||
failure = "0.1.2"
|
||||
parity-wasm = "0.31"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
tempfile = "3.0"
|
||||
wasm-bindgen-shared = { path = "../shared", version = '=0.2.15' }
|
||||
|
@ -5,7 +5,6 @@ use std::mem;
|
||||
use failure::{Error, ResultExt};
|
||||
use parity_wasm;
|
||||
use parity_wasm::elements::*;
|
||||
use serde_json;
|
||||
use shared;
|
||||
use wasm_gc;
|
||||
|
||||
@ -43,7 +42,6 @@ pub struct Context<'a> {
|
||||
pub exported_classes: HashMap<String, ExportedClass>,
|
||||
pub function_table_needed: bool,
|
||||
pub run_descriptor: &'a Fn(&str) -> Option<Vec<u32>>,
|
||||
pub module_versions: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@ -458,7 +456,6 @@ impl<'a> Context<'a> {
|
||||
|
||||
self.export_table();
|
||||
self.gc()?;
|
||||
self.add_wasm_pack_section();
|
||||
|
||||
while js.contains("\n\n\n") {
|
||||
js = js.replace("\n\n\n", "\n\n");
|
||||
@ -1629,28 +1626,6 @@ impl<'a> Context<'a> {
|
||||
self.globals.push_str("\n");
|
||||
}
|
||||
|
||||
fn add_wasm_pack_section(&mut self) {
|
||||
if self.module_versions.len() == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct WasmPackSchema<'a> {
|
||||
version: &'a str,
|
||||
modules: &'a [(String, String)],
|
||||
}
|
||||
|
||||
let contents = serde_json::to_string(&WasmPackSchema {
|
||||
version: "0.0.1",
|
||||
modules: &self.module_versions,
|
||||
}).unwrap();
|
||||
|
||||
let mut section = CustomSection::default();
|
||||
*section.name_mut() = "__wasm_pack_unstable".to_string();
|
||||
*section.payload_mut() = contents.into_bytes();
|
||||
self.module.sections_mut().push(Section::Custom(section));
|
||||
}
|
||||
|
||||
fn use_node_require(&self) -> bool {
|
||||
self.config.nodejs && !self.config.nodejs_experimental_modules
|
||||
}
|
||||
@ -1766,7 +1741,6 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
}
|
||||
|
||||
fn generate_import(&mut self, import: &shared::Import) -> Result<(), Error> {
|
||||
self.validate_import_module(import)?;
|
||||
match import.kind {
|
||||
shared::ImportKind::Function(ref f) => {
|
||||
self.generate_import_function(import, f).with_context(|_| {
|
||||
@ -1787,41 +1761,6 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn validate_import_module(&mut self, import: &shared::Import) -> Result<(), Error> {
|
||||
let version = match import.version {
|
||||
Some(ref s) => s,
|
||||
None => return Ok(()),
|
||||
};
|
||||
let module = match import.module {
|
||||
Some(ref s) => s,
|
||||
None => return Ok(()),
|
||||
};
|
||||
if module.starts_with("./") {
|
||||
return Ok(());
|
||||
}
|
||||
let pkg = if module.starts_with("@") {
|
||||
// Translate `@foo/bar/baz` to `@foo/bar` and `@foo/bar` to itself
|
||||
let first_slash = match module.find('/') {
|
||||
Some(i) => i,
|
||||
None => bail!(
|
||||
"packages starting with `@` must be of the form \
|
||||
`@foo/bar`, but found: `{}`",
|
||||
module
|
||||
),
|
||||
};
|
||||
match module[first_slash + 1..].find('/') {
|
||||
Some(i) => &module[..i],
|
||||
None => module,
|
||||
}
|
||||
} else {
|
||||
module.split('/').next().unwrap()
|
||||
};
|
||||
self.cx
|
||||
.module_versions
|
||||
.push((pkg.to_string(), version.clone()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_import_static(
|
||||
&mut self,
|
||||
info: &shared::Import,
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
extern crate parity_wasm;
|
||||
extern crate wasm_bindgen_shared as shared;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate wasm_gc;
|
||||
extern crate wasmi;
|
||||
@ -203,7 +201,6 @@ impl Bindgen {
|
||||
config: &self,
|
||||
module: &mut module,
|
||||
function_table_needed: false,
|
||||
module_versions: Default::default(),
|
||||
run_descriptor: &|name| {
|
||||
let mut v = MyExternals(Vec::new());
|
||||
match instance.invoke_export(name, &[], &mut v) {
|
||||
|
@ -29,7 +29,7 @@ fn apply() {
|
||||
assert_eq!(Array::from(&arr).length(), 1);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Function.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Function.js")]
|
||||
extern {
|
||||
fn get_function_to_bind() -> Function;
|
||||
fn get_value_to_bind_to() -> JsValue;
|
||||
|
@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Generator.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Generator.js")]
|
||||
extern {
|
||||
fn one_two_generator() -> Generator;
|
||||
fn dummy_generator() -> Generator;
|
||||
|
@ -10,7 +10,7 @@ extern {
|
||||
fn set_foo(this: &Foo42, val: JsValue);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Object.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Object.js")]
|
||||
extern {
|
||||
fn map_with_symbol_key() -> Object;
|
||||
fn symbol_key() -> JsValue;
|
||||
|
@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Proxy.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Proxy.js")]
|
||||
extern {
|
||||
fn proxy_target() -> JsValue;
|
||||
fn proxy_handler() -> Object;
|
||||
|
@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Reflect.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Reflect.js")]
|
||||
extern {
|
||||
fn get_char_at() -> Function;
|
||||
|
||||
|
@ -2,7 +2,7 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Symbol.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/Symbol.js")]
|
||||
extern {
|
||||
fn test_has_instance(sym: &Symbol);
|
||||
fn test_is_concat_spreadable(sym: &Symbol);
|
||||
|
@ -53,17 +53,6 @@ impl BindgenAttrs {
|
||||
.next()
|
||||
}
|
||||
|
||||
/// Get the first version attribute
|
||||
fn version(&self) -> Option<&str> {
|
||||
self.attrs
|
||||
.iter()
|
||||
.filter_map(|a| match a {
|
||||
BindgenAttr::Version(s) => Some(&s[..]),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
}
|
||||
|
||||
/// Whether the catch attribute is present
|
||||
fn catch(&self) -> bool {
|
||||
self.attrs.iter().any(|a| match a {
|
||||
@ -195,7 +184,6 @@ pub enum BindgenAttr {
|
||||
StaticMethodOf(Ident),
|
||||
JsNamespace(Ident),
|
||||
Module(String),
|
||||
Version(String),
|
||||
Getter(Option<Ident>),
|
||||
Setter(Option<Ident>),
|
||||
Structural,
|
||||
@ -257,13 +245,6 @@ impl syn::synom::Synom for BindgenAttr {
|
||||
(s.value())
|
||||
)=> { BindgenAttr::Module }
|
||||
|
|
||||
do_parse!(
|
||||
call!(term, "version") >>
|
||||
punct!(=) >>
|
||||
s: syn!(syn::LitStr) >>
|
||||
(s.value())
|
||||
)=> { BindgenAttr::Version }
|
||||
|
|
||||
do_parse!(
|
||||
call!(term, "js_name") >>
|
||||
punct!(=) >>
|
||||
@ -909,10 +890,6 @@ impl<'a> MacroParse<&'a BindgenAttrs> for syn::ForeignItem {
|
||||
BindgenAttrs::find(attrs)?
|
||||
};
|
||||
let module = item_opts.module().or(opts.module()).map(|s| s.to_string());
|
||||
let version = item_opts
|
||||
.version()
|
||||
.or(opts.version())
|
||||
.map(|s| s.to_string());
|
||||
let js_namespace = item_opts.js_namespace().or(opts.js_namespace()).cloned();
|
||||
let kind = match self {
|
||||
syn::ForeignItem::Fn(f) => f.convert((item_opts, &module))?,
|
||||
@ -923,7 +900,6 @@ impl<'a> MacroParse<&'a BindgenAttrs> for syn::ForeignItem {
|
||||
|
||||
program.imports.push(ast::Import {
|
||||
module,
|
||||
version,
|
||||
js_namespace,
|
||||
kind,
|
||||
});
|
||||
|
@ -24,7 +24,6 @@ pub struct Program {
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Import {
|
||||
pub module: Option<String>,
|
||||
pub version: Option<String>,
|
||||
pub js_namespace: Option<String>,
|
||||
pub kind: ImportKind,
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ fn main() {
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
#[wasm_bindgen(module = "{}", version = "*")]
|
||||
#[wasm_bindgen(module = "{}")]
|
||||
extern {{
|
||||
fn not_actually_a_function{1}();
|
||||
}}
|
||||
|
@ -240,7 +240,6 @@ impl<'src> WebidlParse<'src, ()> for weedle::InterfaceDefinition<'src> {
|
||||
|
||||
program.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Type(backend::ast::ImportType {
|
||||
vis: public(),
|
||||
@ -718,7 +717,6 @@ impl<'src> WebidlParse<'src, ()> for weedle::EnumDefinition<'src> {
|
||||
let variants = &self.values.body.list;
|
||||
program.imports.push(backend::ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Enum(backend::ast::ImportEnum {
|
||||
vis: public(),
|
||||
|
@ -5,37 +5,6 @@ controlling precisely how imports are imported and what they map to in JS. This
|
||||
section is intended to hopefully be an exhaustive reference of the
|
||||
possibilities!
|
||||
|
||||
* `module` and `version` - we've seen `module` so far indicating where we can
|
||||
import items from but `version` is also allowed:
|
||||
|
||||
```rust
|
||||
#[wasm_bindgen(module = "moment", version = "^2.0.0")]
|
||||
extern {
|
||||
type Moment;
|
||||
fn moment() -> Moment;
|
||||
#[wasm_bindgen(method)]
|
||||
fn format(this: &Moment) -> String;
|
||||
}
|
||||
```
|
||||
|
||||
The `module` key is used to configure the module that each item is imported
|
||||
from. The `version` key does not affect the generated wasm itself but rather
|
||||
it's an informative directive for tools like [wasm-pack]. Tools like wasm-pack
|
||||
will generate a `package.json` for you and the `version` listed here, when
|
||||
`module` is also an NPM package, will correspond to what to write down in
|
||||
`package.json`.
|
||||
|
||||
In other words the usage of `module` as the name of an NPM package and
|
||||
`version` as the version requirement allows you to, inline in Rust, depend on
|
||||
the NPM ecosystem and import functionality from those packages. When bundled
|
||||
with a tool like [wasm-pack] everything will automatically get wired up with
|
||||
bundlers and you should be good to go!
|
||||
|
||||
Note that the `version` is *required* if `module` doesn't start with `./`. If
|
||||
`module` starts with `./` then it is an error to provide a version.
|
||||
|
||||
[wasm-pack]: https://github.com/rustwasm/wasm-pack
|
||||
|
||||
* `catch` - this attribute allows catching a JS exception. This can be attached
|
||||
to any imported function and the function must return a `Result` where the
|
||||
`Err` payload is a `JsValue`, like so:
|
||||
|
@ -1,52 +0,0 @@
|
||||
use super::project;
|
||||
|
||||
#[test]
|
||||
fn versions() {
|
||||
project()
|
||||
.debug(false)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
#![feature(use_extern_macros)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "webpack", version = "^0.2.0")]
|
||||
extern {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() {
|
||||
foo();
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.js",
|
||||
r#"
|
||||
import * as fs from 'fs';
|
||||
import * as assert from 'assert';
|
||||
|
||||
export function test() {
|
||||
const bytes = fs.readFileSync('out_bg.wasm');
|
||||
const m = new WebAssembly.Module(bytes);
|
||||
const name = '__wasm_pack_unstable';
|
||||
const sections = WebAssembly.Module.customSections(m, name);
|
||||
assert.strictEqual(sections.length, 1);
|
||||
const b = new Uint8Array(sections[0]);
|
||||
const buf = new Buffer(b);
|
||||
const map = JSON.parse(buf.toString());
|
||||
assert.deepStrictEqual(map, {
|
||||
version: '0.0.1',
|
||||
modules: [
|
||||
['webpack', '^0.2.0']
|
||||
]
|
||||
});
|
||||
};
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
}
|
@ -5,5 +5,4 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
|
||||
use project_builder::project;
|
||||
|
||||
mod comments;
|
||||
mod imports;
|
||||
mod typescript;
|
||||
|
@ -4,7 +4,7 @@ extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js")]
|
||||
extern {
|
||||
fn foo();
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js")]
|
||||
extern {
|
||||
fn foo(x: u32);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/api.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/api.js")]
|
||||
extern {
|
||||
fn js_works();
|
||||
fn js_eq_works();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/char.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/char.js")]
|
||||
extern {
|
||||
fn js_identity(c: char) -> char;
|
||||
fn js_works();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/classes.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/classes.js")]
|
||||
extern {
|
||||
fn js_simple();
|
||||
fn js_strings();
|
||||
|
@ -3,7 +3,7 @@ use wasm_bindgen::prelude::*;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/closures.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/closures.js")]
|
||||
extern {
|
||||
fn works_call(a: &Fn());
|
||||
fn works_thread(a: &Fn(u32) -> u32) -> u32;
|
||||
|
@ -3,7 +3,7 @@ use wasm_bindgen_test::*;
|
||||
use wasm_bindgen_test_crate_a as a;
|
||||
use wasm_bindgen_test_crate_b as b;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js")]
|
||||
extern {
|
||||
fn assert_next_undefined();
|
||||
fn assert_next_ten();
|
||||
|
@ -3,7 +3,7 @@ use wasm_bindgen_test::*;
|
||||
pub mod same_function_different_locations_a {
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_a.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_a.js")]
|
||||
extern {
|
||||
pub fn foo();
|
||||
}
|
||||
@ -12,7 +12,7 @@ pub mod same_function_different_locations_a {
|
||||
pub mod same_function_different_locations_b {
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_a.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_a.js")]
|
||||
extern {
|
||||
pub fn foo();
|
||||
}
|
||||
@ -27,7 +27,7 @@ fn same_function_different_locations() {
|
||||
pub mod same_function_different_modules_a {
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_b.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_b.js")]
|
||||
extern {
|
||||
pub fn foo() -> bool;
|
||||
}
|
||||
@ -36,7 +36,7 @@ pub mod same_function_different_modules_a {
|
||||
pub mod same_function_different_modules_b {
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_c.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/duplicates_c.js")]
|
||||
extern {
|
||||
pub fn foo() -> bool;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use self::inner::ColorWithCustomValues;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/enums.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/enums.js")]
|
||||
extern {
|
||||
fn js_c_style_enum();
|
||||
fn js_c_style_enum_with_custom_values();
|
||||
|
@ -5,7 +5,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/import_class.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/import_class.js")]
|
||||
extern {
|
||||
fn math_log(f: f64) -> f64;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/imports.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/imports.js")]
|
||||
extern {
|
||||
fn test_simple();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/js_objects.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/js_objects.js")]
|
||||
extern {
|
||||
fn simple_foo(s: &JsValue);
|
||||
fn js_simple();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/math.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/math.js")]
|
||||
extern {
|
||||
fn js_auto_bind_math();
|
||||
}
|
||||
@ -64,4 +64,4 @@ pub fn math(a: f32, b: f64) -> f64 {
|
||||
#[wasm_bindgen_test]
|
||||
fn auto_bind_math() {
|
||||
js_auto_bind_math();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/node.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/node.js")]
|
||||
extern {
|
||||
fn test_works();
|
||||
static FOO: JsValue;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/option.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/option.js")]
|
||||
extern {
|
||||
pub type MyType;
|
||||
#[wasm_bindgen(constructor)]
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/optional_primitives.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/optional_primitives.js")]
|
||||
extern {
|
||||
fn optional_i32_js_identity(a: Option<i32>) -> Option<i32>;
|
||||
fn optional_u32_js_identity(a: Option<u32>) -> Option<u32>;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/simple.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/simple.js")]
|
||||
extern {
|
||||
fn test_add();
|
||||
fn test_string_arguments();
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js")]
|
||||
extern {
|
||||
fn js_export();
|
||||
|
||||
@ -44,7 +44,7 @@ fn export() {
|
||||
|
||||
macro_rules! import_macro {
|
||||
($(($rust:ident, $js:ident, $i:ident))*) => ($(
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js")]
|
||||
extern {
|
||||
fn $js(a: &[$i]) -> Vec<$i>;
|
||||
}
|
||||
@ -105,7 +105,7 @@ fn pass_array() {
|
||||
macro_rules! import_mut_macro {
|
||||
($(($rust:ident, $js:ident, $i:ident))*) => (
|
||||
$(
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/slice.js")]
|
||||
extern {
|
||||
fn $js(a: &mut [$i]);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/structural.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/structural.js")]
|
||||
extern {
|
||||
fn js_works();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/u64.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/u64.js")]
|
||||
extern {
|
||||
fn i64_js_identity(a: i64) -> i64;
|
||||
fn u64_js_identity(a: u64) -> u64;
|
||||
|
@ -1,7 +1,7 @@
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/validate_prt.js", version = "*")]
|
||||
#[wasm_bindgen(module = "tests/wasm/validate_prt.js")]
|
||||
extern {
|
||||
fn js_works();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user