Skip to content

derive macros #55

Open
Open
@madsmtm

Description

@madsmtm

We have a few traits that users has to implement manually, namely Encode, RefEncode, Message and the INS... traits. It would be nice if these could be automatically derived, but in essence we can't allow that because they are unsafe, and a derive macro wouldn't be able to uphold the required safety invariants.

#[derive(Encode)] (requested upstream in SSheldon/rust-objc#52) specifically doesn't work because the user could create a #[repr(C)] struct which used e.g. [i8; 4] while the Objective-C side used int. Or *const u8 vs. c_void*; this is valid from a normal FFI-perspective, but Encode requires that the encodings match perfectly.

So I'm actually probably going to remove the existing objc2_foundation_derive helpers in this repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesdocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions