Skip to content

Commit a1f2b77

Browse files
committed
Auto-generate parts of dispatch2::ffi
To: - Ensure that it's correct and complete. - Enable better documentation once we translate header comments too. - Allow better integration with frameworks in the future. Part of #77.
1 parent cd299d2 commit a1f2b77

25 files changed

+373
-458
lines changed

Cargo.lock

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/block2/translation-config.toml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ crate = "block2"
33
required-crates = []
44
link = false
55
skipped = true
6+
is-library = true
67

78
macos = "10.6"
89
maccatalyst = "13.0"

crates/dispatch2/CHANGELOG.md

+45
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,53 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## Unreleased - YYYY-MM-DD
88

9+
### Added
10+
- Added support for `objc2` encodings.
11+
- Added initial support for `block2`.
12+
- Autogenerated `ffi` bindings, which adds:
13+
- `dispatch_data_applier_t`.
14+
- `dispatch_fd_t`.
15+
- `dispatch_io_close_flags_t`.
16+
- `dispatch_io_handler_t`.
17+
- `dispatch_io_interval_flags_t`.
18+
- `dispatch_io_s` / `dispatch_io_t`.
19+
- `dispatch_io_type_t`.
20+
- `DISPATCH_WALLTIME_NOW`.
21+
- `_dispatch_source_type_mach_recv`.
22+
- `_dispatch_source_type_proc`.
23+
- `_dispatch_source_type_signal`.
24+
- `_dispatch_source_type_vnode`.
25+
- `dispatch_allow_send_signals`.
26+
- `dispatch_apply`.
27+
- `dispatch_cancel`.
28+
- `dispatch_data_apply`.
29+
- `dispatch_get_current_queueDeprecated`.
30+
- `dispatch_get_main_queue`.
31+
- `dispatch_io_barrier`.
32+
- `dispatch_io_close`.
33+
- `dispatch_io_create`.
34+
- `dispatch_io_create_with_io`.
35+
- `dispatch_io_create_with_path`.
36+
- `dispatch_io_get_descriptor`.
37+
- `dispatch_io_read`.
38+
- `dispatch_io_set_high_water`.
39+
- `dispatch_io_set_interval`.
40+
- `dispatch_io_set_low_water`.
41+
- `dispatch_io_write`.
42+
- `dispatch_notify`.
43+
- `dispatch_read`.
44+
- `dispatch_testcancel`.
45+
- `dispatch_wait`.
46+
- `dispatch_write`.
47+
- Added `#[must_use]` in bindings where the source uses it.
48+
949
### Changed
1050
- Moved to the `objc2` project.
51+
- **BREAKING**: Made `Queue::set_specific` take a key pointer instead of a `usize`.
52+
53+
### Fixed
54+
- **BREAKING**: Use `extern "C-unwind"` instead of `extern "C"` in certain functions that required that.
55+
- **BREAKING**: Use `isize` instead of `usize` in certain functions where that is more correct.
1156

1257

1358
## 0.1.0 - 2022-10-02

crates/dispatch2/Cargo.modified.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
version = "0.1.0" # Remember to update html_root_url in lib.rs
3+
description = "Bindings and wrappers for Apple's Grand Central Dispatch (GCD)"
4+
keywords = ["gcd", "macos", "ios", "dispatch", "libdispatch"]
5+
authors = ["Mads Marquart <[email protected]>", "Mary <[email protected]>"]
6+
license = "Apache-2.0 OR MIT"
7+
8+
[package.metadata.release]
9+
shared-version = false
10+
tag-prefix = "dispatch"
11+
enable-features = []

crates/dispatch2/Cargo.toml

+27-11
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
1+
# This file has been automatically generated by `objc2`'s `header-translator`.
2+
# DO NOT EDIT
3+
14
[package]
25
name = "dispatch2"
36
version = "0.1.0" # Remember to update html_root_url in lib.rs
47
description = "Bindings and wrappers for Apple's Grand Central Dispatch (GCD)"
5-
keywords = ["gcd", "macos", "ios", "dispatch", "libdispatch"]
6-
categories = [
7-
"api-bindings",
8-
"development-tools::ffi",
9-
"os::macos-apis",
10-
"external-ffi-bindings",
11-
]
12-
authors = ["Mads Marquart <[email protected]>", "Mary <[email protected]>"]
138
edition.workspace = true
149
rust-version.workspace = true
10+
keywords = ["gcd", "macos", "ios", "dispatch", "libdispatch"]
11+
categories.workspace = true
1512
repository.workspace = true
1613
license = "Apache-2.0 OR MIT"
14+
authors = ["Mads Marquart <[email protected]>", "Mary <[email protected]>"]
1715

1816
[lints]
1917
workspace = true
2018

2119
[dependencies]
22-
libc = "0.2"
20+
bitflags = { version = "2.5.0", default-features = false }
21+
block2 = { path = "../block2", version = "0.5.1", default-features = false, optional = true }
22+
libc = { version = "0.2.80", default-features = false, optional = true }
23+
objc2 = { path = "../objc2", version = "0.5.2", default-features = false, optional = true }
2324

2425
[package.metadata.docs.rs]
2526
default-target = "aarch64-apple-darwin"
26-
features = []
27+
features = ["all"]
2728
targets = [
2829
"aarch64-apple-darwin",
2930
"x86_64-apple-darwin",
3031
"aarch64-apple-ios",
31-
"x86_64-apple-ios",
3232
"aarch64-apple-tvos",
3333
"aarch64-apple-watchos",
3434
"aarch64-apple-ios-macabi",
3535
"x86_64-unknown-linux-gnu",
3636
"i686-unknown-linux-gnu",
3737
]
3838

39+
[features]
40+
default = ["std"]
41+
42+
# Currently not possible to turn off, put here for forwards compatibility.
43+
std = ["alloc", "bitflags/std", "block2?/std", "libc?/std", "objc2?/std"]
44+
alloc = ["block2?/alloc", "objc2?/alloc"]
45+
block2 = ["dep:block2"]
46+
libc = ["dep:libc"]
47+
objc2 = ["dep:objc2"]
48+
49+
all = [
50+
"block2",
51+
"libc",
52+
"objc2",
53+
]
54+
3955
[package.metadata.release]
4056
shared-version = false
4157
tag-prefix = "dispatch"

crates/dispatch2/README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
# `dispatch2`
22

33
[![Latest version](https://badgen.net/crates/v/dispatch2)](https://crates.io/crates/dispatch2)
4-
[![License](https://badgen.net/static/license/MIT%20OR%20Apache%202.0/blue)](https://github.com/madsmtm/objc2/blob/master/LICENSE.txt)
4+
[![License](https://badgen.net/badge/license/MIT%20OR%20Apache%202.0/blue)](../LICENSE.txt)
55
[![Documentation](https://docs.rs/dispatch2/badge.svg)](https://docs.rs/dispatch2/)
66
[![CI](https://github.com/madsmtm/objc2/actions/workflows/ci.yml/badge.svg)](https://github.com/madsmtm/objc2/actions/workflows/ci.yml)
77

8-
Apple's Grand Central Dispatch interface in Rust.
8+
Rust bindings to Apple's Grand Central Dispatch.
99

10-
This crate provides a safe and sound interface to Apple's Grand Central
11-
dispatch, as well as the ability to drop into lower-level bindings.
12-
13-
This README is kept intentionally small in an effort to consolidate the
14-
documentation, see [the Rust docs](https://docs.rs/dispatch2/) for more details.
10+
This README is kept intentionally small to consolidate the documentation, see
11+
[the Rust docs](https://docs.rs/dispatch2/) for more details on this crate.
1512

1613
This crate is part of the [`objc2` project](https://github.com/madsmtm/objc2),
1714
see that for related crates.

0 commit comments

Comments
 (0)