macro-support: obey js_class = ... for constructor methods

Fixes #668
This commit is contained in:
Nick Fitzgerald 2018-08-10 13:36:47 -07:00
parent 7af4e62d99
commit 4148d3b4ac

View File

@ -166,7 +166,7 @@ impl BindgenAttrs {
}).next() }).next()
} }
/// Get the first js_name attribute /// Get the first js_class attribute
fn js_class(&self) -> Option<&str> { fn js_class(&self) -> Option<&str> {
self.attrs self.attrs
.iter() .iter()
@ -495,6 +495,10 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a Option<String>)> for syn::ForeignItemFn
_ => bail_span!(self, "return value of constructor must be a bare path"), _ => bail_span!(self, "return value of constructor must be a bare path"),
}; };
let class_name = extract_path_ident(class_name)?; let class_name = extract_path_ident(class_name)?;
let class_name = opts
.js_class()
.map(Into::into)
.unwrap_or_else(|| class_name.to_string());
ast::ImportFunctionKind::Method { ast::ImportFunctionKind::Method {
class: class_name.to_string(), class: class_name.to_string(),