@@ -75,13 +75,13 @@ struct SWTTestContentRecord {
75
75
};
76
76
```
77
77
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 .)
82
82
83
- Instead, define your own copy of this type where needed&mdash ; 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&mdash ; you can copy the
84
+ definitions above _ verbatim_ . If your test record type's ` context ` field (as
85
85
described below) is a pointer type, make sure to change its type in your version
86
86
of ` TestContentRecord ` accordingly so that, on systems with pointer
87
87
authentication enabled, the pointer is correctly resigned at load time.
@@ -108,16 +108,16 @@ other fields in that record are undefined.
108
108
#### The accessor field
109
109
110
110
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.
115
115
116
116
If ` accessor ` is ` nil ` , the test content record is ignored. The testing library
117
117
may, in the future, define record kinds that do not provide an accessor function
118
118
(that is, they represent pure compile-time information only.)
119
119
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 ]
121
121
(not a bitcast Swift type) of the value expected to be written to ` outValue ` .
122
122
This argument helps to prevent memory corruption if two copies of Swift Testing
123
123
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`.
131
131
other than Swift is beyond the scope of this document. With that in mind, it
132
132
is _ technically_ feasible for a test content accessor to be written in (for
133
133
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 ) .
135
136
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
137
138
passed to help the accessor function determine if its corresponding test content
138
139
record matches what the caller is looking for. If the caller passes ` nil ` as the
139
140
` 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:
170
171
> and/or [ ` withUnsafePointer(to:_:) ` ] ( https://developer.apple.com/documentation/swift/withunsafepointer(to:_:)-35wrn )
171
172
> to ensure the pointers passed to ` accessor ` are large enough and are
172
173
> 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.
175
176
176
177
#### The context field
177
178
0 commit comments