Re: Trouble with imported enums in Swift
Re: Trouble with imported enums in Swift
- Subject: Re: Trouble with imported enums in Swift
- From: Rick Mann <email@hidden>
- Date: Tue, 21 Oct 2014 16:25:11 -0700
> On Oct 21, 2014, at 14:54 , Quincey Morris <email@hidden> wrote:
>
> On Oct 21, 2014, at 14:35 , Rick Mann <email@hidden> wrote:
>>
>>> On Oct 21, 2014, at 14:26 , Quincey Morris <email@hidden> wrote:
>>>
>>> Honestly, though, I don’t see why you can’t just deal with writing enums the “compatible” way.
>>
>> Because the file whence it comes is part of a library of C++ code that also has to run on Linux.
>
> Swift isn’t a C++ cross-compiler either.
>
> You know that the NS_ENUM thing is a macro, don’t you? (Or, at least, can be — it seems to be a syntax feature in the latest clang.) Five seconds searching the web gave me this:
>
>> #ifndef NS_ENUM
>> #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
>> #endif
>
> of which I assume a slight variant will eliminate the clang-specific syntax and therefore work fine in C++ and on Linux.
I think you're missing the point. The header (which can be included in a C file) is used throughout a body of code that knows nothing about NS. Sure we can make a macro to mimic the behavior, but only because the code is all generated in-house (it's not some open source code base we use).
But the names of the elements all have to start with the type name, and that means not only changing the entire code base that uses the header, but also changing the naming convention used by that code base. Sure, we can do it, but it'll irritate a number of engineers, at best. All because Swift bridging wasn't designed to be more accommodating.
The reason this header is shared in the first place is that the values are used in a protocol between nodes.
--
Rick Mann
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden