Commit Graph

111 Commits

Author SHA1 Message Date
JP Simard
7301b79342 remove superfluous parentheses in control statements in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:40:15 -08:00
JP Simard
ea5b665afa prefer '-> Void' over '-> ()'
Apple and the Swift community has settled on this style:
https://devforums.apple.com/message/1133616#1133616

> FWIW, we've recently decided to standardize on () -> Void
> (generally, () for parameters and Void for return types) across all of our
> documentation.
2016-12-31 17:55:19 -08:00
JP Simard
bd34ea5e2d remove trailing semicolons in stdlib source 2016-12-31 17:51:18 -08:00
Philippe Hausler
b57752a67f [Foundation] Correct case of over-released data contents when specifying .none as a deallocator 2016-12-19 14:37:24 -08:00
practicalswift
16d6dce62e [gardening] Fix recently introduced typos. 2016-12-16 21:42:09 +01:00
Slava Pestov
30c81e862f Foundation overlay: Fix resilient build 2016-12-12 14:05:50 -08:00
Philippe Hausler
e8b19d9924 Merge pull request #6098 from phausler/additional_data_refinements
Merge the swift-corelibs-foundation version of Data
2016-12-06 15:16:51 -08:00
practicalswift
3e31a3ade4 [gardening] Fix typos. 2016-12-06 21:42:01 +01:00
Philippe Hausler
6134083d31 Merge the swift-corelibs-foundation version of Data in as a single source and correct initializers for copy variants as well as remove defers of _fixLifetime 2016-12-06 10:12:55 -08:00
Philippe Hausler
e27b2b0923 Account for nullability issues of bytes in NSData subclasses and return a placeholder value for now 2016-12-01 15:34:04 -08:00
Philippe Hausler
bdafb2dac0 Handle no-copy cases and custom deallocators as inline construction of swift Data 2016-12-01 12:27:57 -08:00
Philippe Hausler
9c0951b5b2 First draft at a new inlinable version of struct Data 2016-11-29 10:53:44 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Slava Pestov
2b1bfe3270 Foundation overlay: Don't rely on URL struct being a single reference
If the struct is resilient, it is passed indirectly. Even if we decide to
make it fixed layout, it's best to remove as many implicit ABI assumptions
as possible from @_silgen_name function calls.

Fixes <rdar://problem/28673618>.
2016-10-17 18:10:37 -07:00
practicalswift
2ee3c45b5b Merge pull request #4852 from practicalswift/optionals-set-to-nil
[gardening] Remove redundant nil-initialization of optional variables
2016-09-19 11:14:31 +02:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
75fb1747d1 Foundation: change Data.Indices to be a CountableRange<Int>, that is much faster than the default 2016-09-18 03:57:07 +03:00
Dmitri Gribenko
573ed96ba2 Set Foundation.Data.SubSequence to be RangeReplaceable
RangeReplaceableCollection.SubSequence should be a
RangeReplaceableCollection.  Data implements RangeReplaceableCollection,
but sets SubSequence to MutableRandomAccessSlice that is not a
RangeReplaceableCollection.

This commit changes Foundation.Data.SubSequence to
MutableRangeReplaceableRandomAccessSlice.

Fixes rdar://problem/28330713.
2016-09-18 03:57:07 +03:00
practicalswift
710d8416f1 [gardening] Fix minor spacing issue in Data.swift 2016-09-17 13:28:34 +02:00
practicalswift
3a4ee89034 [gardening] Use consistent formatting. 2016-09-17 12:12:49 +02:00
practicalswift
89276cc07e [gardening] Replace "a NSFoo" with "an NSFoo". 2016-09-16 21:49:18 +02:00
Dave Abrahams
5c13e35f29 [stdlib] Suppress noisy warnings
We don't have a way yet to say "this is deprecated for users, but let
the stdlib use it without complaining" so we need to do refactoring
shenanigans.
2016-08-28 15:06:42 -07:00
Xiaodi Wu
f9435b9ce8 [stdlib] Restore MemoryLayout.*(ofValue:) 2016-08-08 10:46:37 -05:00
Michael Ilseman
045bc16b6d Merge pull request #4031 from milseman/noescape_by_default
noescape by default: deprecate @noescape and @autoclosure(escaping)
2016-08-05 13:25:00 -07:00
Michael Ilseman
b7c9eddd11 [noescape by default] drop @noescape from stdlib 2016-08-04 16:09:01 -07:00
Philippe Hausler
956c310975 [Foundation] add hints for replacement APIs for Data of some common usage from NSData
This provides a hint to the proper API to use for struct Data when developers are migrating from NSData.
Purely a fixit addition (no actual functional code)

<rdar://problem/26206061> Missing fixit for Data.getBytes
2016-08-03 16:36:06 -07:00
Dmitri Gribenko
382d215ad3 stdlib: SE-0101: remove the last few uses of old APIs (sizeof, alignof, strideof) 2016-07-30 00:38:18 -07:00
Doug Gregor
b9363fe6bd [SE-0111] Enable SE-0111 by default. 2016-07-29 17:28:24 -07:00
Rintaro Ishizaki
091506315b [SE-0101] Implement: Reconfiguring sizeof and related functions into MemoryLayout struct
As of now:

* old APIs are just marked as `deprecated` not `unavaiable`. To make it
  easier to co-operate with other toolchain repos.
* Value variant of API is implemented as public @private
  `_ofInstance(_:)`.
2016-07-30 03:09:28 +09:00
Dmitri Gribenko
e5db796212 Merge pull request #3843 from atrick/rawptr-convert
Remove "illegal" UnsafePointer casts from the stdlib.
2016-07-28 22:40:16 -07:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Kevin Ballard
a021c89236 Implement a custom Data.Iterator
This iterator uses an inline 32-byte buffer so it doesn't have to call
copyBytes(to:count:) for every single byte. It results in an approximate
6x speedup on my computer.
2016-07-28 18:45:40 -07:00
Ted Kremenek
4a872ed636 Revert "Implement a custom Data.Iterator" (#3848) 2016-07-28 18:33:31 -07:00
Dmitri Gribenko
69255f02cb Merge pull request #3831 from kballard/data_iterator
Implement a custom Data.Iterator
2016-07-28 18:11:16 -07:00
Kevin Ballard
69c3d71ba3 Implement a custom Data.Iterator
This iterator uses an inline 32-byte buffer so it doesn't have to call
copyBytes(to:count:) for every single byte. It results in an approximate
6x speedup on my computer.
2016-07-28 13:27:31 -07:00
Tony Parker
ef99d39d3b Adapt to UnsafeRawPointer changes in Data initializer and deallocator API 2016-07-28 13:21:50 -07:00
Joe Groff
4b9e49827d Make all _toAnyHashable() implements @nonobjc. 2016-07-27 09:25:30 -07:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
David Farler
4a57e647e6 Merge pull request #3762 from bitjammer/se-0081-diagnostic-and-crashes
[SE-0081] Warn on deprecated where clause inside angle brackets
2016-07-26 09:09:30 -07:00
Dmitri Gribenko
34f6eb1438 Foundation: add custom AnyHashable representations to new value types 2016-07-26 03:10:52 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
David Farler
7bfaeb57f1 [SE-0081] Warn on deprecated where clause inside angle brackets
and provide a fix-it to move it to the new location as referenced
in SE-0081.

Fix up a few stray places in the standard library that is still using
the old syntax.

Update any ./test files that aren't expecting the new warning/fix-it
in -verify mode.

While investigating what I thought was a new crash due to this new
diagnostic, I discovered two sources of quite a few compiler crashers
related to unterminated generic parameter lists, where the right
angle bracket source location was getting unconditionally set to
the current token, even though it wasn't actually a '>'.
2016-07-26 01:41:10 -07:00
swift-ci
3cfcb55bfc Merge pull request #3752 from parkera/foundation_reflection 2016-07-25 22:29:48 -07:00
Jordan Rose
0712ffcb07 Convert the Dispatch and Foundation overlays to 'fileprivate'. (#3753)
Similar to the work in apple/swift-corelibs-foundation#445.

Groundwork for SE-0025 ('private' and 'fileprivate').
No intended functionality change.
2016-07-25 20:58:06 -07:00
Tony Parker
dab81e8674 Add CustomReflectable implementation to most Foundation value types.
Also improves the basic debugDescription and description methods.

rdar://26580762
2016-07-25 17:05:51 -07:00
Joe Groff
32b50c624d stdlib: Remove _isBridgedToObjectiveC from _ObjectiveCBridgeable.
All generic bridgeable types can bridge for all their instantiations now. Removing this ferrets out some now-unnecessary traps that check for unbridgeable parameter types.
2016-07-25 06:01:21 -07:00
Joe Groff
95e462022d Update Foundation overlay for id-as-Any. 2016-07-25 06:01:21 -07:00
Kevin Perry
2cd5426a2e Use alternate implementation of Data.write() on macOS and iOS versions where the provided implementation would crash
rdar://26278731
2016-07-21 12:07:00 -07:00
Doug Gregor
ab3a15c87a [SE-0091 / Foundation overlay] Move operators into types.
Foundation provides a number of specific operators defined in the
global scope. Push all of these into their corresponding types. This
cleanup helps verify that the SE-0091 implementation is generally
functional.
2016-07-18 23:18:57 -07:00