bors-servo 965cc88a91 Auto merge of #314 - Litarvan:master, r=jdm
delegate! macro, a higher-level way to create Cocoa delegates (e.g. NSWindowDelegate)

As @vbo mentioned in #205 the only way to create cocoa delegates such as NSWindowDelegate is to use the objc crate and it's a bit hard.

I thought a macro for this would be useful.

## Example with NSWindowDelegate

Without macro :
```rust
let mut decl = ClassDecl::new("MyWindowDelegate", class!(NSObject)).unwrap();

decl.add_ivar::<id>("window");
decl.add_method(sel!(windowWillEnterFullScreen:), on_enter_fullscreen as extern fn(&Object, Sel, id));

let cl = decl.register();

let delegate: id = msg_send![cl, alloc];
(*delegate).set_ivar("window", window);

window.setDelegate_(delegate);
```

With macro :
```rust
window.setDelegate_(delegate!("MyWindowDelegate", {
    window: id = window,
    (windowWillEnterFullScreen:) => on_enter_fullscreen as extern fn(&Object, Sel, id)
}));
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/314)
<!-- Reviewable:end -->
2019-05-02 17:23:44 -04:00
2019-05-02 20:05:36 +02:00
2018-02-01 15:57:28 -05:00
2013-04-04 19:01:35 -07:00
2013-04-03 18:18:52 -07:00
2013-04-03 18:18:52 -07:00
2019-03-14 17:42:22 +07:00

core-foundation-rs

Build Status

Compatibility

Targets macOS 10.7 by default.

To enable features added in macOS 10.8, set Cargo feature mac_os_10_8_features. To have both 10.8 features and 10.7 compatibility, also set mac_os_10_7_support. Setting both requires weak linkage, which is a nightly-only feature as of Rust 1.19.

For more experimental but more complete, generated bindings take a look at https://github.com/michaelwu/RustKit.

S
Description
No description provided
Readme 2.5 MiB
Languages
Rust 100%