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

[cxx-interop] Support nested classes in reverse interop #79045

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xazax-hun
Copy link
Contributor

Turns out we already had most of the building blocks given we already support nested structs.

rdar://143343490

Turns out we already had most of the building blocks given we already
support nested structs.

rdar://143343490
@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Jan 30, 2025
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun Xazax-hun requested a review from j-hui January 30, 2025 17:57
Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks good to me, my comments are mostly about testing. I'm glad that the mechanical mechanisms were already in place for this to work without any big changes.

Comment on lines +16 to +21
int main() {
using namespace Classes;
auto x = makeRecordConfig();
RecordConfig::File::Gate y = x.getGate();
RecordConfig::AudioFormat z = x.getFile().getFormat();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do more in this test here? Some things I can think of:

  • Directly instantiate nested classes (i.e., referring to constructors)
  • Call some methods and computed properties of nested classes (which you'll need to define)
  • Assert some things about the values of y.prop (should be equal to -80) and z (should be RecordConfig::AudioFormat::ALAC).

@@ -0,0 +1,31 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -enable-library-evolution -typecheck -module-name Classes -clang-header-expose-decls=all-public -emit-clang-header-path %t/classes.h
// RN: %FileCheck %s < %t/structs.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo?

Suggested change
// RN: %FileCheck %s < %t/structs.h
// RUN: %FileCheck %s < %t/classes.h

And I don't see any // CHECK statements in this file. What is this supposed to do?

I was also going to ask whether there's any way to check the textual contents of the C++ header file generated from this Swift code (similar to the -module-interface.swift files for many forward interop test cases), but I suspect that's what you mean to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants