mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-24 06:33:33 +03:00
parent
7ec1511d3d
commit
5df8e20815
@ -143,7 +143,7 @@ pub struct ImportType {
|
|||||||
pub attrs: Vec<syn::Attribute>,
|
pub attrs: Vec<syn::Attribute>,
|
||||||
pub doc_comment: Option<String>,
|
pub doc_comment: Option<String>,
|
||||||
pub instanceof_shim: String,
|
pub instanceof_shim: String,
|
||||||
pub extends: Vec<Ident>,
|
pub extends: Vec<syn::Path>,
|
||||||
pub vendor_prefixes: Vec<Ident>,
|
pub vendor_prefixes: Vec<Ident>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ impl ImportedTypes for ast::ImportType {
|
|||||||
{
|
{
|
||||||
f(&self.rust_name, ImportedTypeKind::Definition);
|
f(&self.rust_name, ImportedTypeKind::Definition);
|
||||||
for class in self.extends.iter() {
|
for class in self.extends.iter() {
|
||||||
f(class, ImportedTypeKind::Reference);
|
class.imported_types(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ impl BindgenAttrs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Return the list of classes that a type extends
|
/// Return the list of classes that a type extends
|
||||||
fn extends(&self) -> impl Iterator<Item = &Ident> {
|
fn extends(&self) -> impl Iterator<Item = &syn::Path> {
|
||||||
self.attrs.iter().filter_map(|a| match a {
|
self.attrs.iter().filter_map(|a| match a {
|
||||||
BindgenAttr::Extends(s) => Some(s),
|
BindgenAttr::Extends(s) => Some(s),
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -232,7 +232,7 @@ pub enum BindgenAttr {
|
|||||||
Readonly,
|
Readonly,
|
||||||
JsName(String, Span),
|
JsName(String, Span),
|
||||||
JsClass(String),
|
JsClass(String),
|
||||||
Extends(Ident),
|
Extends(syn::Path),
|
||||||
VendorPrefix(Ident),
|
VendorPrefix(Ident),
|
||||||
Variadic,
|
Variadic,
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ impl Parse for BindgenAttr {
|
|||||||
}
|
}
|
||||||
if attr == "extends" {
|
if attr == "extends" {
|
||||||
input.parse::<Token![=]>()?;
|
input.parse::<Token![=]>()?;
|
||||||
return Ok(BindgenAttr::Extends(input.parse::<AnyIdent>()?.0));
|
return Ok(BindgenAttr::Extends(input.parse()?));
|
||||||
}
|
}
|
||||||
if attr == "vendor_prefix" {
|
if attr == "vendor_prefix" {
|
||||||
input.parse::<Token![=]>()?;
|
input.parse::<Token![=]>()?;
|
||||||
|
@ -126,8 +126,11 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>) -> Result<Program>
|
|||||||
// `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
|
t.extends.retain(|n| {
|
||||||
.retain(|n| first_pass_record.builtin_idents.contains(n) || filter(&n.to_string()));
|
let ident = &n.segments.last().unwrap().value().ident;
|
||||||
|
first_pass_record.builtin_idents.contains(ident) ||
|
||||||
|
filter(&ident.to_string())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,8 +518,8 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
self.append_required_features_doc(&import_type, &mut doc_comment, extra);
|
self.append_required_features_doc(&import_type, &mut doc_comment, extra);
|
||||||
import_type.extends = self
|
import_type.extends = self
|
||||||
.all_superclasses(name)
|
.all_superclasses(name)
|
||||||
.map(|name| Ident::new(&name, Span::call_site()))
|
.map(|name| Ident::new(&name, Span::call_site()).into())
|
||||||
.chain(Some(Ident::new("Object", Span::call_site())))
|
.chain(Some(Ident::new("Object", Span::call_site()).into()))
|
||||||
.collect();
|
.collect();
|
||||||
import_type.doc_comment = doc_comment;
|
import_type.doc_comment = doc_comment;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ extern "C" {
|
|||||||
#[wasm_bindgen(constructor)]
|
#[wasm_bindgen(constructor)]
|
||||||
fn new() -> JsCast3;
|
fn new() -> JsCast3;
|
||||||
|
|
||||||
#[wasm_bindgen(extends = JsCast1, extends = JsCast3)]
|
#[wasm_bindgen(extends = ::jscast::JsCast1, extends = JsCast3)]
|
||||||
type JsCast4;
|
type JsCast4;
|
||||||
#[wasm_bindgen(constructor)]
|
#[wasm_bindgen(constructor)]
|
||||||
fn new() -> JsCast4;
|
fn new() -> JsCast4;
|
||||||
|
Loading…
Reference in New Issue
Block a user