Allow simply distinguishing enums from option sets

Bug #1660085 reported by Chris Hanson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CFFI
New
Undecided
Unassigned

Bug Description

C enums are used for a couple of different purposes. They're used for traditional pick-one-of-many enumerations that are used in e.g. switch/case constructs. However, they're also used to impart additional type system support to bit fields where several items can be or'd together.

To improve IDE support and Swift interoperability, Apple added C++ enum "base type" support to Objective-C, and also added two macros that the IDE and the Swift C importer can look at to determine the intent of an enum: CF_ENUM() and CF_OPTIONS(). (The more commonly used NS_* variants are just wrappers for these.)

It could be useful for CFFI to have some comparable way of annotating C enumerations for the same purpose. For example, an API that takes an imported C enum marked as an option set could accept a list like (:flag1 :flag2) to represent the bitwise OR of values from the enum, while disallowing the same for a C enum not representing an option set.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.