mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-21 16:51:33 +00:00
Add test for enums
This commit is contained in:
@ -1054,8 +1054,15 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
passed_args.push_str(arg);
|
||||
};
|
||||
match *arg {
|
||||
shared::TYPE_ENUM | shared::TYPE_NUMBER => {
|
||||
// TODO: TS for Enum
|
||||
shared::TYPE_ENUM => {
|
||||
dst_ts.push_str(&format!(": {}", "any"));
|
||||
if self.cx.config.debug {
|
||||
self.cx.expose_assert_num();
|
||||
arg_conversions.push_str(&format!("_assertNum({});\n", name));
|
||||
}
|
||||
pass(&name)
|
||||
}
|
||||
shared::TYPE_NUMBER => {
|
||||
dst_ts.push_str(": number");
|
||||
if self.cx.config.debug {
|
||||
self.cx.expose_assert_num();
|
||||
@ -1160,6 +1167,10 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
dst_ts.push_str(": void");
|
||||
format!("return ret;")
|
||||
}
|
||||
Some(shared::TYPE_ENUM) => {
|
||||
dst_ts.push_str(": any");
|
||||
format!("return ret;")
|
||||
}
|
||||
Some(shared::TYPE_NUMBER) => {
|
||||
dst_ts.push_str(": number");
|
||||
format!("return ret;")
|
||||
@ -1439,6 +1450,14 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
self.cx.globals.push_str(&format!("export const {} = {{", enum_.name));
|
||||
self.cx.globals.push_str(&variants);
|
||||
self.cx.globals.push_str("}\n");
|
||||
self.cx.typescript.push_str(&format!("export enum {} {{", enum_.name));
|
||||
|
||||
variants.clear();
|
||||
for variant in enum_.variants.iter() {
|
||||
variants.push_str(&format!("{},", variant.name));
|
||||
}
|
||||
self.cx.typescript.push_str(&variants);
|
||||
self.cx.typescript.push_str("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user