Skip to content

define_class!: Allow safe overriding of methods / safe implementation of protocols #437

@madsmtm

Description

@madsmtm

It would be nice if icrate could mark certain protocols / methods as safe to override, such that define_class! could (after checking that all types are the same) allow just doing:

define_class!(
    // ...

    impl MyClass {
        #[method_id(init)]
        fn init(this: Allocated<Self>) -> Id<Self> {
            todo!()
        }
    }

    impl MyProtocol for MyClass {
        #[method(protocolMethod)]
        fn protocol_method(&self) {}
    }
);

(Notice the lack of unsafe impl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frameworkAffects the framework crates and the translator for themA-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions