Support opaque types that are not structs

This commit is contained in:
David Tolnay 2020-01-20 18:39:24 -08:00
parent 199d73509b
commit 8861bee797
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -40,7 +40,8 @@ pub(super) fn gen(namespace: Vec<String>, apis: &[Api], types: &Types, header: b
for api in apis { for api in apis {
match api { match api {
Api::Struct(strct) => write_struct_decl(out, &strct.ident), Api::Struct(strct) => write_struct_decl(out, &strct.ident),
Api::CxxType(ety) | Api::RustType(ety) => write_struct_decl(out, &ety.ident), Api::CxxType(ety) => write_struct_using(out, &ety.ident),
Api::RustType(ety) => write_struct_decl(out, &ety.ident),
_ => {} _ => {}
} }
} }
@ -167,6 +168,10 @@ fn write_struct_decl(out: &mut OutFile, ident: &Ident) {
writeln!(out, "struct {};", ident); writeln!(out, "struct {};", ident);
} }
fn write_struct_using(out: &mut OutFile, ident: &Ident) {
writeln!(out, "using {} = {};", ident, ident);
}
fn write_cxx_function_shim(out: &mut OutFile, efn: &ExternFn, types: &Types) { fn write_cxx_function_shim(out: &mut OutFile, efn: &ExternFn, types: &Types) {
let indirect_return = efn let indirect_return = efn
.ret .ret