From 4148d3b4acaa12fc4b042823e18127a064d2852f Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Fri, 10 Aug 2018 13:36:47 -0700 Subject: [PATCH] macro-support: obey `js_class = ...` for constructor methods Fixes #668 --- crates/macro-support/src/parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/macro-support/src/parser.rs b/crates/macro-support/src/parser.rs index 5cc1f0c6..ae7815d5 100644 --- a/crates/macro-support/src/parser.rs +++ b/crates/macro-support/src/parser.rs @@ -166,7 +166,7 @@ impl BindgenAttrs { }).next() } - /// Get the first js_name attribute + /// Get the first js_class attribute fn js_class(&self) -> Option<&str> { self.attrs .iter() @@ -495,6 +495,10 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a Option)> for syn::ForeignItemFn _ => bail_span!(self, "return value of constructor must be a bare path"), }; 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 { class: class_name.to_string(),