Skip to content

Commit e05976f

Browse files
authored
Merge branch 'main' into master
2 parents cb9994d + e5162be commit e05976f

File tree

22 files changed

+139
-128
lines changed

22 files changed

+139
-128
lines changed

.github/workflows/rust.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Rust
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [main]
66
pull_request:
77
branches: ["**"]
88
merge_group:
@@ -31,8 +31,11 @@ jobs:
3131
runs-on: ${{ matrix.os }}
3232
strategy:
3333
matrix:
34-
os: [macos-11.0, macos-12, macos-13]
35-
toolchain: [stable, 1.56.1]
34+
os: [macos-11.0, macos-12, macos-13, macos-14]
35+
toolchain: [stable]
36+
include:
37+
- os: macos-14
38+
toolchain: 1.56.1
3639
steps:
3740
- uses: actions/checkout@v4
3841
- name: Install toolchain

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# core-foundation-rs
22

3-
[![Build Status](https://travis-ci.com/servo/core-foundation-rs.svg?branch=master)](https://travis-ci.com/servo/core-foundation-rs)
3+
[![Build Status](https://github.com/servo/core-foundation-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/servo/core-foundation-rs/actions)
44

55
## Compatibility
66

@@ -9,6 +9,7 @@ Targets macOS 10.7 by default.
99
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.
1010

1111
For more experimental but more complete, generated bindings take a look at https://github.com/michaelwu/RustKit.
12+
Other alternatives are https://github.com/nvzqz/fruity and https://gitlab.com/objrs/objrs
1213

1314
## Contributing
1415

cocoa-foundation/Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "cocoa-foundation"
44
description = "Bindings to Cocoa Foundation for macOS"
55
homepage = "https://github.com/servo/core-foundation-rs"
66
repository = "https://github.com/servo/core-foundation-rs"
7-
version = "0.1.2"
7+
version = "0.2.0"
88
authors = ["The Servo Project Developers"]
99
license = "MIT OR Apache-2.0"
1010
edition = "2018"
@@ -14,14 +14,13 @@ default-target = "x86_64-apple-darwin"
1414

1515
[dependencies]
1616
block = "0.1"
17-
bitflags = "1.0"
17+
bitflags = "2"
1818
libc = "0.2"
19-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
20-
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.1" }
19+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
20+
core-graphics-types = { default-features = false, path = "../core-graphics-types", version = "0.2" }
2121
objc = "0.2.3"
2222

2323
[features]
2424
default = ["link"]
2525
# Disable to manually link. Enabled by default.
2626
link = ["core-foundation/link", "core-graphics-types/link"]
27-

cocoa-foundation/src/foundation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ impl NSDictionary for id {
613613
}
614614

615615
bitflags! {
616+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
616617
pub struct NSEnumerationOptions: libc::c_ulonglong {
617618
const NSEnumerationConcurrent = 1 << 0;
618619
const NSEnumerationReverse = 1 << 1;
@@ -792,6 +793,7 @@ impl NSRunLoop for id {
792793
}
793794

794795
bitflags! {
796+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
795797
pub struct NSURLBookmarkCreationOptions: NSUInteger {
796798
const NSURLBookmarkCreationPreferFileIDResolution = 1 << 8;
797799
const NSURLBookmarkCreationMinimalBookmark = 1 << 9;
@@ -804,6 +806,7 @@ bitflags! {
804806
pub type NSURLBookmarkFileCreationOptions = NSURLBookmarkCreationOptions;
805807

806808
bitflags! {
809+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
807810
pub struct NSURLBookmarkResolutionOptions: NSUInteger {
808811
const NSURLBookmarkResolutionWithoutUI = 1 << 8;
809812
const NSURLBookmarkResolutionWithoutMounting = 1 << 9;
@@ -1590,6 +1593,7 @@ impl NSData for id {
15901593
}
15911594

15921595
bitflags! {
1596+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
15931597
pub struct NSDataReadingOptions: libc::c_ulonglong {
15941598
const NSDataReadingMappedIfSafe = 1 << 0;
15951599
const NSDataReadingUncached = 1 << 1;
@@ -1598,6 +1602,7 @@ bitflags! {
15981602
}
15991603

16001604
bitflags! {
1605+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
16011606
pub struct NSDataBase64EncodingOptions: libc::c_ulonglong {
16021607
const NSDataBase64Encoding64CharacterLineLength = 1 << 0;
16031608
const NSDataBase64Encoding76CharacterLineLength = 1 << 1;
@@ -1607,19 +1612,22 @@ bitflags! {
16071612
}
16081613

16091614
bitflags! {
1615+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
16101616
pub struct NSDataBase64DecodingOptions: libc::c_ulonglong {
16111617
const NSDataBase64DecodingIgnoreUnknownCharacters = 1 << 0;
16121618
}
16131619
}
16141620

16151621
bitflags! {
1622+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
16161623
pub struct NSDataWritingOptions: libc::c_ulonglong {
16171624
const NSDataWritingAtomic = 1 << 0;
16181625
const NSDataWritingWithoutOverwriting = 1 << 1;
16191626
}
16201627
}
16211628

16221629
bitflags! {
1630+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
16231631
pub struct NSDataSearchOptions: libc::c_ulonglong {
16241632
const NSDataSearchBackwards = 1 << 0;
16251633
const NSDataSearchAnchored = 1 << 1;

cocoa/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "cocoa"
44
description = "Bindings to Cocoa for macOS"
55
homepage = "https://github.com/servo/core-foundation-rs"
66
repository = "https://github.com/servo/core-foundation-rs"
7-
version = "0.25.0"
7+
version = "0.26.0"
88
authors = ["The Servo Project Developers"]
99
license = "MIT OR Apache-2.0"
1010
edition = "2018"
@@ -14,10 +14,10 @@ default-target = "x86_64-apple-darwin"
1414

1515
[dependencies]
1616
block = "0.1"
17-
bitflags = "1.0"
17+
bitflags = "2"
1818
libc = "0.2"
19-
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.1" }
20-
core-foundation = { default-features = false, path = "../core-foundation", version = "0.9" }
19+
cocoa-foundation = { default-features = false, path = "../cocoa-foundation", version = "0.2" }
20+
core-foundation = { default-features = false, path = "../core-foundation", version = "0.10" }
2121
core-graphics = { default-features = false, path = "../core-graphics", version = "0.24" }
2222
foreign-types = "0.5"
2323
objc = "0.2.3"

cocoa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Cocoa-rs
33

44
This crate provides Rust bindings to Cocoa for macOS. It's dual-licensed MIT /
55
Apache 2.0. If you'd like to help improve cocoa-rs, check out [the Servo
6-
contributing guide](https://github.com/servo/servo/blob/master/CONTRIBUTING.md)!
6+
contributing guide](https://github.com/servo/servo/blob/main/CONTRIBUTING.md)!

cocoa/src/appkit.rs

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub enum NSApplicationTerminateReply {
184184
}
185185

186186
bitflags! {
187+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
187188
pub struct NSApplicationPresentationOptions : NSUInteger {
188189
const NSApplicationPresentationDefault = 0;
189190
const NSApplicationPresentationAutoHideDock = 1 << 0;
@@ -202,6 +203,7 @@ bitflags! {
202203
}
203204

204205
bitflags! {
206+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
205207
pub struct NSWindowStyleMask: NSUInteger {
206208
const NSBorderlessWindowMask = 0;
207209
const NSTitledWindowMask = 1 << 0;
@@ -251,6 +253,7 @@ pub enum NSWindowToolbarStyle {
251253
}
252254

253255
bitflags! {
256+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
254257
pub struct NSWindowOrderingMode: NSInteger {
255258
const NSWindowAbove = 1;
256259
const NSWindowBelow = -1;
@@ -259,6 +262,7 @@ bitflags! {
259262
}
260263

261264
bitflags! {
265+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
262266
pub struct NSAlignmentOptions: libc::c_ulonglong {
263267
const NSAlignMinXInward = 1 << 0;
264268
const NSAlignMinYInward = 1 << 1;
@@ -279,18 +283,18 @@ bitflags! {
279283
const NSAlignWidthNearest = 1 << 20;
280284
const NSAlignHeightNearest = 1 << 21;
281285
const NSAlignRectFlipped = 1 << 63;
282-
const NSAlignAllEdgesInward = NSAlignmentOptions::NSAlignMinXInward.bits
283-
| NSAlignmentOptions::NSAlignMaxXInward.bits
284-
| NSAlignmentOptions::NSAlignMinYInward.bits
285-
| NSAlignmentOptions::NSAlignMaxYInward.bits;
286-
const NSAlignAllEdgesOutward = NSAlignmentOptions::NSAlignMinXOutward.bits
287-
| NSAlignmentOptions::NSAlignMaxXOutward.bits
288-
| NSAlignmentOptions::NSAlignMinYOutward.bits
289-
| NSAlignmentOptions::NSAlignMaxYOutward.bits;
290-
const NSAlignAllEdgesNearest = NSAlignmentOptions::NSAlignMinXNearest.bits
291-
| NSAlignmentOptions::NSAlignMaxXNearest.bits
292-
| NSAlignmentOptions::NSAlignMinYNearest.bits
293-
| NSAlignmentOptions::NSAlignMaxYNearest.bits;
286+
const NSAlignAllEdgesInward = NSAlignmentOptions::NSAlignMinXInward.bits()
287+
| NSAlignmentOptions::NSAlignMaxXInward.bits()
288+
| NSAlignmentOptions::NSAlignMinYInward.bits()
289+
| NSAlignmentOptions::NSAlignMaxYInward.bits();
290+
const NSAlignAllEdgesOutward = NSAlignmentOptions::NSAlignMinXOutward.bits()
291+
| NSAlignmentOptions::NSAlignMaxXOutward.bits()
292+
| NSAlignmentOptions::NSAlignMinYOutward.bits()
293+
| NSAlignmentOptions::NSAlignMaxYOutward.bits();
294+
const NSAlignAllEdgesNearest = NSAlignmentOptions::NSAlignMinXNearest.bits()
295+
| NSAlignmentOptions::NSAlignMaxXNearest.bits()
296+
| NSAlignmentOptions::NSAlignMinYNearest.bits()
297+
| NSAlignmentOptions::NSAlignMaxYNearest.bits();
294298
}
295299
}
296300

@@ -578,7 +582,7 @@ impl NSApplication for id {
578582
}
579583

580584
unsafe fn setPresentationOptions_(self, options: NSApplicationPresentationOptions) -> BOOL {
581-
msg_send![self, setPresentationOptions:options.bits]
585+
msg_send![self, setPresentationOptions:options.bits()]
582586
}
583587

584588
unsafe fn presentationOptions_(self) -> NSApplicationPresentationOptions {
@@ -1041,6 +1045,7 @@ impl NSMenuItem for id {
10411045
pub type NSWindowDepth = libc::c_int;
10421046

10431047
bitflags! {
1048+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
10441049
pub struct NSWindowCollectionBehavior: NSUInteger {
10451050
const NSWindowCollectionBehaviorDefault = 0;
10461051
const NSWindowCollectionBehaviorCanJoinAllSpaces = 1 << 0;
@@ -1059,6 +1064,7 @@ bitflags! {
10591064
}
10601065

10611066
bitflags! {
1067+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
10621068
pub struct NSWindowOcclusionState: NSUInteger {
10631069
const NSWindowOcclusionStateVisible = 1 << 1;
10641070
}
@@ -1351,7 +1357,7 @@ impl NSWindow for id {
13511357
defer: BOOL,
13521358
) -> id {
13531359
msg_send![self, initWithContentRect:rect
1354-
styleMask:style.bits
1360+
styleMask:style.bits()
13551361
backing:backing as NSUInteger
13561362
defer:defer]
13571363
}
@@ -1365,7 +1371,7 @@ impl NSWindow for id {
13651371
screen: id,
13661372
) -> id {
13671373
msg_send![self, initWithContentRect:rect
1368-
styleMask:style.bits
1374+
styleMask:style.bits()
13691375
backing:backing as NSUInteger
13701376
defer:defer
13711377
screen:screen]
@@ -1378,7 +1384,7 @@ impl NSWindow for id {
13781384
}
13791385

13801386
unsafe fn setStyleMask_(self, styleMask: NSWindowStyleMask) {
1381-
msg_send![self, setStyleMask:styleMask.bits]
1387+
msg_send![self, setStyleMask:styleMask.bits()]
13821388
}
13831389

13841390
unsafe fn toggleFullScreen_(self, sender: id) {
@@ -1507,23 +1513,23 @@ impl NSWindow for id {
15071513
windowFrame: NSRect,
15081514
windowStyle: NSWindowStyleMask,
15091515
) -> NSRect {
1510-
msg_send![self, contentRectForFrameRect:windowFrame styleMask:windowStyle.bits]
1516+
msg_send![self, contentRectForFrameRect:windowFrame styleMask:windowStyle.bits()]
15111517
}
15121518

15131519
unsafe fn frameRectForContentRect_styleMask_(
15141520
self,
15151521
windowContentRect: NSRect,
15161522
windowStyle: NSWindowStyleMask,
15171523
) -> NSRect {
1518-
msg_send![self, frameRectForContentRect:windowContentRect styleMask:windowStyle.bits]
1524+
msg_send![self, frameRectForContentRect:windowContentRect styleMask:windowStyle.bits()]
15191525
}
15201526

15211527
unsafe fn minFrameWidthWithTitle_styleMask_(
15221528
self,
15231529
windowTitle: id,
15241530
windowStyle: NSWindowStyleMask,
15251531
) -> CGFloat {
1526-
msg_send![self, minFrameWidthWithTitle:windowTitle styleMask:windowStyle.bits]
1532+
msg_send![self, minFrameWidthWithTitle:windowTitle styleMask:windowStyle.bits()]
15271533
}
15281534

15291535
unsafe fn contentRectForFrameRect_(self, windowFrame: NSRect) -> NSRect {
@@ -2517,6 +2523,7 @@ impl NSOpenGLContext for id {
25172523
}
25182524

25192525
bitflags! {
2526+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
25202527
pub struct NSEventSwipeTrackingOptions: NSUInteger {
25212528
const NSEventSwipeTrackingLockDirection = 0x1 << 0;
25222529
const NSEventSwipeTrackingClampGestureAmount = 0x1 << 1;
@@ -2531,6 +2538,7 @@ pub enum NSEventGestureAxis {
25312538
}
25322539

25332540
bitflags! {
2541+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
25342542
pub struct NSEventPhase: NSUInteger {
25352543
const NSEventPhaseNone = 0;
25362544
const NSEventPhaseBegan = 0x1 << 0;
@@ -2543,15 +2551,16 @@ bitflags! {
25432551
}
25442552

25452553
bitflags! {
2554+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
25462555
pub struct NSTouchPhase: NSUInteger {
25472556
const NSTouchPhaseBegan = 1 << 0;
25482557
const NSTouchPhaseMoved = 1 << 1;
25492558
const NSTouchPhaseStationary = 1 << 2;
25502559
const NSTouchPhaseEnded = 1 << 3;
25512560
const NSTouchPhaseCancelled = 1 << 4;
2552-
const NSTouchPhaseTouching = NSTouchPhase::NSTouchPhaseBegan.bits
2553-
| NSTouchPhase::NSTouchPhaseMoved.bits
2554-
| NSTouchPhase::NSTouchPhaseStationary.bits;
2561+
const NSTouchPhaseTouching = NSTouchPhase::NSTouchPhaseBegan.bits()
2562+
| NSTouchPhase::NSTouchPhaseMoved.bits()
2563+
| NSTouchPhase::NSTouchPhaseStationary.bits();
25552564
const NSTouchPhaseAny = !0; // NSUIntegerMax
25562565
}
25572566
}
@@ -2592,6 +2601,7 @@ pub enum NSEventType {
25922601
}
25932602

25942603
bitflags! {
2604+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
25952605
pub struct NSEventMask: libc::c_ulonglong {
25962606
const NSLeftMouseDownMask = 1 << NSLeftMouseDown as libc::c_ulonglong;
25972607
const NSLeftMouseUpMask = 1 << NSLeftMouseUp as libc::c_ulonglong;
@@ -2628,13 +2638,12 @@ bitflags! {
26282638

26292639
impl NSEventMask {
26302640
pub fn from_type(ty: NSEventType) -> NSEventMask {
2631-
NSEventMask {
2632-
bits: 1 << ty as libc::c_ulonglong,
2633-
}
2641+
NSEventMask::from_bits_truncate(1 << ty as libc::c_ulonglong)
26342642
}
26352643
}
26362644

26372645
bitflags! {
2646+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
26382647
pub struct NSEventModifierFlags: NSUInteger {
26392648
const NSAlphaShiftKeyMask = 1 << 16;
26402649
const NSShiftKeyMask = 1 << 17;

cocoa/src/quartzcore.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,7 @@ impl Filter {
11761176
}
11771177

11781178
bitflags! {
1179+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
11791180
pub struct EdgeAntialiasingMask: u32 {
11801181
const LEFT_EDGE = 1 << 0; // kCALayerLeftEdge
11811182
const RIGHT_EDGE = 1 << 1; // kCALayerRightEdge
@@ -1185,6 +1186,7 @@ bitflags! {
11851186
}
11861187

11871188
bitflags! {
1189+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
11881190
pub struct CornerMask: NSUInteger {
11891191
const MIN_X_MIN_Y_CORNER = 1 << 0; // kCALayerMinXMinYCorner
11901192
const MAX_X_MIN_Y_CORNER = 1 << 1; // kCALayerMaxXMinYCorner
@@ -1194,6 +1196,7 @@ bitflags! {
11941196
}
11951197

11961198
bitflags! {
1199+
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
11971200
pub struct AutoresizingMask: u32 {
11981201
const NOT_SIZABLE = 0; // kCALayerNotSizable
11991202
const MIN_X_MARGIN = 1 << 0; // kCALayerMinXMargin

0 commit comments

Comments
 (0)