Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webidl_ty field in multi-value transform #1839

Merged
merged 2 commits into from
Oct 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions crates/cli-support/src/webidl/standard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,32 @@ pub fn add_multi_value(
// Finally, unset `return_via_outptr`, fix up its incoming bindings'
// argument numberings, and update its function type.
for (id, binding) in &mut bindings.exports {
if binding.return_via_outptr.take().is_some() {
if binding.incoming.is_empty() {
bail!("missing incoming binding expression for return pointer parameter");
}
if !is_ret_ptr_bindings(binding.incoming.remove(0)) {
bail!("unexpected incoming binding expression for return pointer parameter");
}
if binding.return_via_outptr.take().is_none() {
continue;
}
if binding.incoming.is_empty() {
bail!("missing incoming binding expression for return pointer parameter");
}
if !is_ret_ptr_bindings(binding.incoming.remove(0)) {
bail!("unexpected incoming binding expression for return pointer parameter");
}

fixup_binding_argument_gets(&mut binding.incoming)?;
fixup_binding_argument_gets(&mut binding.incoming)?;

let func = match module.exports.get(*id).item {
walrus::ExportItem::Function(f) => f,
_ => unreachable!(),
};
binding.wasm_ty = module.funcs.get(func).ty();
}
let func = match module.exports.get(*id).item {
walrus::ExportItem::Function(f) => f,
_ => unreachable!(),
};
binding.wasm_ty = module.funcs.get(func).ty();

// Be sure to delete the out-param pointer from the WebIDL type as well.
let webidl_ty = bindings
.types
.get::<ast::WebidlFunction>(binding.webidl_ty)
.unwrap();
let mut new_ty = webidl_ty.clone();
new_ty.params.remove(0);
binding.webidl_ty = bindings.types.insert(new_ty);
}

Ok(())
Expand Down