mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
After this change, any import that only takes and returns ABI-safe numbers (signed integers less than 64 bits and unrestricted floating point numbers) will be a direct import, and will not have a little JS shim in the middle. We don't have a great mechanism for testing the generated bindings' contents -- as opposed to its behavior -- but I manually verified that everything here does the Right Thing and doesn't have a JS shim: ```rust \#[wasm_bindgen] extern "C" { fn trivial(); fn incoming_i32() -> i32; fn incoming_f32() -> f32; fn incoming_f64() -> f64; fn outgoing_i32(x: i32); fn outgoing_f32(y: f32); fn outgoing_f64(z: f64); fn many(x: i32, y: f32, z: f64) -> i32; } ``` Furthermore, I verified that when our support for emitting native `anyref` is enabled, then we do not have a JS shim for the following import, but if it is disabled, then we do have a JS shim: ```rust \#[wasm_bindgen] extern "C" { fn works_when_anyref_support_is_enabled(v: JsValue) -> JsValue; } ``` Fixes #1636.
50 lines
919 B
Rust
50 lines
919 B
Rust
#![cfg(target_arch = "wasm32")]
|
|
|
|
extern crate js_sys;
|
|
extern crate wasm_bindgen;
|
|
extern crate wasm_bindgen_test;
|
|
extern crate wasm_bindgen_test_crate_a;
|
|
extern crate wasm_bindgen_test_crate_b;
|
|
|
|
#[cfg(feature = "serde-serialize")]
|
|
#[macro_use]
|
|
extern crate serde_derive;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
pub mod api;
|
|
pub mod arg_names;
|
|
pub mod char;
|
|
pub mod classes;
|
|
pub mod closures;
|
|
pub mod comments;
|
|
pub mod duplicate_deps;
|
|
pub mod duplicates;
|
|
pub mod enums;
|
|
#[path = "final.rs"]
|
|
pub mod final_;
|
|
pub mod getters_and_setters;
|
|
pub mod import_class;
|
|
pub mod imports;
|
|
pub mod js_objects;
|
|
pub mod jscast;
|
|
pub mod math;
|
|
pub mod no_shims;
|
|
pub mod node;
|
|
pub mod option;
|
|
pub mod optional_primitives;
|
|
pub mod rethrow;
|
|
pub mod simple;
|
|
pub mod slice;
|
|
pub mod structural;
|
|
pub mod u64;
|
|
pub mod validate_prt;
|
|
pub mod variadic;
|
|
pub mod vendor_prefix;
|
|
|
|
// should not be executed
|
|
#[wasm_bindgen(start)]
|
|
pub fn start() {
|
|
panic!();
|
|
}
|