servo / cocoa-rs

DEPRECATED - Cocoa/Objective-C bindings for the Rust programming language
https://github.com/servo/core-foundation-rs/
Other
286 stars 72 forks source link

Implement NSWindowStyleMask as bitflags #160

Closed oluseyi closed 7 years ago

oluseyi commented 7 years ago

RE https://github.com/servo/cocoa-rs/issues/159

NSWindowStyleMask, as an enumeration in Objective-C, degrades to NSUInteger and is therefore bitwise-combinable, though it loses type information. Instead of implementing NSWindowStyleMask as a packed-data object with a u64 representational form, we ought to employ bit flags to generate a strong type that remains combinable in the manner Cocoa programmers are accustomed to. Also easier than manually implementing std::ops::BitOr for the type.


This change is Reviewable

jdm commented 7 years ago

@bors-servo: r+

bors-servo commented 7 years ago

:pushpin: Commit 135fce2 has been approved by jdm

bors-servo commented 7 years ago

:hourglass: Testing commit 135fce23857e5f6a85209d8f20a72a21f9aa5475 with merge 31d8ba22dca7c2510fce2d811b2e1bed34bc7844...

bors-servo commented 7 years ago

:broken_heart: Test failed - status-travis

jdm commented 7 years ago

Example needs to be updated now:

error[E0308]: mismatched types

  --> examples/hello_world.rs:40:59

   |

40 |                                                           NSTitledWindowMask as NSUInteger,

   |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `cocoa::appkit::NSWindowStyleMask`, found u64

   |

   = note: expected type `cocoa::appkit::NSWindowStyleMask`

              found type `u64`

error: non-scalar cast: `cocoa::appkit::NSWindowStyleMask` as `u64`

  --> examples/hello_world.rs:40:59

   |

40 |                                                           NSTitledWindowMask as NSUInteger,

   |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `cocoa`.
oluseyi commented 7 years ago

Yeah, saw the message from bors-servo. Was at lunch; committing now. Thanks @jdm.

jdm commented 7 years ago

@bors-servo: r+

bors-servo commented 7 years ago

:pushpin: Commit e773703 has been approved by jdm

bors-servo commented 7 years ago

:hourglass: Testing commit e773703bb5961f4ccc29bbd5f8797050bdc4459e with merge 4c63ce7a7115c415dcb62ece2e495f86d65e24c8...

bors-servo commented 7 years ago

:sunny: Test successful - status-travis Approved by: jdm Pushing 4c63ce7a7115c415dcb62ece2e495f86d65e24c8 to master...