mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-22 09:11:35 +00:00
webidl: emit methods for regular operations
This commit is contained in:
@ -8,34 +8,4 @@ extern crate wasm_bindgen_webidl as wb_webidl;
|
||||
mod util;
|
||||
use util::*;
|
||||
|
||||
/// Tests for parsing WebIDL into an expected wasm-bindgen AST.
|
||||
mod parse {
|
||||
use super::*;
|
||||
|
||||
assert_parse!(empty, backend::ast::Program::default());
|
||||
|
||||
assert_parse!(
|
||||
Event,
|
||||
backend::ast::Program {
|
||||
exports: vec![],
|
||||
imports: vec![backend::ast::Import {
|
||||
module: None,
|
||||
version: None,
|
||||
js_namespace: None,
|
||||
kind: backend::ast::ImportKind::Type(backend::ast::ImportType {
|
||||
vis: syn::Visibility::Public(syn::VisPublic {
|
||||
pub_token: Default::default(),
|
||||
}),
|
||||
name: syn::Ident::new("Event", proc_macro2::Span::call_site()),
|
||||
}),
|
||||
}],
|
||||
enums: vec![],
|
||||
structs: vec![],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// Tests for compiling WebIDL into Rust bindings.
|
||||
mod compile {
|
||||
assert_compile!(Event);
|
||||
}
|
||||
assert_compile!(Event);
|
||||
|
@ -1,31 +1,9 @@
|
||||
use backend;
|
||||
use diff;
|
||||
use std::io::{self, Write};
|
||||
use std::process;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use wb_webidl;
|
||||
|
||||
pub fn assert_parse(webidl: &str, expected: backend::ast::Program) {
|
||||
let actual = wb_webidl::parse(webidl).expect("should parse the webidl source OK");
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
macro_rules! assert_parse {
|
||||
($test_name:ident, $expected_ast:expr) => {
|
||||
#[test]
|
||||
#[allow(non_snake_case)]
|
||||
fn $test_name() {
|
||||
let webidl_source = include_str!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/tests/fixtures/",
|
||||
stringify!($test_name),
|
||||
".webidl"
|
||||
));
|
||||
$crate::assert_parse(webidl_source, $expected_ast);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn rustfmt<S: Into<String>>(source: S) -> (String, String) {
|
||||
let source = source.into();
|
||||
|
||||
|
@ -53,6 +53,124 @@ impl From<Event> for ::wasm_bindgen::JsValue {
|
||||
obj.obj
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "C" fn __wbindgen_describe___wbg_f_stopPropagation_stopPropagation_Event() {
|
||||
use wasm_bindgen::describe::*;
|
||||
inform(FUNCTION);
|
||||
inform(1u32);
|
||||
<&Event as WasmDescribe>::describe();
|
||||
inform(0);
|
||||
}
|
||||
impl Event {
|
||||
#[allow(bad_style)]
|
||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||
pub extern "C" fn stopPropagation(&self) {
|
||||
::wasm_bindgen::__rt::link_this_library();
|
||||
#[wasm_import_module = "__wbindgen_placeholder__"]
|
||||
extern "C" {
|
||||
fn __wbg_f_stopPropagation_stopPropagation_Event(
|
||||
self_: <&Event as ::wasm_bindgen::convert::IntoWasmAbi>::Abi,
|
||||
) -> ();
|
||||
}
|
||||
unsafe {
|
||||
let _ret = {
|
||||
let mut __stack = ::wasm_bindgen::convert::GlobalStack::new();
|
||||
let self_ =
|
||||
<&Event as ::wasm_bindgen::convert::IntoWasmAbi>::into_abi(self, &mut __stack);
|
||||
__wbg_f_stopPropagation_stopPropagation_Event(self_)
|
||||
};
|
||||
()
|
||||
}
|
||||
}
|
||||
#[allow(bad_style, unused_variables)]
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
||||
pub extern "C" fn stopPropagation(&self) {
|
||||
panic!(
|
||||
"cannot call wasm-bindgen imported functions on \
|
||||
non-wasm targets"
|
||||
);
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "C" fn __wbindgen_describe___wbg_f_stopImmediatePropagation_stopImmediatePropagation_Event(
|
||||
) {
|
||||
use wasm_bindgen::describe::*;
|
||||
inform(FUNCTION);
|
||||
inform(1u32);
|
||||
<&Event as WasmDescribe>::describe();
|
||||
inform(0);
|
||||
}
|
||||
impl Event {
|
||||
#[allow(bad_style)]
|
||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||
pub extern "C" fn stopImmediatePropagation(&self) {
|
||||
::wasm_bindgen::__rt::link_this_library();
|
||||
#[wasm_import_module = "__wbindgen_placeholder__"]
|
||||
extern "C" {
|
||||
fn __wbg_f_stopImmediatePropagation_stopImmediatePropagation_Event(
|
||||
self_: <&Event as ::wasm_bindgen::convert::IntoWasmAbi>::Abi,
|
||||
) -> ();
|
||||
}
|
||||
unsafe {
|
||||
let _ret = {
|
||||
let mut __stack = ::wasm_bindgen::convert::GlobalStack::new();
|
||||
let self_ =
|
||||
<&Event as ::wasm_bindgen::convert::IntoWasmAbi>::into_abi(self, &mut __stack);
|
||||
__wbg_f_stopImmediatePropagation_stopImmediatePropagation_Event(self_)
|
||||
};
|
||||
()
|
||||
}
|
||||
}
|
||||
#[allow(bad_style, unused_variables)]
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
||||
pub extern "C" fn stopImmediatePropagation(&self) {
|
||||
panic!(
|
||||
"cannot call wasm-bindgen imported functions on \
|
||||
non-wasm targets"
|
||||
);
|
||||
}
|
||||
}
|
||||
#[no_mangle]
|
||||
#[allow(non_snake_case)]
|
||||
pub extern "C" fn __wbindgen_describe___wbg_f_preventDefault_preventDefault_Event() {
|
||||
use wasm_bindgen::describe::*;
|
||||
inform(FUNCTION);
|
||||
inform(1u32);
|
||||
<&Event as WasmDescribe>::describe();
|
||||
inform(0);
|
||||
}
|
||||
impl Event {
|
||||
#[allow(bad_style)]
|
||||
#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))]
|
||||
pub extern "C" fn preventDefault(&self) {
|
||||
::wasm_bindgen::__rt::link_this_library();
|
||||
#[wasm_import_module = "__wbindgen_placeholder__"]
|
||||
extern "C" {
|
||||
fn __wbg_f_preventDefault_preventDefault_Event(
|
||||
self_: <&Event as ::wasm_bindgen::convert::IntoWasmAbi>::Abi,
|
||||
) -> ();
|
||||
}
|
||||
unsafe {
|
||||
let _ret = {
|
||||
let mut __stack = ::wasm_bindgen::convert::GlobalStack::new();
|
||||
let self_ =
|
||||
<&Event as ::wasm_bindgen::convert::IntoWasmAbi>::into_abi(self, &mut __stack);
|
||||
__wbg_f_preventDefault_preventDefault_Event(self_)
|
||||
};
|
||||
()
|
||||
}
|
||||
}
|
||||
#[allow(bad_style, unused_variables)]
|
||||
#[cfg(not(all(target_arch = "wasm32", not(target_os = "emscripten"))))]
|
||||
pub extern "C" fn preventDefault(&self) {
|
||||
panic!(
|
||||
"cannot call wasm-bindgen imported functions on \
|
||||
non-wasm targets"
|
||||
);
|
||||
}
|
||||
}
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[wasm_custom_section = "__wasm_bindgen_unstable"]
|
||||
const __WASM_BINDGEN_GENERATED_wasm_bindgen_webidl_0_1_0_0 : [ u8 ; 180usize ] = * b"\xB0\0\0\0{\"exports\":[],\"enums\":[],\"imports\":[{\"module\":null,\"version\":null,\"js_namespace\":null,\"kind\":{\"kind\":\"type\"}}],\"structs\":[],\"version\":\"0.2.11 (3879f6f42)\",\"schema_version\":\"4\"}" ;
|
||||
|
@ -3,4 +3,4 @@
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
mod Event;
|
||||
pub mod Event;
|
||||
|
Reference in New Issue
Block a user