Skip to content

structs: dependency-only: opaque should apply to ObjC interfaces #432

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

Open
vaind opened this issue Sep 7, 2023 · 3 comments
Open

structs: dependency-only: opaque should apply to ObjC interfaces #432

vaind opened this issue Sep 7, 2023 · 3 comments
Labels
lang-objective_c Related to Objective C support package:ffigen

Comments

@vaind
Copy link
Contributor

vaind commented Sep 7, 2023

Say we have an API that requires an NSString as an argument.
Say you only want to call that API, not do all the fiddly bits you can do with NSStrings so you set exlcude-all-by-default and only include the interface class you want to use.

If you happen to run ffigen, it will see the API you want to use needs an NSString, then it will have a look at all its APIs and will go ahead and generate code for all of those. While this is functional, it creates a lot of code (file sizes measured in megabytes). I assume this code does get tree-shaken during compilation, but it's still something that will impact compilation speed, git repo size and all the implications that has over time, package size when pushed to pub.dev (and being downloaded by the package users), etc.

I've also tried structs: dependency-only: opaque but that doesn't seem to do anything.

While the approach to generate all the dependent code is a valid one and it does work, I wonder if we could make exclude-all-by-default apply for this as well. Instead, I'd prefer having to specify the methods I need (besides the constructor) - I am excluding everything after all. Alternatively, it could be done so that by just listing the class/interface in the include list would generate all methods (related: #251) but would not go on transitively for each argument - those would be opaque instead.

Example:

@liamappelbe liamappelbe added the lang-objective_c Related to Objective C support label Sep 7, 2023
@liamappelbe
Copy link
Contributor

How is this different from method filtering? Are you just asking for exclude-all-by-default to apply to methods, once we implement this filtering?

@vaind
Copy link
Contributor Author

vaind commented Sep 7, 2023

Maybe this could be simplified to: let's have the existing option structs: dependency-only: opaque also work for objective-c. In that case, types used in arguments wouldn't pull so much code transitively.

@liamappelbe liamappelbe changed the title Don't generate methods on dependent obj-c classes with exclude-all-by-default structs: dependency-only: opaque should apply to ObjC interfaces Sep 7, 2023
@liamappelbe
Copy link
Contributor

Sounds reasonable. But it should probably be its own flag specific to ObjC interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-objective_c Related to Objective C support package:ffigen
Projects
Status: Backlog
Development

No branches or pull requests

3 participants