Skip to content

5.1 Syntax Updates (NFCI) #2435

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 2 commits into from
Aug 17, 2019
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
6 changes: 3 additions & 3 deletions Foundation/CGFloat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

@_fixed_layout
@frozen
public struct CGFloat {
#if arch(i386) || arch(arm)
/// The native type used to store the CGFloat, which is Float on
Expand Down Expand Up @@ -777,12 +777,12 @@ public func tgamma(_ x: CGFloat) -> CGFloat {

@_transparent
public func nearbyint(_ x: CGFloat) -> CGFloat {
return CGFloat(nearbyint(x.native))
return CGFloat(x.native.rounded(.toNearestOrEven))
}

@_transparent
public func rint(_ x: CGFloat) -> CGFloat {
return CGFloat(rint(x.native))
return CGFloat(x.native.rounded(.toNearestOrEven))
}

@_transparent
Expand Down
11 changes: 5 additions & 6 deletions Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ internal class __NSSwiftData : NSData {
#endif
}

@_fixed_layout
@frozen
public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessCollection, MutableCollection, RangeReplaceableCollection, MutableDataProtocol, ContiguousBytes {
public typealias ReferenceType = NSData

Expand All @@ -651,7 +651,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
// A small inline buffer of bytes suitable for stack-allocation of small data.
// Inlinability strategy: everything here should be inlined for direct operation on the stack wherever possible.
@usableFromInline
@_fixed_layout
@frozen
internal struct InlineData {
#if arch(x86_64) || arch(arm64) || arch(s390x) || arch(powerpc64) || arch(powerpc64le)
@usableFromInline typealias Buffer = (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8,
Expand Down Expand Up @@ -872,7 +872,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
// A buffer of bytes too large to fit in an InlineData, but still small enough to fit a storage pointer + range in two words.
// Inlinability strategy: everything here should be easily inlinable as large _DataStorage methods should not inline into here.
@usableFromInline
@_fixed_layout
@frozen
internal struct InlineSlice {
// ***WARNING***
// These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last
Expand Down Expand Up @@ -1090,7 +1090,6 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
// A reference wrapper around a Range<Int> for when the range of a data buffer is too large to whole in a single word.
// Inlinability strategy: everything should be inlinable as trivial.
@usableFromInline
@_fixed_layout
internal final class RangeReference {
@usableFromInline var range: Range<Int>

Expand Down Expand Up @@ -1118,7 +1117,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
// A buffer of bytes whose range is too large to fit in a signle word. Used alongside a RangeReference to make it fit into _Representation's two-word size.
// Inlinability strategy: everything here should be easily inlinable as large _DataStorage methods should not inline into here.
@usableFromInline
@_fixed_layout
@frozen
internal struct LargeSlice {
// ***WARNING***
// These ivars are specifically laid out so that they cause the enum _Representation to be 16 bytes on 64 bit platforms. This means we _MUST_ have the class type thing last
Expand Down Expand Up @@ -1294,7 +1293,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
// The actual storage for Data's various representations.
// Inlinability strategy: almost everything should be inlinable as forwarding the underlying implementations. (Inlining can also help avoid retain-release traffic around pulling values out of enums.)
@usableFromInline
@_frozen
@frozen
internal enum _Representation {
case empty
case inline(InlineData)
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSSwiftRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import WinSDK
/// On 64-bit iOS, the Objective-C BOOL type is a typedef of C/C++
/// bool. Elsewhere, it is "signed char". The Clang importer imports it as
/// ObjCBool.
@_fixed_layout
@frozen
public struct ObjCBool : ExpressibleByBooleanLiteral {
#if os(macOS) || (os(iOS) && (arch(i386) || arch(arm)))
// On macOS and 32-bit iOS, Objective-C's BOOL type is a "signed char".
Expand Down