3838using namespace swift ::hashable_support;
3939
4040// TODO: Making this a SwiftObject subclass would let us use Swift refcounting,
41- // but we would need to be able to emit SwiftValue 's Objective-C class object
41+ // but we would need to be able to emit _SwiftValue 's Objective-C class object
4242// with the Swift destructor pointer prefixed before it.
4343//
44- // The layout of `SwiftValue ` is:
44+ // The layout of `_SwiftValue ` is:
4545// - object header,
4646// - `SwiftValueHeader` instance,
4747// - the payload, tail-allocated (the Swift value contained in this box).
48- @interface SwiftValue : NSObject <NSCopying >
48+ @interface _SwiftValue : NSObject <NSCopying >
4949
5050- (id )copyWithZone : (NSZone *)zone ;
5151
5252@end
5353
54- // / The fixed-size ivars of `SwiftValue `. The actual boxed value is
54+ // / The fixed-size ivars of `_SwiftValue `. The actual boxed value is
5555// / tail-allocated.
5656struct SwiftValueHeader {
57- // / The type of the value contained in the `SwiftValue ` box.
57+ // / The type of the value contained in the `_SwiftValue ` box.
5858 const Metadata *type;
5959
6060 // / The base type that introduces the `Hashable` conformance.
@@ -131,10 +131,10 @@ - (id)copyWithZone:(NSZone *)zone;
131131 */
132132
133133static Class _getSwiftValueClass () {
134- auto theClass = [SwiftValue class ];
135- // Fixed instance size of SwiftValue should be same as object header.
134+ auto theClass = [_SwiftValue class ];
135+ // Fixed instance size of _SwiftValue should be same as object header.
136136 assert (class_getInstanceSize (theClass) == SwiftValueHeaderOffset
137- && " unexpected size of SwiftValue ?!" );
137+ && " unexpected size of _SwiftValue ?!" );
138138 return theClass;
139139}
140140
@@ -147,13 +147,13 @@ static constexpr size_t getSwiftValuePayloadOffset(size_t alignMask) {
147147 ~alignMask;
148148}
149149
150- static SwiftValueHeader *getSwiftValueHeader (SwiftValue *v) {
150+ static SwiftValueHeader *getSwiftValueHeader (_SwiftValue *v) {
151151 auto instanceBytes = reinterpret_cast <char *>(v);
152152 return reinterpret_cast <SwiftValueHeader *>(instanceBytes +
153153 SwiftValueHeaderOffset);
154154}
155155
156- static OpaqueValue *getSwiftValuePayload (SwiftValue *v, size_t alignMask) {
156+ static OpaqueValue *getSwiftValuePayload (_SwiftValue *v, size_t alignMask) {
157157 auto instanceBytes = reinterpret_cast <char *>(v);
158158 return reinterpret_cast <OpaqueValue *>(instanceBytes +
159159 getSwiftValuePayloadOffset (alignMask));
@@ -163,18 +163,18 @@ static size_t getSwiftValuePayloadAlignMask(const Metadata *type) {
163163 return type->getValueWitnesses ()->getAlignmentMask () | SwiftValueMinAlignMask;
164164}
165165
166- const Metadata *swift::getSwiftValueTypeMetadata (SwiftValue *v) {
166+ const Metadata *swift::getSwiftValueTypeMetadata (_SwiftValue *v) {
167167 return getSwiftValueHeader (v)->type ;
168168}
169169
170170std::pair<const Metadata *, const OpaqueValue *>
171- swift::getValueFromSwiftValue (SwiftValue *v) {
171+ swift::getValueFromSwiftValue (_SwiftValue *v) {
172172 auto instanceType = getSwiftValueTypeMetadata (v);
173173 size_t alignMask = getSwiftValuePayloadAlignMask (instanceType);
174174 return {instanceType, getSwiftValuePayload (v, alignMask)};
175175}
176176
177- SwiftValue *swift::bridgeAnythingToSwiftValueObject (OpaqueValue *src,
177+ _SwiftValue *swift::bridgeAnythingToSwiftValueObject (OpaqueValue *src,
178178 const Metadata *srcType,
179179 bool consume) {
180180 size_t alignMask = getSwiftValuePayloadAlignMask (srcType);
@@ -183,7 +183,7 @@ static size_t getSwiftValuePayloadAlignMask(const Metadata *type) {
183183 getSwiftValuePayloadOffset (alignMask) + srcType->getValueWitnesses ()->size ;
184184
185185 void *instanceMemory = swift_slowAlloc (totalSize, alignMask);
186- SwiftValue *instance
186+ _SwiftValue *instance
187187 = objc_constructInstance (getSwiftValueClass (), instanceMemory);
188188 /* TODO: If we're able to become a SwiftObject subclass in the future,
189189 * change to this:
@@ -204,18 +204,18 @@ static size_t getSwiftValuePayloadAlignMask(const Metadata *type) {
204204 return instance;
205205}
206206
207- SwiftValue *swift::getAsSwiftValue (id object) {
208- // SwiftValue should have no subclasses or proxies. We can do an exact
207+ _SwiftValue *swift::getAsSwiftValue (id object) {
208+ // _SwiftValue should have no subclasses or proxies. We can do an exact
209209 // class check.
210210 if (object_getClass (object) == getSwiftValueClass ())
211211 return object;
212212 return nil ;
213213}
214214
215- @implementation SwiftValue
215+ @implementation _SwiftValue
216216
217217+ (instancetype )allocWithZone : (NSZone *)zone {
218- swift::crash (" SwiftValue cannot be instantiated" );
218+ swift::crash (" _SwiftValue cannot be instantiated" );
219219}
220220
221221- (id )copyWithZone : (NSZone *)zone {
@@ -299,7 +299,7 @@ - (NSUInteger)hash {
299299 selfHeader->type , hashableConformance);
300300}
301301
302- static NSString *getValueDescription (SwiftValue *self) {
302+ static NSString *getValueDescription (_SwiftValue *self) {
303303 String tmp;
304304 const Metadata *type;
305305 const OpaqueValue *value;
@@ -332,6 +332,6 @@ - (const OpaqueValue *)_swiftValue {
332332
333333@end
334334
335- // TODO: We could pick specialized SwiftValue subclasses for trivial types
335+ // TODO: We could pick specialized _SwiftValue subclasses for trivial types
336336// or for types with known size and alignment characteristics. Probably
337337// not enough of a real perf bottleneck to be worth it...
0 commit comments