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
[SR-6958] ClangImporter ignore aliased Objective-C type name #49506
Comments
Comment by Peter Steinberger (JIRA) This would make a lot of our API much nicer. Thanks for filing that one! |
It's supposed to already do that. Do you have a self-contained example where it isn't? |
(Note that NSUInteger could very well be the weirdness here, since that's imported as Int in most-but-not-all positions, and we have to pick which side the typedef falls on.) |
It may be something with the NSUInteger. Here is my current workaround where I basically mimic the NSUInteger type: #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef unsigned long PageIndex;
#else
typedef unsigned int PageIndex;
#endif Will try to build self-contained example. |
On all the platforms you care about |
It looks like PageIndex is converted differently than the NSUInteger, and I don't get it. |
Certain types are recognized as "word-sized", something that needs information beyond what you get out of a preprocessed C file. |
hm... when used uintptr_t Conflicting return type in implementation of 'pageIndex': 'PSPDFPageIndex' (aka 'unsigned long') vs 'NSUInteger' (aka 'unsigned int') |
I mean, you do have to be consistent about it… |
I see. I thought you said " Typedefs:
- Name: "PSPDFPageIndex"
SwiftBridge: "Swift.UInt" and if I look at the generated interface, it's UInt, but it doesn't seem to impact the type checked as it still thinks it's UInt32 eg. Cannot convert value of type 'PSPDFPageIndex' (aka 'UInt32') to expected argument type 'UInt' |
No, sorry, that's not what SwiftBridge is for. Stepping back, why do you want UInt for this API? That's not standard Swift. If the typedef were imported as Int would you be happy? |
I want to do |
Oh, wait, sorry. I got confused because system APIs import NSUInteger as Int. Non-system ones are still UInt. Okay, this is just a bug, then. Leaving it NSUInteger is fine. |
@swift-ci create |
To add, for the type defined like this: typedef unsigned long PSPDFUInteger;
typedef PSPDFUInteger PSPDFPageIndex NS_SWIFT_NAME(PageIndex); And use - (nullable NSURL *)pathForPageAtIndex:(PSPDFPageIndex)pageIndex; it's imported as func pathForPage(at pageIndex: Any!) -> URL? so it looks like there is something missing with typedef resolving. |
Comment by Peter Steinberger (JIRA) I've tested this with Xcode 11.3.1 (11C505), the importer still has the same issue. |
Environment
Swift 4.0.3. Xcode 9.2
Additional Detail from JIRA
md5: 5ad94f5dd12a2f7cc4f9b104597dfc1f
Issue Description:
When importing Objective-C function signature with basic primitive type aliased with the typedef, the function is imported with the aliased type name, not with the used alias:
Objective-C
Swift
Expected behavior:
The text was updated successfully, but these errors were encountered: