From 8861bee797c81aa501e6c30797e83dafcc19456e Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 20 Jan 2020 18:39:24 -0800 Subject: [PATCH] Support opaque types that are not structs --- gen/write.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gen/write.rs b/gen/write.rs index eb114702a..97fdc4802 100644 --- a/gen/write.rs +++ b/gen/write.rs @@ -40,7 +40,8 @@ pub(super) fn gen(namespace: Vec, apis: &[Api], types: &Types, header: b for api in apis { match api { 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); } +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) { let indirect_return = efn .ret