mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 14:01:25 +00:00
Add a #[wasm_bindgen(constructor)] attribute
This can be used for specifying that a static function should actually delegate to `new`
This commit is contained in:
@ -501,27 +501,26 @@ impl<'a> Js<'a> {
|
||||
}
|
||||
|
||||
for f in import.functions.iter() {
|
||||
self.generate_import_struct_function(&import.name,
|
||||
f.method,
|
||||
&f.function);
|
||||
self.generate_import_struct_function(&import.name, f);
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_import_struct_function(
|
||||
&mut self,
|
||||
class: &str,
|
||||
is_method: bool,
|
||||
function: &shared::Function,
|
||||
f: &shared::ImportStructFunction,
|
||||
) {
|
||||
let delegate = if is_method {
|
||||
format!("{}.prototype.{}.call", class, function.name)
|
||||
let delegate = if f.method {
|
||||
format!("{}.prototype.{}.call", class, f.function.name)
|
||||
} else if f.js_new {
|
||||
format!("new {}", class)
|
||||
} else {
|
||||
format!("{}.{}", class, function.name)
|
||||
format!("{}.{}", class, f.function.name)
|
||||
};
|
||||
self.gen_import_shim(&shared::mangled_import_name(Some(class), &function.name),
|
||||
self.gen_import_shim(&shared::mangled_import_name(Some(class), &f.function.name),
|
||||
&delegate,
|
||||
is_method,
|
||||
function)
|
||||
f.method,
|
||||
&f.function)
|
||||
}
|
||||
|
||||
fn gen_import_shim(
|
||||
|
Reference in New Issue
Block a user