mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-16 14:31:22 +00:00
webidl: initial enum support
Add enum support to the WebIDL interface generator.
This commit is contained in:
@ -71,13 +71,15 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
self.prelude(
|
||||
"if (this.ptr === 0) {
|
||||
throw new Error('Attempt to use a moved value');
|
||||
}"
|
||||
}",
|
||||
);
|
||||
if consumed {
|
||||
self.prelude("\
|
||||
const ptr = this.ptr;\n\
|
||||
this.ptr = 0;\n\
|
||||
");
|
||||
self.prelude(
|
||||
"\
|
||||
const ptr = this.ptr;\n\
|
||||
this.ptr = 0;\n\
|
||||
",
|
||||
);
|
||||
self.rust_arguments.insert(0, "ptr".to_string());
|
||||
} else {
|
||||
self.rust_arguments.insert(0, "this.ptr".to_string());
|
||||
|
@ -1756,6 +1756,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
})?;
|
||||
}
|
||||
shared::ImportKind::Type(_) => {}
|
||||
shared::ImportKind::Enum(_) => {}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
||||
// Insert an assertion to the type of the returned value as
|
||||
// otherwise this will cause memory unsafety on the Rust side of
|
||||
// things.
|
||||
self.ret_expr = format!("\
|
||||
self.ret_expr = format!(
|
||||
"\
|
||||
const val = JS;
|
||||
if (!(val instanceof {0})) {{
|
||||
throw new Error('expected value of type {0}');
|
||||
@ -314,8 +315,10 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
||||
const ret = val.ptr;
|
||||
val.ptr = 0;
|
||||
return ret;\
|
||||
", class);
|
||||
return Ok(())
|
||||
",
|
||||
class
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.ret_expr = match *ty {
|
||||
|
Reference in New Issue
Block a user