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

[swift2objc] Generate bindings for enums #1364

Open
liamappelbe opened this issue Jul 22, 2024 · 2 comments
Open

[swift2objc] Generate bindings for enums #1364

liamappelbe opened this issue Jul 22, 2024 · 2 comments

Comments

@liamappelbe
Copy link
Contributor

enum CompassPoint {
    case north
    case south
    case east
    case west
}

Enums are a bit complicated in Swift. There are simple enums like this one, and also enums with associated values.

@Levi-Lesches
Copy link
Contributor

How does this play with the enum overhaul from earlier?

@liamappelbe
Copy link
Contributor Author

swift2objc is a separate tool from ffigen, so it's not directly related.

image

I think if a Swift enum is simple enough that we can represent it as an ObjC/C enum, then it will make its way through to the Dart bindings just like any other enum. For the more complicated enums, we'll be generating classes that emulate the enums, and those will be represented in the Dart bindings as classes.

Later, we might be able to plumb some custom metadata through this pipeline to tell ffigen that a particular ObjC class is actually a representation of a Swift enum, and generate a Dart enum to wrap it, since Dart enums have many of the same features as Swift enums. That's not something I'm planning to do atm though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants