File tree Expand file tree Collapse file tree 3 files changed +15
-18
lines changed Expand file tree Collapse file tree 3 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,6 @@ public class NSSimpleCString {}
22
22
@available ( * , unavailable, message: " Please use String or NSString " )
23
23
public class NSConstantString { }
24
24
25
- // Called by the SwiftObject implementation.
26
- public func _getDescription< T> ( _ x: T ) -> NSString {
27
- return String ( reflecting: x) . _bridgeToObjectiveC ( )
28
- }
29
-
30
25
extension NSString : ExpressibleByStringLiteral {
31
26
/// Create an instance initialized to `value`.
32
27
public required convenience init ( stringLiteral value: StaticString ) {
Original file line number Diff line number Diff line change @@ -368,6 +368,14 @@ extension String {
368
368
}
369
369
}
370
370
371
+ // Called by the SwiftObject implementation to get the description of a value
372
+ // as an NSString.
373
+ @_silgen_name ( " swift_stdlib_getDescription " )
374
+ public func _getDescription< T> ( _ x: T ) -> AnyObject {
375
+ return String ( reflecting: x) . _bridgeToObjectiveCImpl ( )
376
+ }
377
+
378
+
371
379
#else // !_runtime(_ObjC)
372
380
373
381
@_fixed_layout // FIXME(sil-serialize-all)
Original file line number Diff line number Diff line change @@ -147,20 +147,14 @@ static Class _swift_getObjCClassOfAllocated(const void *object) {
147
147
class_getInstanceSize (cls), mask));
148
148
}
149
149
150
- NSString *swift::getDescription (OpaqueValue *value, const Metadata *type) {
151
- typedef SWIFT_CC (swift) NSString *GetDescriptionFn (OpaqueValue*, const Metadata*);
152
- auto getDescription = SWIFT_LAZY_CONSTANT (
153
- reinterpret_cast <GetDescriptionFn*>(dlsym (RTLD_DEFAULT,
154
- MANGLE_AS_STRING (MANGLE_SYM (10Foundation15_getDescriptionySo8NSStringCxlF)))));
155
-
156
- // If Foundation hasn't loaded yet, fall back to returning the static string
157
- // "Swift._SwiftObject". The likelihood of someone invoking -description without
158
- // ObjC interop is low.
159
- if (!getDescription) {
160
- return @" Swift._SwiftObject" ;
161
- }
150
+ SWIFT_CC (swift) SWIFT_RUNTIME_STDLIB_INTERFACE
151
+ NSString *swift_stdlib_getDescription(OpaqueValue *value,
152
+ const Metadata *type);
162
153
163
- return [getDescription (value, type) autorelease ];
154
+ NSString *swift::getDescription (OpaqueValue *value, const Metadata *type) {
155
+ auto result = swift_stdlib_getDescription (value, type);
156
+ SWIFT_CC_PLUSZERO_GUARD (type->vw_destroy (value));
157
+ return [result autorelease ];
164
158
}
165
159
166
160
static NSString *_getObjectDescription (SwiftObject *obj) {
You can’t perform that action at this time.
0 commit comments