webidl: initial enum support

Add enum support to the WebIDL interface generator.
This commit is contained in:
Stephan Wolski
2018-07-08 22:09:00 -04:00
parent 94d939f4da
commit a981dfd507
10 changed files with 239 additions and 12 deletions

View File

@ -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());