Skip to content

Automatically generate class names in define_class! #713

Open
@madsmtm

Description

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?).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions