Skip to content

Commit ee2afe2

Browse files
authored
Merge pull request #452 from madsmtm/doc
Improve examples and remove words that downplay the difficulty of a given task
2 parents 1c3f05c + d5a6ccf commit ee2afe2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+419
-342
lines changed

crates/block-sys/README.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,27 @@ see that for related crates.
1313

1414
## Runtime Support
1515

16-
This library is basically just a raw interface to the aptly specified [Blocks
17-
ABI](https://clang.llvm.org/docs/Block-ABI-Apple.html). However, different
18-
runtime implementations exist and act in slightly different ways (and have
19-
several different helper functions), the most important aspect being that the
20-
libraries are named differently, so the linking must take that into account.
21-
22-
The user can choose the desired runtime by using the relevant cargo feature
23-
flags, see the following sections (might have to disable the default `apple`
16+
This library is a raw interface to the aptly specified [Blocks ABI][abi].
17+
However, different runtime implementations exist and act in slightly different
18+
ways (and have several different helper functions), the most important aspect
19+
being that the libraries are named differently, so the linking must take that
20+
into account.
21+
22+
You can choose the desired runtime by using the relevant cargo feature flags,
23+
see the following sections (you might have to disable the default `apple`
2424
feature first). Note that if the `objc-sys` crate is present in the module
2525
tree, this should have the same feature flag enabled as that.
2626

2727

28+
[abi]: https://clang.llvm.org/docs/Block-ABI-Apple.html
29+
30+
2831
### Apple's [`libclosure`](https://github.com/apple-oss-distributions/libclosure)
2932

3033
- Feature flag: `apple`.
3134

32-
This is naturally the most sophisticated runtime, and it has quite a lot more
33-
features than the specification mandates. This is used by default.
35+
This is the most sophisticated runtime, and it has quite a lot more features
36+
than the specification mandates. It is used by default.
3437

3538
The minimum required operating system versions are as follows:
3639
- macOS: `10.6`
@@ -45,11 +48,11 @@ Though in practice Rust itself requires higher versions than this.
4548

4649
- Feature flag: `compiler-rt`.
4750

48-
This is effectively just a copy of Apple's older (around macOS 10.6) runtime,
49-
and is now used in [Swift's `libdispatch`] and [Swift's Foundation] as well.
51+
This is a copy of Apple's older (around macOS 10.6) runtime, and is now used
52+
in [Swift's `libdispatch`] and [Swift's Foundation] as well.
5053

51-
This can be easily used on many Linux systems with the `libblocksruntime-dev`
52-
package.
54+
The runtime and associated headers can be installed on many Linux systems with
55+
the `libblocksruntime-dev` package.
5356

5457
Using this runtime probably won't work together with `objc-sys` crate.
5558

@@ -77,8 +80,8 @@ Sources:
7780

7881
**Unstable: Hasn't been tested on Windows yet!**
7982

80-
Essentially just [a fork](https://github.com/microsoft/libobjc2) based on
81-
GNUStep's `libobjc2` version 1.8.
83+
[A fork](https://github.com/microsoft/libobjc2) based on GNUStep's `libobjc2`
84+
version 1.8.
8285

8386

8487
### [`ObjFW`](https://github.com/ObjFW/ObjFW)

crates/block-sys/build.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ fn main() {
3030

3131
match (apple, compiler_rt, gnustep, objfw) {
3232
(true, false, false, false) => {
33-
// Link to libclosure (internally called libsystem_blocks), which is
34-
// exported by libSystem.dylib.
33+
// Link to libclosure (internally called libsystem_blocks), which
34+
// is exported by libSystem.dylib.
3535
//
36-
// Note that System.framework is just a deprecated wrapper over the
37-
// dynamic library.
36+
// Note: Don't get confused by the presence of `System.framework`,
37+
// it is a deprecated wrapper over the dynamic library, so we'd
38+
// rather use the latter.
3839
println!("cargo:rustc-link-lib=dylib=System");
3940
// Alternative: Only link to libsystem_blocks.dylib
4041
// println!("cargo:rustc-link-search=native=/usr/lib/system");

crates/block-sys/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ pub struct Block_layout {
284284
/// }
285285
/// ```
286286
///
287-
/// But it is safe to access this through just `Block_descriptor_header`.
287+
/// But since all of these start with `Block_descriptor_header`, it is
288+
/// always safe to reinterpret this pointer as that.
288289
// Note: Important to use `*const c_void` until we know which type it is!
289290
pub descriptor: *const c_void,
290291
}

crates/block2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
Apple's C language extension of blocks in Rust.
99

10-
This crate provides functionality for interracting with C blocks, which is
11-
effectively the C-equivalent of Rust's closures.
10+
This crate provides functionality for interracting with C blocks, which is the
11+
C-equivalent of Rust's closures.
1212

1313
They are _technically_ not limited to only being used in Objective-C, though
1414
in practice it's likely the only place you'll ever encounter them.

crates/block2/src/block.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ block_args_impl!(
9090
#[repr(C)]
9191
pub struct Block<A, R> {
9292
_inner: [u8; 0],
93-
// We effectively store `Block_layout` + a bit more, but `Block` has to
94-
// remain an empty type otherwise the compiler thinks we only have
95-
// provenance over `Block_layout`.
93+
// We store `Block_layout` + a bit more, but `Block` has to remain an
94+
// empty type otherwise the compiler thinks we only have provenance over
95+
// `Block_layout`.
9696
_layout: PhantomData<ffi::Block_layout>,
9797
// To get correct variance on args and return types
9898
_p: PhantomData<fn(A) -> R>,

crates/block2/src/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const GLOBAL_DESCRIPTOR: ffi::Block_descriptor_header = ffi::Block_descriptor_he
1818

1919
/// An Objective-C block that does not capture its environment.
2020
///
21-
/// This is effectively just a glorified function pointer, and can created and
21+
/// This is effectively a glorified function pointer, and can created and
2222
/// stored in static memory using the [`global_block!`] macro.
2323
///
2424
/// If [`ConcreteBlock`] is the [`Fn`]-block equivalent, this is likewise the

crates/block2/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! # Apple's C language extension of blocks
22
//!
3-
//! C Blocks are effectively the C-equivalent of Rust's closures, in that they
4-
//! have the ability to capture their environments.
3+
//! C Blocks are the C-equivalent of Rust's closures, in that they have the
4+
//! ability to capture their environments.
55
//!
66
//! This crate provides capabilities to create and invoke these blocks, in an
77
//! ergonomic "Rust-centric" fashion.

crates/header-translator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cargo run --bin header-translator
1111

1212
Make sure you have the same XCode version installed as the one documented in [`crates/icrate/README.md`](../icrate/README.md).
1313

14-
If you use a different operating system than macOS, or simply have multiple SDKs installed, you can specify the directory as the first argument:
14+
If you use a different operating system than macOS, or have multiple SDKs installed, you can specify the directory as the first argument:
1515

1616
```console
1717
cargo run --bin header-translator -- /Applications/Xcode_new.app/Contents/Developer

crates/header-translator/src/data/CoreAnimation.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ data! {
4848
// `nil` superlayer.
4949

5050
// If the layer already has a superlayer, it will be changed
51-
// appropriately by these methods (effectively, removeFromSuperlayer
52-
// is called on the given layer inside these).
51+
// appropriately by these methods (`removeFromSuperlayer` is called on
52+
// the given layer inside these).
5353
unsafe -addSublayer;
5454
unsafe -insertSublayer_atIndex;
5555
unsafe -insertSublayer_below;
@@ -193,8 +193,7 @@ data! {
193193
unsafe -endFrame;
194194
}
195195

196-
// SAFETY: CATransaction is basically just a way to call methods that
197-
// access thread-local state.
196+
// SAFETY: CATransaction methods access thread-local state.
198197
class CATransaction {
199198
unsafe +begin;
200199
unsafe +commit;

crates/header-translator/src/method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl MemoryManagement {
170170
// And if:
171171
// > its signature obeys the added restrictions of the method family.
172172
//
173-
// Which is just:
173+
// Which is:
174174
// > must return a retainable object pointer
175175
if result_type.is_id() {
176176
// We also check that the correct modifier flags were set for the

0 commit comments

Comments
 (0)