Skip to content

Commit 74a8c52

Browse files
authored
Some fixes/cleanup to TestContent.md (#948)
Proofreading is your friend. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent fb93dd4 commit 74a8c52

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Documentation/ABI/TestContent.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ struct SWTTestContentRecord {
7575
};
7676
```
7777

78-
Do not use the `__TestContentRecord` typealias defined in the testing library.
79-
This type exists to support the testing library's macros and may change in the
80-
future (e.g. to accomodate a generic argument or to make use of one of the
81-
reserved fields.)
78+
Do not use the `__TestContentRecord` or `__TestContentRecordAccessor` typealias
79+
defined in the testing library. These types exist to support the testing
80+
library's macros and may change in the future (e.g. to accomodate a generic
81+
argument or to make use of a reserved field.)
8282

83-
Instead, define your own copy of this type where needed—you can copy the
84-
definition above _verbatim_. If your test record type's `context` field (as
83+
Instead, define your own copy of these types where needed—you can copy the
84+
definitions above _verbatim_. If your test record type's `context` field (as
8585
described below) is a pointer type, make sure to change its type in your version
8686
of `TestContentRecord` accordingly so that, on systems with pointer
8787
authentication enabled, the pointer is correctly resigned at load time.
@@ -108,16 +108,16 @@ other fields in that record are undefined.
108108
#### The accessor field
109109

110110
The function `accessor` is a C function. When called, it initializes the memory
111-
at its argument `outValue` to an instance of some Swift type and returns `true`,
112-
or returns `false` if it could not generate the relevant content. On successful
113-
return, the caller is responsible for deinitializing the memory at `outValue`
114-
when done with it.
111+
at `outValue` to an instance of the appropriate type and returns `true`; or, if
112+
it could not generate the relevant content, it leaves the memory uninitialized
113+
and returns `false`. On successful return, the caller is responsible for
114+
deinitializing the memory at `outValue` when done with it.
115115

116116
If `accessor` is `nil`, the test content record is ignored. The testing library
117117
may, in the future, define record kinds that do not provide an accessor function
118118
(that is, they represent pure compile-time information only.)
119119

120-
The second argument to this function, `type`, is a pointer to the type[^mightNotBeSwift]
120+
The third argument to this function, `type`, is a pointer to the type[^mightNotBeSwift]
121121
(not a bitcast Swift type) of the value expected to be written to `outValue`.
122122
This argument helps to prevent memory corruption if two copies of Swift Testing
123123
or a third-party library are inadvertently loaded into the same process. If the
@@ -131,9 +131,10 @@ accessor function must return `false` and must not modify `outValue`.
131131
other than Swift is beyond the scope of this document. With that in mind, it
132132
is _technically_ feasible for a test content accessor to be written in (for
133133
example) C++, expect the `type` argument to point to a C++ value of type
134-
`std::type_info`, and write a C++ class instance to `outValue`.
134+
[`std::type_info`](https://en.cppreference.com/w/cpp/types/type_info), and
135+
write a C++ class instance to `outValue` using [placement `new`](https://en.cppreference.com/w/cpp/language/new#Placement_new).
135136

136-
The third argument to this function, `hint`, is an optional input that can be
137+
The fourth argument to this function, `hint`, is an optional input that can be
137138
passed to help the accessor function determine if its corresponding test content
138139
record matches what the caller is looking for. If the caller passes `nil` as the
139140
`hint` argument, the accessor behaves as if it matched (that is, no additional
@@ -170,8 +171,8 @@ by `type`, and the value pointed to by `hint` depend on the kind of record:
170171
> and/or [`withUnsafePointer(to:_:)`](https://developer.apple.com/documentation/swift/withunsafepointer(to:_:)-35wrn)
171172
> to ensure the pointers passed to `accessor` are large enough and are
172173
> well-aligned. If they are not large enough to contain values of the
173-
> appropriate types (per above), or if `hint` points to uninitialized or
174-
> incorrectly-typed memory, the result is undefined.
174+
> appropriate types (per above), or if `type` or `hint` points to uninitialized
175+
> or incorrectly-typed memory, the result is undefined.
175176
176177
#### The context field
177178

0 commit comments

Comments
 (0)