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

Support cfg in declare_class! #285

Closed
madsmtm opened this issue Nov 8, 2022 · 2 comments · Fixed by #286
Closed

Support cfg in declare_class! #285

madsmtm opened this issue Nov 8, 2022 · 2 comments · Fixed by #286
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates bug Something isn't working

Comments

@madsmtm
Copy link
Owner

madsmtm commented Nov 8, 2022

Reported on winit matrix.

Code excerpt from that thread:

declare_class! {
    // -- snip --
    unsafe impl ApplicationDelegate {
        // -- snip --
        #[cfg(feature = "macos-open-urls")]
        #[sel(application:openURLs:)]
        fn open_urls(&self, _sender: *const Object, urls: &NSArray<NSURL, Shared>) {
            trace_scope!("application:openURLs:");
        }
    }
}
@madsmtm madsmtm added bug Something isn't working A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Nov 8, 2022
@madsmtm
Copy link
Owner Author

madsmtm commented Nov 8, 2022

Implementation-wise: __attribute_helper's @extract_sel has to be extended to also extract attributes that apply to the function as well as any items referencing the function (which we do internally in code similar to classbuilder.add_method(ApplicationDelegate::open_urls).

Current list (based on the built-in index):

  • cfg
  • deprecated - We should add a corresponding allow(deprecated) before use
  • Any availability attributes that we decide on: How do we handle availability? #266
  • cfg_attr, if the inner attributes are on this list. (Might punt on this one, since it's a bit difficult, and a rare case anyhow)

@madsmtm
Copy link
Owner Author

madsmtm commented Nov 8, 2022

We should similarly try to support such attributes on each impl item

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 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant