mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
commit
2e80313aa3
@ -750,12 +750,16 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
|||||||
.map(|s| format!("{}: {}", s.0, s.1))
|
.map(|s| format!("{}: {}", s.0, s.1))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
let mut ts = format!("{} {}({})", prefix, self.js_name, ts_args);
|
let mut ts = if prefix.is_empty() {
|
||||||
|
format!("{}({})", self.js_name, ts_args)
|
||||||
|
} else {
|
||||||
|
format!("{} {}({})", prefix, self.js_name, ts_args)
|
||||||
|
};
|
||||||
if self.constructor.is_none() {
|
if self.constructor.is_none() {
|
||||||
ts.push_str(": ");
|
ts.push_str(": ");
|
||||||
ts.push_str(&self.ret_ty);
|
ts.push_str(&self.ret_ty);
|
||||||
}
|
}
|
||||||
ts.push_str(";\n");
|
ts.push(';');
|
||||||
(js, ts, self.js_doc_comments())
|
(js, ts, self.js_doc_comments())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ impl<'a> Context<'a> {
|
|||||||
",
|
",
|
||||||
name,
|
name,
|
||||||
));
|
));
|
||||||
ts_dst.push_str("free(): void;\n");
|
ts_dst.push_str(" free(): void;");
|
||||||
dst.push_str(&class.contents);
|
dst.push_str(&class.contents);
|
||||||
ts_dst.push_str(&class.typescript);
|
ts_dst.push_str(&class.typescript);
|
||||||
dst.push_str("}\n");
|
dst.push_str("}\n");
|
||||||
@ -2399,6 +2399,8 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
|||||||
.contents
|
.contents
|
||||||
.push_str(&format_doc_comments(&export.comments, Some(js_doc)));
|
.push_str(&format_doc_comments(&export.comments, Some(js_doc)));
|
||||||
|
|
||||||
|
class.typescript.push_str(" "); // Indentation
|
||||||
|
|
||||||
if export.is_constructor {
|
if export.is_constructor {
|
||||||
if class.has_constructor {
|
if class.has_constructor {
|
||||||
bail!("found duplicate constructor `{}`", export.function.name);
|
bail!("found duplicate constructor `{}`", export.function.name);
|
||||||
@ -2571,12 +2573,12 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
|||||||
.typescript
|
.typescript
|
||||||
.push_str(&format!("export enum {} {{", enum_.name));
|
.push_str(&format!("export enum {} {{", enum_.name));
|
||||||
|
|
||||||
variants.clear();
|
|
||||||
for variant in enum_.variants.iter() {
|
for variant in enum_.variants.iter() {
|
||||||
variants.push_str(&format!("{},", variant.name));
|
self.cx
|
||||||
|
.typescript
|
||||||
|
.push_str(&format!("\n {},", variant.name));
|
||||||
}
|
}
|
||||||
self.cx.typescript.push_str(&variants);
|
self.cx.typescript.push_str("\n}\n");
|
||||||
self.cx.typescript.push_str("}\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_struct(&mut self, struct_: &decode::Struct) -> Result<(), Error> {
|
fn generate_struct(&mut self, struct_: &decode::Struct) -> Result<(), Error> {
|
||||||
@ -2596,7 +2598,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
|||||||
.argument(&descriptor)?
|
.argument(&descriptor)?
|
||||||
.ret(&Descriptor::Unit)?;
|
.ret(&Descriptor::Unit)?;
|
||||||
ts_dst.push_str(&format!(
|
ts_dst.push_str(&format!(
|
||||||
"{}{}: {};\n",
|
"\n {}{}: {};",
|
||||||
if field.readonly { "readonly " } else { "" },
|
if field.readonly { "readonly " } else { "" },
|
||||||
field.name,
|
field.name,
|
||||||
&cx.js_arguments[0].1
|
&cx.js_arguments[0].1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user