-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Better support CoreFoundation types in RemoteMirror #76586
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Enum_CF | ||
// RUN: %target-codesign %t/reflect_Enum_CF | ||
|
||
// RUN: %target-run %target-swift-reflection-test %t/reflect_Enum_CF | tee /dev/stderr | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK%target-ptrsize --dump-input=fail %add_num_extra_inhabitants | ||
|
||
// REQUIRES: objc_interop | ||
// REQUIRES: executable_test | ||
// REQUIRES: reflection_test_support | ||
// UNSUPPORTED: use_os_stdlib | ||
// UNSUPPORTED: asan | ||
|
||
import SwiftReflectionTest | ||
import Foundation | ||
|
||
enum MyPair<T,U> { | ||
case a(T) | ||
case b(U) | ||
} | ||
|
||
reflect(enum: MyPair<Void,CFNumber>.b(kCFNumberPositiveInfinity)) | ||
|
||
// CHECK: Reflecting an enum. | ||
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} | ||
// CHECK-NEXT: Type reference: | ||
// CHECK-NEXT: (bound_generic_enum reflect_Enum_CF.MyPair | ||
// CHECK-NEXT: (tuple) | ||
// CHECK-NEXT: (foreign name=So11CFNumberRefa)) | ||
|
||
// CHECK: Type info: | ||
// CHECK64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=254 bitwise_takable=1 | ||
// CHECK64-NEXT: (case name=a index=0 offset=0 | ||
// CHECK64-NEXT: (tuple size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)) | ||
// CHECK64-NEXT: (case name=b index=1 offset=0 | ||
// CHECK64-NEXT: (reference kind=strong refcounting=unknown))) | ||
|
||
// CHECK: Mangled name: $s15reflect_Enum_CF6MyPairOyytSo11CFNumberRefaG | ||
// CHECK-NEXT: Demangled name: reflect_Enum_CF.MyPair<(), __C.CFNumberRef> | ||
|
||
// CHECK: Enum value: | ||
// CHECK-NEXT: (enum_value name=b index=1 | ||
// CHECK-NEXT: (foreign name=So11CFNumberRefa) | ||
// CHECK-NEXT: ) | ||
|
||
struct StructA { | ||
let field1 = MyPair<Void,CFNumber>.b(kCFNumberPositiveInfinity) | ||
let field2 = 7 | ||
} | ||
|
||
enum T { | ||
case a | ||
case b(MyPair<Void,CFNumber>) | ||
} | ||
|
||
reflect(enum: StructA().field1) | ||
|
||
// CHECK: Reflecting an enum. | ||
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} | ||
// CHECK-NEXT: Type reference: | ||
// CHECK-NEXT: (bound_generic_enum reflect_Enum_CF.MyPair | ||
// CHECK-NEXT: (tuple) | ||
// CHECK-NEXT: (foreign name=So11CFNumberRefa)) | ||
|
||
// CHECK: Type info: | ||
// CHECK64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=254 bitwise_takable=1 | ||
// CHECK64-NEXT: (case name=a index=0 offset=0 | ||
// CHECK64-NEXT: (tuple size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)) | ||
// CHECK64-NEXT: (case name=b index=1 offset=0 | ||
// CHECK64-NEXT: (reference kind=strong refcounting=unknown))) | ||
|
||
// CHECK: Mangled name: $s15reflect_Enum_CF6MyPairOyytSo11CFNumberRefaG | ||
// CHECK-NEXT: Demangled name: reflect_Enum_CF.MyPair<(), __C.CFNumberRef> | ||
|
||
// CHECK: Enum value: | ||
// CHECK-NEXT: (enum_value name=b index=1 | ||
// CHECK-NEXT: (foreign name=So11CFNumberRefa) | ||
// CHECK-NEXT: ) | ||
|
||
reflect(enum: T.a) | ||
|
||
// CHECK: Reflecting an enum. | ||
// CHECK-NEXT: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}} | ||
// CHECK-NEXT: Type reference: | ||
// CHECK-NEXT: (enum reflect_Enum_CF.T) | ||
|
||
// CHECK: Type info: | ||
// CHECK64-NEXT: (single_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=253 bitwise_takable=1 | ||
// CHECK64-NEXT: (case name=b index=0 offset=0 | ||
// CHECK64-NEXT: (multi_payload_enum size=9 alignment=8 stride=16 num_extra_inhabitants=254 bitwise_takable=1 | ||
// CHECK64-NEXT: (case name=a index=0 offset=0 | ||
// CHECK64-NEXT: (tuple size=0 alignment=1 stride=1 num_extra_inhabitants=0 bitwise_takable=1)) | ||
// CHECK64-NEXT: (case name=b index=1 offset=0 | ||
// CHECK64-NEXT: (reference kind=strong refcounting=unknown)))) | ||
// CHECK64-NEXT: (case name=a index=1)) | ||
|
||
// CHECK: Mangled name: $s15reflect_Enum_CF1TO | ||
// CHECK-NEXT: Demangled name: reflect_Enum_CF.T | ||
|
||
// CHECK: Enum value: | ||
// CHECK-NEXT: (enum_value name=a index=1) | ||
|
||
doneReflecting() | ||
|
||
// CHECKALL: Done. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could go out and find a matching foreign type descriptor to get a definitive answer about what the type is. But that would be a lot more difficult, and this heuristic should definitely be good enough. We can keep that in our pocket in case this doesn't work right somewhere.