Skip to content

Commit

Permalink
Implement extern C++ shared structs
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 30, 2020
1 parent c8b5035 commit a593d6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gen/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ pub(super) fn gen(
match api {
Api::Struct(strct) => {
out.next_section();
write_struct(out, strct);
if !types.cxx.contains(&strct.ident) {
write_struct(out, strct);
}
}
Api::Enum(enm) => {
out.next_section();
Expand Down
3 changes: 2 additions & 1 deletion macro/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fn expand(ffi: Module, apis: &[Api], types: &Types) -> TokenStream {
Api::Struct(strct) => expanded.extend(expand_struct(strct)),
Api::Enum(enm) => expanded.extend(expand_enum(enm)),
Api::CxxType(ety) => {
if !types.enums.contains_key(&ety.ident) {
let ident = &ety.ident;
if !types.structs.contains_key(ident) && !types.enums.contains_key(ident) {
expanded.extend(expand_cxx_type(namespace, ety));
}
}
Expand Down
3 changes: 0 additions & 3 deletions syntax/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ fn check_api_struct(cx: &mut Check, strct: &Struct) {
if let Some(ety) = cx.types.untrusted.get(ident) {
let msg = "extern shared struct must be declared in an `unsafe extern` block";
cx.error(ety, msg);
} else {
let span = span_for_struct_error(strct);
cx.error(span, "extern C++ structs are not implemented yet");
}
}

Expand Down

0 comments on commit a593d6e

Please sign in to comment.