Skip to content

Commit 9b8711a

Browse files
authored
Update webidl_ty field in multi-value transform (#1839)
* Reduce indentation in interface types processing Just a small stylistic change * Update `webidl_ty` field in multi-value transform When we're emitting a bindings section we need to be sure to update the listed type of the binding in addition to the actual binding expressions. This should help remove the stray return pointer being listed there by accident!
1 parent 0397e52 commit 9b8711a

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

crates/cli-support/src/webidl/standard.rs

+24-14
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,32 @@ pub fn add_multi_value(
5454
// Finally, unset `return_via_outptr`, fix up its incoming bindings'
5555
// argument numberings, and update its function type.
5656
for (id, binding) in &mut bindings.exports {
57-
if binding.return_via_outptr.take().is_some() {
58-
if binding.incoming.is_empty() {
59-
bail!("missing incoming binding expression for return pointer parameter");
60-
}
61-
if !is_ret_ptr_bindings(binding.incoming.remove(0)) {
62-
bail!("unexpected incoming binding expression for return pointer parameter");
63-
}
57+
if binding.return_via_outptr.take().is_none() {
58+
continue;
59+
}
60+
if binding.incoming.is_empty() {
61+
bail!("missing incoming binding expression for return pointer parameter");
62+
}
63+
if !is_ret_ptr_bindings(binding.incoming.remove(0)) {
64+
bail!("unexpected incoming binding expression for return pointer parameter");
65+
}
6466

65-
fixup_binding_argument_gets(&mut binding.incoming)?;
67+
fixup_binding_argument_gets(&mut binding.incoming)?;
6668

67-
let func = match module.exports.get(*id).item {
68-
walrus::ExportItem::Function(f) => f,
69-
_ => unreachable!(),
70-
};
71-
binding.wasm_ty = module.funcs.get(func).ty();
72-
}
69+
let func = match module.exports.get(*id).item {
70+
walrus::ExportItem::Function(f) => f,
71+
_ => unreachable!(),
72+
};
73+
binding.wasm_ty = module.funcs.get(func).ty();
74+
75+
// Be sure to delete the out-param pointer from the WebIDL type as well.
76+
let webidl_ty = bindings
77+
.types
78+
.get::<ast::WebidlFunction>(binding.webidl_ty)
79+
.unwrap();
80+
let mut new_ty = webidl_ty.clone();
81+
new_ty.params.remove(0);
82+
binding.webidl_ty = bindings.types.insert(new_ty);
7383
}
7484

7585
Ok(())

0 commit comments

Comments
 (0)