This commit is contained in:
Alex Crichton
2018-02-05 16:39:11 -08:00
parent 8f8da49dab
commit 0320bc0d7c
5 changed files with 163 additions and 19 deletions

View File

@ -256,7 +256,7 @@ impl Function {
syn::Ident::from(generated_name)
}
fn shared(&self) -> shared::Function {
pub fn shared(&self) -> shared::Function {
shared::Function {
name: self.name.as_ref().to_string(),
arguments: self.arguments.iter().map(|t| t.shared()).collect(),

View File

@ -429,10 +429,9 @@ impl ToTokens for Receiver {
}
fn bindgen_import(import: &ast::Import, tokens: &mut Tokens) {
bindgen_import_function(&import.function,
&import.function.ident.to_string(),
Some(&import.module),
tokens);
let import_name = import.function.wasm_function.shared()
.mangled_import_name(None);
bindgen_import_function(&import.function, &import_name, tokens);
}
fn bindgen_imported_struct(import: &ast::ImportStruct, tokens: &mut Tokens) {
@ -446,12 +445,9 @@ fn bindgen_imported_struct(import: &ast::ImportStruct, tokens: &mut Tokens) {
let mut methods = Tokens::new();
for &(_is_method, ref f) in import.functions.iter() {
let import_name = format!("__wbg_{}_{}", name, f.ident);
bindgen_import_function(f,
&import_name,
import.module.as_ref().map(|s| &**s),
&mut methods);
let import_name = f.wasm_function.shared()
.mangled_import_name(Some(&import.name.to_string()));
bindgen_import_function(f, &import_name, &mut methods);
}
(my_quote! {
@ -463,7 +459,6 @@ fn bindgen_imported_struct(import: &ast::ImportStruct, tokens: &mut Tokens) {
fn bindgen_import_function(import: &ast::ImportFunction,
import_name: &str,
_import_module: Option<&str>,
tokens: &mut Tokens) {
let vis = &import.rust_vis;
let ret = &import.rust_decl.output;