Skip to content

Revert "NSNumber bridging: use BOOL rather than _Bool when bridging Bools." #4373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/public/SDK/Foundation/Foundation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ internal func _swift_Foundation_TypePreservingNSNumberWithCGFloat(

@_silgen_name("_swift_Foundation_TypePreservingNSNumberWithBool")
internal func _swift_Foundation_TypePreservingNSNumberWithBool(
_ value: ObjCBool
_ value: Bool
) -> NSNumber

@_silgen_name("_swift_Foundation_TypePreservingNSNumberGetKind")
Expand Down Expand Up @@ -207,7 +207,7 @@ internal func _swift_Foundation_TypePreservingNSNumberGetAsCGFloat(
@_silgen_name("_swift_Foundation_TypePreservingNSNumberGetAsBool")
internal func _swift_Foundation_TypePreservingNSNumberGetAsBool(
_ value: NSNumber
) -> ObjCBool
) -> Bool

// Conversions between NSNumber and various numeric types. The
// conversion to NSNumber is automatic (auto-boxing), while conversion
Expand Down Expand Up @@ -348,7 +348,7 @@ extension Bool: _ObjectiveCBridgeable {

@_semantics("convertToObjectiveC")
public func _bridgeToObjectiveC() -> NSNumber {
return _swift_Foundation_TypePreservingNSNumberWithBool(ObjCBool(self))
return _swift_Foundation_TypePreservingNSNumberWithBool(self)
}

public static func _forceBridgeFromObjectiveC(
Expand Down Expand Up @@ -456,7 +456,7 @@ extension NSNumber : _HasCustomAnyHashableRepresentation {
case .CoreGraphicsCGFloat:
return AnyHashable(_swift_Foundation_TypePreservingNSNumberGetAsCGFloat(self))
case .SwiftBool:
return AnyHashable(_swift_Foundation_TypePreservingNSNumberGetAsBool(self).boolValue)
return AnyHashable(_swift_Foundation_TypePreservingNSNumberGetAsBool(self))
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions stdlib/public/SDK/Foundation/TypePreservingNSNumber.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (const char *)objCType {
case SwiftCGFloat:
return @encode(CGFloat);
case SwiftBool:
return @encode(BOOL);
return @encode(bool);
}
swift::swift_reportError(
/* flags = */ 0,
Expand All @@ -102,7 +102,7 @@ - (void)getValue:(void *)value {
memcpy(value, self->storage, sizeof(CGFloat));
return;
case SwiftBool:
memcpy(value, self->storage, sizeof(BOOL));
memcpy(value, self->storage, sizeof(bool));
return;
}
swift::swift_reportError(
Expand Down Expand Up @@ -139,7 +139,7 @@ - (C_TYPE)METHOD_NAME { \
return result; \
} \
case SwiftBool: { \
BOOL result; \
bool result; \
memcpy(&result, self->storage, sizeof(result)); \
return result; \
} \
Expand All @@ -156,7 +156,6 @@ - (C_TYPE)METHOD_NAME { \
DEFINE_ACCESSOR(unsigned long long, unsignedLongLongValue)
DEFINE_ACCESSOR(float, floatValue)
DEFINE_ACCESSOR(double, doubleValue)
DEFINE_ACCESSOR(BOOL, boolValue)

#undef DEFINE_ACCESSOR

Expand All @@ -179,7 +178,7 @@ - (Class)classForCoder {
DEFINE_INIT(float, Float)
DEFINE_INIT(double, Double)
DEFINE_INIT(CGFloat, CGFloat)
DEFINE_INIT(BOOL, Bool)
DEFINE_INIT(bool, Bool)

#undef DEFINE_INIT

Expand Down Expand Up @@ -213,7 +212,7 @@ - (Class)classForCoder {
DEFINE_GETTER(float, Float)
DEFINE_GETTER(double, Double)
DEFINE_GETTER(CGFloat, CGFloat)
DEFINE_GETTER(BOOL, Bool)
DEFINE_GETTER(bool, Bool)

#undef DEFINE_GETTER

Expand Down
4 changes: 0 additions & 4 deletions validation-test/stdlib/NSNumberBridging.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ NSNumberTests.test("_SwiftTypePreservingNSNumber(${Self}).getValue(_:), objCType
_UnknownArchError()
#endif
% elif Self == 'Bool':
#if ((os(iOS) || os(tvOS)) && (arch(arm64) || arch(x86_64))) || os(watchOS)
expectedObjCType = "B"
#else
expectedObjCType = "c"
#endif
% else:
_UnknownTypeError()
% end
Expand Down