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

Figure out whether CF collections should be generic #705

Open
madsmtm opened this issue Jan 28, 2025 · 0 comments
Open

Figure out whether CF collections should be generic #705

madsmtm opened this issue Jan 28, 2025 · 0 comments
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Jan 28, 2025

Relevant for the types CFArray, CFBag, CFBinaryHeap, CFDictionary, CFSet and maybe CFTree.

For a bit of prior art, core-foundation, the predecessor to objc2-core-foundation, declares these as generic, but the headers themselves do not.

This is especially problematic because it prevents any function that takes e.g. &CFArray or &CFDictionary from being marked as safe, because those arrays/dictionaries can contain anything (while the function expects of a certain type, or at least just that the inner type is a CFType). Returned arrays/dictionaries are also harder to use, because you have to manually ensure that they contain the right value.

As said, the headers do not provide this type information directly, but perhaps we can enrich it ourselves?

Basically, it comes down to a choice between:

  • Making every element accessor unsafe, and forcing users to consider the type there.
  • Making element accessors safe (but dependent on the element type), and making conversion/construction of a typed collection from an untyped collection unsafe.

This probably blocks #692 and #693.

@madsmtm madsmtm added A-framework Affects the framework crates and the translator for them question Further information is requested enhancement New feature or request and removed question Further information is requested labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant