mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-03 08:01:23 +00:00
Merge pull request #819 from fitzgen/webidl-interfaces-should-extend-object
webidl: All interfaces implicitly extend `Object`
This commit is contained in:
commit
2fc499d66d
@ -15,5 +15,6 @@
|
|||||||
|
|
||||||
extern crate wasm_bindgen;
|
extern crate wasm_bindgen;
|
||||||
extern crate js_sys;
|
extern crate js_sys;
|
||||||
|
use js_sys::Object;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
use futures::future::Future;
|
use futures::future::Future;
|
||||||
use js_sys::Promise;
|
use js_sys::{Object, Promise};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen::JsCast;
|
||||||
use wasm_bindgen_futures::JsFuture;
|
use wasm_bindgen_futures::JsFuture;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
use web_sys::Event;
|
use web_sys::Event;
|
||||||
@ -15,6 +16,10 @@ fn event() -> impl Future<Item = (), Error = JsValue> {
|
|||||||
JsFuture::from(new_event())
|
JsFuture::from(new_event())
|
||||||
.map(Event::from)
|
.map(Event::from)
|
||||||
.map(|event| {
|
.map(|event| {
|
||||||
|
// All DOM interfaces should inherit from `Object`.
|
||||||
|
assert!(event.is_instance_of::<Object>());
|
||||||
|
let _: &Object = event.as_ref();
|
||||||
|
|
||||||
// These should match `new Event`.
|
// These should match `new Event`.
|
||||||
assert!(event.bubbles());
|
assert!(event.bubbles());
|
||||||
assert!(event.cancelable());
|
assert!(event.cancelable());
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/array.rs"));
|
include!(concat!(env!("OUT_DIR"), "/array.rs"));
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/array_buffer.rs"));
|
include!(concat!(env!("OUT_DIR"), "/array_buffer.rs"));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
use js_sys::Function;
|
use js_sys::{Function, Object};
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/callbacks.rs"));
|
include!(concat!(env!("OUT_DIR"), "/callbacks.rs"));
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
|
include!(concat!(env!("OUT_DIR"), "/consts.rs"));
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/enums.rs"));
|
include!(concat!(env!("OUT_DIR"), "/enums.rs"));
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/global.rs"));
|
include!(concat!(env!("OUT_DIR"), "/global.rs"));
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/simple.rs"));
|
include!(concat!(env!("OUT_DIR"), "/simple.rs"));
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn interfaces_inherit_from_object() {
|
||||||
|
let m = Method::new(42.0).unwrap();
|
||||||
|
assert!(m.is_instance_of::<Object>());
|
||||||
|
let _: &Object = m.as_ref();
|
||||||
|
}
|
||||||
|
|
||||||
#[wasm_bindgen_test]
|
#[wasm_bindgen_test]
|
||||||
fn method() {
|
fn method() {
|
||||||
let pi = Method::new(3.14159).unwrap();
|
let pi = Method::new(3.14159).unwrap();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use js_sys::Object;
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/throws.rs"));
|
include!(concat!(env!("OUT_DIR"), "/throws.rs"));
|
||||||
|
@ -120,7 +120,10 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>)
|
|||||||
// `AsRef` and such implementations.
|
// `AsRef` and such implementations.
|
||||||
for import in program.imports.iter_mut() {
|
for import in program.imports.iter_mut() {
|
||||||
if let backend::ast::ImportKind::Type(t) = &mut import.kind {
|
if let backend::ast::ImportKind::Type(t) = &mut import.kind {
|
||||||
t.extends.retain(|n| filter(&n.to_string()));
|
t.extends.retain(|n| {
|
||||||
|
first_pass_record.builtin_idents.contains(n) ||
|
||||||
|
filter(&n.to_string())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,6 +448,7 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
instanceof_shim: format!("__widl_instanceof_{}", name),
|
instanceof_shim: format!("__widl_instanceof_{}", name),
|
||||||
extends: self.all_superclasses(name)
|
extends: self.all_superclasses(name)
|
||||||
.map(|name| Ident::new(&name, Span::call_site()))
|
.map(|name| Ident::new(&name, Span::call_site()))
|
||||||
|
.chain(Some(Ident::new("Object", Span::call_site())))
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
self.append_required_features_doc(&import_type, &mut doc_comment);
|
self.append_required_features_doc(&import_type, &mut doc_comment);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user