Commit Graph

2617 Commits

Author SHA1 Message Date
Ben Cohen
3752e6dae4 move _outlinedMakeUniqueBuffer and _arrayReserve into _ArrayBufferProtocol extension 2016-10-25 16:29:48 -07:00
Ben Cohen
6e841e0215 move _forceCreateUniqueMutableBuffer{Impl} into _ArrayBufferProtocol extension 2016-10-25 16:22:10 -07:00
Ben Cohen
b57b5bb222 move _forceCreateUniqueMutableBuffer{Impl} into _ArrayBufferProtocol extension 2016-10-25 16:18:07 -07:00
Joe Shajrawi
103ac620d6 always inline Array's getters and setters 2016-10-25 16:16:00 -07:00
Ben Cohen
e0a31a9a6e move _arrayOutOfPlaceUpdate into _ArrayBufferProtocol extension 2016-10-25 15:14:19 -07:00
Philip Ridgeway
e866fb4eac Fixes error in flatMap documentation comment.
This fixes an error in the example code in the documentation comment for flatMap.
2016-10-25 12:54:59 -07:00
Brian Gesiak
61868b5aec [CMake] Updates for Android NDK r13
Fixes the Android build, and makes some adjustments for Android NDK r13.

* Fix FindICU.cmake to properly set the `SWIFT_${sdk}_ICU_UC` and
  `SWIFT_${sdk}_ICU_I18N` values. These were not properly set because
  "uc" and "i18n" were lowercase.
* Adapt `add_swift_library` to parse `ICU_UC` and `ICU_I18N` for
  private link libraries and use the proper `SWIFT_${sdk}_ICU_*` values.
* NDK r13 removes a subdirectory from the llvm-libc++ includes path.
  Adapt to this change, and add a FIXME to address this issue before it
  may break again.
* Update the documentation to point to a new libicu download for NDK 13.
2016-10-24 15:17:20 -07:00
Slava Pestov
28764374a6 stdlib: Remove workaround for rdar://15520519, resolving ABI FIXME#141 2016-10-24 02:16:21 -07:00
Slava Pestov
af8d13e9d3 stdlib: Make UnicodeDecodingResult fixed-layout 2016-10-24 02:16:20 -07:00
Ada Turner
1c2a17637a Fix typo in Bool.swift
Fix typo in documentation where the "Prints <result>" comment had a parenthesis at the end, probably from coping and pasting out of the code example.
2016-10-19 15:55:12 -06:00
Dave Abrahams
22f5dfa50a Merge pull request #5264 from shajrawi/idasany_perf
improve set's conditional downcast performance by over 2X
2016-10-19 12:13:02 -07:00
Dave Abrahams
76b5afcc4a Speed up Set/Dictionary init from Sequence
Alternative to #5264
2016-10-19 10:23:22 -07:00
swift-ci
cbce7854b8 Merge pull request #5333 from LouisDhauwe/master 2016-10-18 16:18:38 -07:00
Louis D'hauwe
f9cd8b129d Updated popLast() and removeLast() documentation. 2016-10-18 21:29:01 +02:00
Louis D'hauwe
520d0d2e12 Updated popLast() and removeLast() documentation. 2016-10-18 15:59:19 +02:00
Christian Hoffmann
ae7728cc7d Make Bool example compileable 2016-10-18 10:19:05 +02:00
Louis D'hauwe
ad827ccd51 Use code style in documentation for referred functions. 2016-10-18 00:30:42 +02:00
Louis D'hauwe
f1a2f22b17 Improved documentation for removeLast() 2016-10-18 00:21:18 +02:00
Louis D'hauwe
cdbfc4fb45 Improved documentation for popLast() with note about performance versus removeLast() 2016-10-17 23:47:08 +02:00
Nicholas Maccharoli
3d7f8cc1a0 [stdlib] Reorder increment and element creation to not need (#5062) 2016-10-14 14:05:49 -07:00
Nate Cook
c2bc72d9d6 [stdlib] Fix string index sharing (#4896)
* [stdlib] Fix String.UTF16View index sharing

* [stdlib] Fix String.UnicodeScalarView index sharing

* [stdlib] Fix String.CharacterView index sharing

* [stdlib] Test advancing string indices past their ends

* [stdlib] Simplify CharacterView ranged subscript
2016-10-13 10:19:38 -07:00
Doug Gregor
25e00d78d1 [AnyHashable] Eliminate the _AnyHashableProtocol hack.
Now that we have the ability to write extensions where one of the type
parameters is equivalent to a concrete type, eliminate
_AnyHashableProtocol and provide AnyHashable-specific behavior for
Dictionary (where Key == AnyHashable) and Set (where Element ==
AnyHashable) rather than employing the "Key: _AnyHashableProtocol"
hack.

Fixes standard library ABI FIXME's #35, #37, #39.
2016-10-12 18:56:37 -07:00
Joe Shajrawi
eeae7e1f8c improve set's conditional downcast performance by over 2X 2016-10-12 16:27:54 -07:00
swift-ci
37ee4eed55 Merge pull request #5245 from airspeedswift/remove-dummy-void-args 2016-10-11 18:41:04 -07:00
ben-cohen
d34f3ee96d Remove dummy Void args working around fixed typechecker bug – ABI FIXME #26 2016-10-11 17:56:42 -07:00
Andrew Trick
0a448ea74b SE-0138: Minor update. Array.withUnsafeBytes is nonmutating.
The "mutating" keyword should not have been on this API. The example
code in SE-0138 uses it as a nonmutating API.

(The mutating keyword was a temporary workaround that should never
have been carried over to the swift-3.0-branch).

<rdar://28614519> [swift-3.0-branch] Remove "mutating" keyword from Array.withUnsafeBytes
2016-10-11 15:54:16 -07:00
Dave Abrahams
be1f95a65b [stdlib] Simplify expressions
Overload resolution is still slow, so these simple changes make a >10%
difference in compilation time.
2016-10-11 10:07:21 -07:00
Erik Eckstein
0aa023aeda stdlib: Use new built-ins for tail-allocated arrays in ManagedBuffer
... instead of ManagedBufferPointer.
This is what we already did for Array, Set and Dictionary.
The intention is to simplify the generated SIL which is generated for ManagedBuffer operations.
2016-10-07 14:26:13 -07:00
Ben Cohen
a2a3e1d706 numbered FIXME #165: _RangeReplaceableIndexable should be RangeReplaceableCollection 2016-10-05 17:56:15 -07:00
Andrew Trick
d5642f731b Add descriptive doc comments to withMemoryRebound(to:capacity:_:) and… (#5072)
* Add descriptive doc comments to withMemoryRebound(to:capacity:_:) and bindMemory(to:capacity:).

SR-2480: Improve documentation for withMemoryRebound(to:capacity:_:)
rdar://problem/28440528

* Nate's feedback
2016-10-05 12:44:47 -07:00
Slava Pestov
fab574c3a7 stdlib: Add some @_versioned declarations to fix resilient build
A recent change made accessibility checking stricter. This had some
fallout on the half-baked @_versioned attribute, where we could no
longer define @_versioned members on a non-@_versioned type.

This was wrong anyway (and will be diagnosed when we add proper
diagnostics for @_versioned), because type metadata for the
internal type did not get the right linkage, but it used to work
as long as you didn't try to get the type metadata at runtime.

This patch adds @_versioned attributes to the right types now that
this broken behavior is gone.

As a result, _Variant{Set,Dictionary}Storage became resilient
(non-@_versioned internal types are not resilient), which broke
too many tests that assumed you can exhaustively switch over all
the cases. Since eager-bridging is going to eliminate this enum
anyway (or so I've heard), make it @_fixed_layout for now.
2016-09-30 18:28:11 -07:00
Steve (Numerics) Canon
40628dd043 Fix for documentation of the [form]TruncatingRemainder methods.
The result of these methods was incorrectly documented as having
the same sign as `other` (the divisor) rather than `self` (the
dividend). This patch corrects the documentation, and also fixes
the capitalization of `formTruncatingRemainder` in one location.
2016-09-28 12:20:23 -04:00
swift-ci
27eab8ae77 Merge pull request #4982 from moiseev/floating-availability 2016-09-26 11:23:47 -07:00
swift-ci
0ab20e8bb2 Merge pull request #4929 from eliperkins/SR-2627-utf16-access-modifier 2016-09-25 22:11:29 -07:00
swift-ci
bfd8d2040d Merge pull request #5013 from atrick/unsafebytes 2016-09-25 20:54:15 -07:00
Andrew Trick
9c729e4c0c SE-0138: UnsafeRawBufferPointer revision.
The withUnsafeMutableBytes closure argument should not be `inout`.

Improve testing, fix comments.

Addresses DaveA's review.
2016-09-25 19:56:21 -07:00
swift-ci
69925cd54c Merge pull request #5010 from practicalswift/redundant-nil-init 2016-09-25 10:42:55 -07:00
practicalswift
a75ce9b45f [gardening] Remove redundant nil-initialization of optional variables 2016-09-25 18:53:13 +02:00
practicalswift
1110189a29 [gardening] Fix typos. 2016-09-25 18:00:49 +02:00
practicalswift
69b0f622f3 [gardening] Fix inconsistent headers 2016-09-25 18:00:39 +02:00
Max Moiseev
a779f3059d [stdlib] availability attributes for floating point types 2016-09-23 16:42:17 -07:00
Nicholas Maccharoli
cbc3334600 [stdlib] Refactor using switch. (#4948) 2016-09-23 15:35:33 -07:00
Nicholas Maccharoli
731df181eb [stdlib] Refactor logic for .pastEnd index check. (#4957) 2016-09-23 15:33:53 -07:00
Andrew Trick
f70a2e083e SE-0138: Add UnsafeRawBufferPointer and UnsafeMutableRawBufferPointer. (#4954)
https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md

Unsafe[Mutable]RawBufferPointer is a non-owning view over a region of memory as
a Collection of bytes independent of the type of values held in that
memory. Each 8-bit byte in memory is viewed as a `UInt8` value.

Reads and writes on memory via `Unsafe[Mutable]RawBufferPointer` are untyped
operations. Accessing this Collection's bytes does not bind the
underlying memory to `UInt8`. The underlying memory must be bound
to some trivial type whenever it is accessed via a typed operation.

In addition to the `Collection` interface, the following methods from
`Unsafe[Mutable]RawPointer`'s interface to raw memory are
provided with debug mode bounds checks: `load(fromByteOffset:as:)`,
`storeBytes(of:toByteOffset:as:)`, and `copyBytes(from:count:)`.

This is only a view into memory and does not own the memory. Copying a value of
type `UnsafeMutableRawBufferPointer` does not copy the underlying
memory. Assigning an `Unsafe[Mutable]RawBufferPointer` into a value-based
collection, such as `[UInt8]` copies bytes out of memory. Assigning into a
subscript range of UnsafeMutableRawBufferPointer copies into memory.
2016-09-23 11:26:00 -07:00
Eli Perkins
4a6d368f44 Keep value as only available internally 2016-09-22 18:47:56 -04:00
Doug Gregor
312c80af41 Merge pull request #4926 from DougGregor/sr-2648-anyhashable-wrappers
[AnyHashable] Handle comparisons/casting for wrappers around bridged types
2016-09-22 15:44:51 -07:00
Eli Perkins
9009eaf968 Mark UnicodeScalar.utf16 and UnicodeScalar.UTF16View as public
Implements SR-2627
2016-09-22 17:21:51 -04:00
Doug Gregor
6f34118cb6 [AnyHashable] Handle comparisons/casting for wrappers around bridged types.
Swift value types are their bridged Objective-C classes can have
different hash values. To address this, AnyHashable's responds to the
_HasCustomAnyHashableRepresentation protocol, which bridge objects of
those class types---NSString, NSNumber, etc---into their Swift
counterparts. That way, we get consistent (Swift) hashing behavior
across platforms.

However, there are cases where multiple Swift value types map to the
same Objective-C class type. In such cases, AnyHashable ends up
converting the object of class type back to some canonical type. For
example, an NS_STRING_ENUM (such as (NS)RunLoopMode) is a Swift
wrapper around a String. If an (NS)RunLoopMode is placed into an
AnyHashable, it maintains it's Swift type identity (which is correct
behavior). If it is bridged to Objective-C, it becomes an NSString; if
that NSString is placed into an AnyHashable, it produces a String. The
hash values still line up, but equality of the AnyHashable values
fails, which breaks when (for example) a dictionary with AnyHashable
keys is used from Objective-C. See SR-2648 / rdar://problem/27992351
for a case where this breaks interoperability.

To address this problem, make AnyHashable's casting and equality
sensitive to the origin of the hashed value: if the AnyHashable was
created through a _HasCustomAnyHashableRepresentation conformance,
treat comparisons/casting from it as "fuzzy":

* For equality, if one of the AnyHashable's comes from a custom
  representation (e.g., it originated with an Objective-C type like
  NSString) but the other did not, bridge the value of the *other*
  AnyHashable to Objective-C, re-wrap it in an AnyHashable, and
  compare that. This allows, e.g., an (NS)RunLoopMode created in Swift
  to compare to an NSString constant with the same string value.
* For casting, if the AnyHashable we're casting from came from a
  custom representation and the cast would fail, bridge to Objective-C
  and then initiate the cast again. This allows an NSString to be
  casted to (NS)RunLoopMode.

Fixes SR-2648 / rdar://problem/27992351.
2016-09-22 14:16:21 -07:00
Joe Groff
b0e3c0be59 Merge pull request #4865 from jckarter/nsvalue-bridging
SE-0139: NSValue bridging
2016-09-22 09:13:47 -07:00
Sasha Lopoukhine
c3b13bd84c remove repeated "if the" from documentation 2016-09-22 10:44:40 +02:00