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

Automatically generate class names in define_class! #713

Open
madsmtm opened this issue Feb 13, 2025 · 0 comments
Open

Automatically generate class names in define_class! #713

madsmtm opened this issue Feb 13, 2025 · 0 comments
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Feb 13, 2025

It would be nice if you didn't have to specify a custom class name in define_class!.

Maybe we can generate it with something like:

const NAME: &'static str = concat!(module_path!(), "::", $struct_name, env!("CARGO_PKG_VERSION"));

This also ties in to ryanmcgrath/cacao#63 and rust-windowing/raw-window-metal#29; if we have a unique name based on the package, it would probably be sound to look up the name from the runtime instead of always trying to declare it ourselves.

(Though a bit unsure, can two Cargo packages with SemVer compatible versions ever be different? Maybe in the plugin case, where two classes are loaded dynamically at runtime, and one of them comes from a modified Git dependency where the other one doesn't? But maybe we can just say that that's up to the user to ensure is sound?).

@madsmtm madsmtm added A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates enhancement New feature or request labels Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant