Implement a js_name customization

This'll allow binding multiple signatures of a JS function as well as otherwise
changing the name of the JS function you're calling from the Rust function that
you're defining.

Closes #72
This commit is contained in:
Alex Crichton
2018-03-22 19:05:14 -07:00
parent a8045fbbe9
commit 7ebc428646
10 changed files with 155 additions and 66 deletions

View File

@ -34,6 +34,7 @@ pub enum ImportKind {
#[derive(Deserialize)]
pub struct ImportFunction {
pub shim: String,
pub module: Option<String>,
pub catch: bool,
pub method: bool,
@ -49,6 +50,7 @@ pub struct ImportFunction {
pub struct ImportStatic {
pub module: Option<String>,
pub name: String,
pub shim: String,
}
#[derive(Deserialize)]
@ -110,17 +112,6 @@ pub fn struct_function_export_name(struct_: &str, f: &str) -> String {
return name
}
pub fn mangled_import_name(struct_: Option<&str>, f: &str) -> String {
match struct_ {
Some(s) => format!("__wbg_s_{}_{}", s, f),
None => format!("__wbg_f_{}", f),
}
}
pub fn static_import_shim_name(statik: &str) -> String {
format!("__wbg_field_import_shim_{}", statik)
}
pub type Type = char;
pub const TYPE_VECTOR_JSVALUE: char = '\u{5b}';