objc-macros 0.1.0

Handy macros for interacting with Objective-C from Rust.
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 0 items with examples
  • Size
  • Source code size: 14.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 219.05 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • jgall

Objective-c Rust macros

Why does this exist? Who knows... but it lets you do cool stuff like this:

    let my_class = register_class!(MyClass:NSObject with {
        (pub width: u32),
        (priv height: u32),
        (sel add:(i32)t1 with:(i32)t2 -> i32 with |obj, sel| {
            return t1+t2;
        }),
    });
    
    let obj = unsafe { msg_send![msg_send![my_class, alloc], init] };
    let x: i32 = unsafe { msg_send![*obj, add:5 with:6] };
    assert_eq!(x, 11);