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

Add support for tagless enums. #510

Merged
merged 1 commit into from
Apr 28, 2017
Merged

Add support for tagless enums. #510

merged 1 commit into from
Apr 28, 2017

Conversation

yallop
Copy link
Owner

@yallop yallop commented Apr 28, 2017

It's quite common in C code to create enumerations without tags, so that they can only be referred to by an alias:

typedef enum {
  X,
  Y,
  Z
} xyz;

This PR adds support for exposing such types via an optional argument, typedef, to the enum function. The typedef flag indicates that the name passed to enum represents an alias, not an enumeration tag. With this PR the following code exposes an enueration like xyz above,

let i64 n = constant n int64_t
let t = enum "xyz" ~typedef:true [
  `X , i64 "X";
  `Y , i64 "Y";
  `Z , i64 "Z";
]

Omitting the ~typedef:true gives a binding suitable for an enumeration defined with a tag:

enum xyz {
  X,
  Y,
  Z
};

@yallop yallop merged commit 8b887fc into yallop:master Apr 28, 2017
@yallop yallop deleted the enum-typedef branch April 28, 2017 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant