23
23
#if defined(WANT_ALL_VALUE_WITNESSES)
24
24
#undef WANT_ALL_VALUE_WITNESSES
25
25
#define WANT_REQUIRED_VALUE_WITNESSES 1
26
- #define WANT_EXTRA_INHABITANT_VALUE_WITNESSES 1
27
26
#define WANT_ENUM_VALUE_WITNESSES 1
28
27
29
28
// / WANT_ONLY_REQUIRED_VALUE_WITNESSES
30
29
// / Define this to expand only the required value witnesses.
31
30
#elif defined(WANT_ONLY_REQUIRED_VALUE_WITNESSES)
32
31
#undef WANT_ONLY_REQUIRED_VALUE_WITNESSES
33
32
#define WANT_REQUIRED_VALUE_WITNESSES 1
34
- #define WANT_EXTRA_INHABITANT_VALUE_WITNESSES 0
35
- #define WANT_ENUM_VALUE_WITNESSES 0
36
-
37
- // / WANT_ONLY_EXTRA_INHABITANT_VALUE_WITNESSES
38
- // / Define this to expand only the extra-inhabitant value witnesses.
39
- #elif defined(WANT_ONLY_EXTRA_INHABITANT_VALUE_WITNESSES)
40
- #undef WANT_ONLY_EXTRA_INHABITANT_VALUE_WITNESSES
41
- #define WANT_REQUIRED_VALUE_WITNESSES 0
42
- #define WANT_EXTRA_INHABITANT_VALUE_WITNESSES 1
43
33
#define WANT_ENUM_VALUE_WITNESSES 0
44
34
45
35
// / WANT_ONLY_ENUM_VALUE_WITNESSES
46
36
// / Define this to expand only the enum value witnesses.
47
37
#elif defined(WANT_ONLY_ENUM_VALUE_WITNESSES)
48
38
#undef WANT_ONLY_ENUM_VALUE_WITNESSES
49
39
#define WANT_REQUIRED_VALUE_WITNESSES 0
50
- #define WANT_EXTRA_INHABITANT_VALUE_WITNESSES 0
51
40
#define WANT_ENUM_VALUE_WITNESSES 1
52
41
53
42
// / WANT_REQUIRED_VALUE_WITNESSES
54
- // / WANT_EXTRA_INHABITANT_VALUE_WITNESSES
55
43
// / WANT_ENUM_VALUE_WITNESSES
56
44
// / Define all of these to control exactly what to expand.
57
45
#else
58
- #if !defined(WANT_REQUIRED_VALUE_WITNESSES) || !defined(WANT_EXTRA_INHABITANT_VALUE_WITNESSES) || !defined(WANT_ENUM_VALUE_WITNESSES)
46
+ #if !defined(WANT_REQUIRED_VALUE_WITNESSES) || !defined(WANT_ENUM_VALUE_WITNESSES)
59
47
#error failed to define a WANT macro; possible typo?
60
48
#endif
61
49
#endif
@@ -206,7 +194,16 @@ BEGIN_VALUE_WITNESS_RANGE(TypeLayoutWitness,
206
194
BEGIN_VALUE_WITNESS_RANGE(RequiredTypeLayoutWitness,
207
195
Size )
208
196
209
- // / SIZE_TYPE flags;
197
+ // / SIZE_TYPE stride;
198
+ // /
199
+ // / The required size per element of an array of this type. It is at least
200
+ // / one, even for zero-sized types, like the empty tuple.
201
+ DATA_VALUE_WITNESS(stride,
202
+ Stride,
203
+ SIZE_TYPE)
204
+
205
+
206
+ // / UINT_TYPE flags;
210
207
// /
211
208
// / The ValueWitnessAlignmentMask bits represent the required
212
209
// / alignment of the first byte of an object of this type, expressed
@@ -222,97 +219,35 @@ BEGIN_VALUE_WITNESS_RANGE(RequiredTypeLayoutWitness,
222
219
// / The ValueWitnessIsNonInline bit is set if the type cannot be
223
220
// / represented in a fixed-size buffer or if it is not bitwise takable.
224
221
// /
225
- // / The Enum_HasExtraInhabitants bit is set if the type's binary
226
- // / representation has "extra inhabitants" that do not form valid values of
227
- // / the type, and the value witness table contains the ExtraInhabitantWitness
228
- // / entries.
222
+ // / The ExtraInhabitantsMask bits represent the number of "extra inhabitants"
223
+ // / of the bit representation of the value that do not form valid values of
224
+ // / the type.
229
225
// /
230
226
// / The Enum_HasSpareBits bit is set if the type's binary representation
231
227
// / has unused bits.
232
228
// /
233
229
// / The HasEnumWitnesses bit is set if the type is an enum type.
234
230
DATA_VALUE_WITNESS(flags,
235
231
Flags,
236
- SIZE_TYPE )
232
+ UINT_TYPE )
237
233
238
- // / SIZE_TYPE stride ;
234
+ // / UINT_TYPE extraInhabitantCount ;
239
235
// /
240
- // / The required size per element of an array of this type. It is at least
241
- // / one, even for zero-sized types, like the empty tuple.
242
- DATA_VALUE_WITNESS(stride,
243
- Stride,
244
- SIZE_TYPE)
236
+ // / The number of extra inhabitants in the type.
237
+ DATA_VALUE_WITNESS(extraInhabitantCount,
238
+ ExtraInhabitantCount,
239
+ UINT_TYPE)
245
240
246
241
END_VALUE_WITNESS_RANGE(RequiredTypeLayoutWitness,
247
- Stride )
242
+ ExtraInhabitantCount )
248
243
249
244
END_VALUE_WITNESS_RANGE(RequiredValueWitness,
250
- Stride)
251
-
252
- #endif /* WANT_REQUIRED_VALUE_WITNESSES */
253
-
254
- #if WANT_EXTRA_INHABITANT_VALUE_WITNESSES
255
-
256
- // The following value witnesses are conditionally present based on
257
- // the Enum_HasExtraInhabitants bit of the flags.
258
-
259
- // / SIZE_TYPE extraInhabitantFlags;
260
- // /
261
- // / These bits are always present if the extra inhabitants witnesses are:
262
- // /
263
- // / - The NumExtraInhabitantsMask bits contain the number of extra
264
- // / inhabitants of the type representation.
265
- // /
266
- // / If the Enum_HasSpareBits flag is set in the value witness flags, these
267
- // / additional flags are available:
268
- // /
269
- // / - The NumSpareBitsMask bits contain the number of (host-endian) contiguous
270
- // / spare bits in the type representation.
271
- // / - The SpareBitsShiftMask bits contain the (host-endian) bit offset of the
272
- // / lowest spare bit.
273
- DATA_VALUE_WITNESS (extraInhabitantFlags,
274
- ExtraInhabitantFlags,
275
- SIZE_TYPE)
276
-
277
- BEGIN_VALUE_WITNESS_RANGE(ExtraInhabitantValueWitness,
278
- ExtraInhabitantFlags)
245
+ ExtraInhabitantCount)
279
246
280
247
END_VALUE_WITNESS_RANGE(TypeLayoutWitness,
281
- ExtraInhabitantFlags)
282
-
283
- // / void (*storeExtraInhabitant)(T *obj, int index, M *self);
284
- // /
285
- // / Given an invalid object of this type, store the representation of an
286
- // / extra inhabitant of the type. The object will remain invalid, because
287
- // / an extra inhabitant is by definition an invalid representation of the
288
- // / type. index must be less than numExtraInhabitants.
289
- FUNCTION_VALUE_WITNESS(storeExtraInhabitant,
290
- StoreExtraInhabitant,
291
- VOID_TYPE,
292
- (MUTABLE_VALUE_TYPE, INT_TYPE, TYPE_TYPE))
293
-
294
- BEGIN_VALUE_WITNESS_RANGE(ExtraInhabitantValueWitnessFunction,
295
- StoreExtraInhabitant)
296
-
297
- // / int (*getExtraInhabitantIndex)(T *obj, M *self);
298
- // /
299
- // / Given an invalid object of this type with an extra inhabitant
300
- // / representation, returns the index of the extra inhabitant representation.
301
- // / Returns -1 if the object is a valid value of the type. If non-negative,
302
- // / the return value is the same index that can be passed to
303
- // / storeExtraInhabitant to reproduce the representation.
304
- FUNCTION_VALUE_WITNESS(getExtraInhabitantIndex,
305
- GetExtraInhabitantIndex,
306
- INT_TYPE,
307
- (IMMUTABLE_VALUE_TYPE, TYPE_TYPE))
308
-
309
- END_VALUE_WITNESS_RANGE(ExtraInhabitantValueWitnessFunction,
310
- GetExtraInhabitantIndex)
248
+ ExtraInhabitantCount)
311
249
312
- END_VALUE_WITNESS_RANGE(ExtraInhabitantValueWitness,
313
- GetExtraInhabitantIndex)
314
-
315
- #endif /* WANT_EXTRA_INHABITANT_VALUE_WITNESSES */
250
+ #endif /* WANT_REQUIRED_VALUE_WITNESSES */
316
251
317
252
#if WANT_ENUM_VALUE_WITNESSES
318
253
@@ -372,9 +307,7 @@ END_VALUE_WITNESS_RANGE(ValueWitness,
372
307
#undef FUNCTION_VALUE_WITNESS
373
308
#undef VALUE_WITNESS
374
309
#undef ENUM_VALUE_WITNESS
375
- #undef EXTRA_INHABITANT_VALUE_WITNESS
376
310
#undef NON_REQUIRED_VALUE_WITNESS
377
311
#undef REQUIRED_VALUE_WITNESS
378
312
#undef WANT_ENUM_VALUE_WITNESSES
379
- #undef WANT_EXTRA_INHABITANT_VALUE_WITNESSES
380
313
#undef WANT_REQUIRED_VALUE_WITNESSES
0 commit comments