Add support for constructing JsValue instances generically

This commit is contained in:
David Flemström
2018-03-28 01:22:31 +02:00
committed by Alex Crichton
parent e6a483f906
commit 73619b5d15
5 changed files with 86 additions and 4 deletions

View File

@ -266,6 +266,11 @@ impl<'a> Context<'a> {
}}
"));
ts_dst.push_str("constructor(ptr: number, sym: Symbol);\n");
self.globals.push_str(&format!("
export function {new_name}(ptr) {{
return addHeapObject(new {class}(ptr, token));
}}", new_name=shared::new_function(&class), class=class));
} else {
dst.push_str(&format!("
constructor(ptr) {{
@ -273,6 +278,11 @@ impl<'a> Context<'a> {
}}
"));
ts_dst.push_str("constructor(ptr: number);\n");
self.globals.push_str(&format!("
export function {new_name}(ptr) {{
return addHeapObject(new {class}(ptr));
}}", new_name=shared::new_function(&class), class=class));
}
dst.push_str(&format!("