Skip to content

Merge upstream with async #2

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

Open
wants to merge 9 commits into
base: async
Choose a base branch
from
Open
Show file tree
Hide file tree
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
63 changes: 45 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ indexmap = "2.0.0"
prettyplease = "0.2.20"
syn = { version = "2.0", features = ["printing"] }

wasmparser = "0.214.0"
wasm-encoder = "0.214.0"
wasm-metadata = "0.214.0"
wit-parser = "0.214.0"
wit-component = "0.214.0"
wasmparser = { git = "https://github.com/cpetig/wasm-tools", branch = "async" }
wasm-encoder = { git = "https://github.com/cpetig/wasm-tools", branch = "async" }
wasm-metadata = { git = "https://github.com/cpetig/wasm-tools", branch = "async" }
wit-parser = { git = "https://github.com/cpetig/wasm-tools", branch = "async" }
wit-component = { git = "https://github.com/cpetig/wasm-tools", branch = "async" }

wit-bindgen-core = { path = 'crates/core', version = '0.28.0' }
wit-bindgen-c = { path = 'crates/c', version = '0.28.0' }
Expand Down
27 changes: 16 additions & 11 deletions crates/c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ fn is_prim_type_id(resolve: &Resolve, id: TypeId) -> bool {
| TypeDefKind::Result(_)
| TypeDefKind::Future(_)
| TypeDefKind::Stream(_)
| TypeDefKind::Error
| TypeDefKind::Unknown => false,
}
}
Expand Down Expand Up @@ -747,6 +748,7 @@ pub fn push_ty_name(resolve: &Resolve, ty: &Type, src: &mut String) {
| TypeDefKind::Resource
| TypeDefKind::Flags(_)
| TypeDefKind::Enum(_)
| TypeDefKind::Error
| TypeDefKind::Variant(_) => {
unimplemented!()
}
Expand Down Expand Up @@ -993,6 +995,7 @@ impl Return {
TypeDefKind::Stream(_) => todo!("return_single for stream"),
TypeDefKind::Resource => todo!("return_single for resource"),
TypeDefKind::Unknown => unreachable!(),
TypeDefKind::Error => todo!(),
}

self.retptrs.push(*orig_ty);
Expand Down Expand Up @@ -1426,13 +1429,17 @@ impl<'a> wit_bindgen_core::AnonymousTypeGenerator<'a> for InterfaceGenerator<'a>
todo!("print_anonymous_type for future");
}

fn anonymous_type_stream(&mut self, _id: TypeId, _ty: &Stream, _docs: &Docs) {
fn anonymous_type_stream(&mut self, _id: TypeId, _ty: &Type, _docs: &Docs) {
todo!("print_anonymous_type for stream");
}

fn anonymous_typ_type(&mut self, _id: TypeId, _ty: &Type, _docs: &Docs) {
todo!("print_anonymous_type for typ");
}

fn anonymous_type_error(&mut self, _id: TypeId, _docs: &Docs) {
todo!()
}
}

pub enum CTypeNameInfo<'a> {
Expand Down Expand Up @@ -1609,6 +1616,7 @@ impl InterfaceGenerator<'_> {
self.free(&Type::Id(*id), "*ptr");
}
TypeDefKind::Unknown => unreachable!(),
TypeDefKind::Error => todo!(),
}
if c_helpers_body_start == self.src.c_helpers.len() {
self.src.c_helpers.as_mut_string().truncate(c_helpers_start);
Expand Down Expand Up @@ -1749,6 +1757,7 @@ impl InterfaceGenerator<'_> {
LiftLower::LowerArgsLiftResults,
func,
&mut f,
false,
);

let FunctionBindgen {
Expand Down Expand Up @@ -1821,6 +1830,7 @@ impl InterfaceGenerator<'_> {
LiftLower::LiftArgsLowerResults,
func,
&mut f,
false,
);
let FunctionBindgen { src, .. } = f;
self.src.c_adapters(&src);
Expand Down Expand Up @@ -1851,7 +1861,7 @@ impl InterfaceGenerator<'_> {

let mut f = FunctionBindgen::new(self, c_sig, &import_name);
f.params = params;
abi::post_return(f.gen.resolve, func, &mut f);
abi::post_return(f.gen.resolve, func, &mut f, false);
let FunctionBindgen { src, .. } = f;
self.src.c_fns(&src);
self.src.c_fns("}\n");
Expand Down Expand Up @@ -2078,18 +2088,12 @@ impl InterfaceGenerator<'_> {
.as_ref()
.map_or(false, |ty| self.contains_droppable_borrow(ty)),

TypeDefKind::Stream(s) => {
s.element
.as_ref()
.map_or(false, |ty| self.contains_droppable_borrow(ty))
|| s.end
.as_ref()
.map_or(false, |ty| self.contains_droppable_borrow(ty))
}
TypeDefKind::Stream(s) => self.contains_droppable_borrow(s),

TypeDefKind::Type(ty) => self.contains_droppable_borrow(ty),

TypeDefKind::Unknown => false,
TypeDefKind::Error => todo!(),
}
} else {
false
Expand Down Expand Up @@ -2752,7 +2756,7 @@ impl Bindgen for FunctionBindgen<'_, '_> {
self.src.push_str(");\n");
}

Instruction::CallInterface { func } => {
Instruction::CallInterface { func, .. } => {
let mut args = String::new();
for (i, (op, (byref, _))) in operands.iter().zip(&self.sig.params).enumerate() {
if i > 0 {
Expand Down Expand Up @@ -3146,6 +3150,7 @@ pub fn is_arg_by_pointer(resolve: &Resolve, ty: &Type) -> bool {
TypeDefKind::Stream(_) => todo!("is_arg_by_pointer for stream"),
TypeDefKind::Resource => todo!("is_arg_by_pointer for resource"),
TypeDefKind::Unknown => unreachable!(),
TypeDefKind::Error => todo!(),
},
Type::String => true,
_ => false,
Expand Down
Loading