Commit Graph

112 Commits

Author SHA1 Message Date
Dave Abrahams
94965036d5 [stdlib] Move ObjC Mirrors out of Foundation
These mirrors are the default mirrors that get used for all objective-C
object, including some that aren't defined in Foundation:

  import Dispatch
  println(dispatch_get_global_queue(0,0))

This example isn't fixed yet, because we need to pull all the string
bridging goop out of Foundation and into the core standard library.

Swift SVN r25012
2015-02-05 19:18:33 +00:00
Dave Abrahams
97ec182ba7 [stdlib] Move String bridging into Core stdlib
This change allows us to drop an egregious table-of-function-pointers
hack in favor of a much cleaner hack using SwiftShims.  It also allows
us to move the ObjC mirrors out of Foundation in an upcoming commit.

Swift SVN r25011
2015-02-05 19:18:32 +00:00
Dmitri Hrybenko
83f5a45f24 stdlib/runtime: re-enable CrashReporter
Fold the contents of CrashReporterClient.a into the Swift runtime.

rdar://19482263

Swift SVN r24443
2015-01-15 10:13:02 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00
Dmitri Hrybenko
e0c7bb7cec CMake: mark essential stdlib as target library
Swift SVN r23084
2014-11-03 16:58:15 +00:00
Dmitri Hrybenko
e954ac9534 CMake: normalize checks for Apple operating systems
Swift SVN r23056
2014-11-01 04:14:36 +00:00
Dave Abrahams
ce99c04938 [stdlib] mv files NSSwiftXXX => SwiftNativeNSXXX
Swift SVN r22912
2014-10-24 15:48:47 +00:00
Dave Abrahams
393c520fbe [stdlib] Separate source file for shadow protocols
They didn't belong lumped together in the implementation of Dictionary,
where they were.

Swift SVN r22909
2014-10-24 15:48:45 +00:00
Dave Abrahams
981a156823 [stdlib] Add _UnitTestArray[Buffer] temporarily
We're going to replace StdlibUnittest's use of ContiguousArray with
_UnitTestArray so that we can work on (and potentially break)
_ContiguousArray and still get useful test results.  When refactoring is
complete, we can optionally replace StdlibUnittest's use of
_UnitTestArray with ContiguousArray, or move the decoupled component
into the StdlibUnittest module.

Swift SVN r22874
2014-10-22 05:28:22 +00:00
Dave Abrahams
8a27fb8178 [stdlib] Integrate BridgeStorage into the stdlib
We're going to use it for Array internals.  When we do, it should be
expected to cause a performance hit on arrays of value types until
rdar://18125016 is handled.

Swift SVN r22784
2014-10-15 23:32:44 +00:00
Doug Gregor
ef3ff24439 CMake: don't use target_link_libraries on a "target" library.
Fixes regression in the SDK variant build that was introduced by r22527.

Swift SVN r22583
2014-10-07 23:04:34 +00:00
Dave Abrahams
83eec23968 [stdlib] Revert "Gyb ManagedBuffer..."
This reverts r22541.  It turns out that because of the type-punning we
need in order to handle the canonical empty array buffer in Array<Int>
and Array<SomeClass>, calls through methods that could be
dynamically-dispatched (i.e. methods of classes) can't be used to access
an array buffer.  So, for arrays, we need to keep the HeapBuffer
strategy wherein a struct manager object does all the address
calculations.

ManagedBuffer is still a useful tool for users though, and it fills the
role that HeapBuffer was intended to serve for them better than
HeapBuffer itself does, because it is simpler and more type-safe.

Swift SVN r22573
2014-10-07 21:40:43 +00:00
Graham Batty
a7a032d4a6 Temporarily undo no-whole-archive change.
This change breaks things and will probably continue breaking them
until the standard library and code generation is more functional
on linux.

Leaving in a TODO to turn it back on later.

Swift SVN r22572
2014-10-07 21:26:25 +00:00
Dave Abrahams
01f6f811b5 [stdlib] Gyb ManagedBuffer for Array storage
Swift SVN r22541
2014-10-06 18:40:04 +00:00
Graham Batty
22c7a7569f Don't do foundations or objc linking on linux.
Swift SVN r22527
2014-10-05 20:10:57 +00:00
Dave Abrahams
43deddf8ac [stdlib] Move ManagedBuffer prototype into stdlib
...in preparation to use it in _[Contiguous]ArrayBuffer

Swift SVN r22440
2014-10-01 21:12:43 +00:00
Devin Coughlin
9c7d27c4eb Add an OS version check for API availability to standard library and runtime.
This patch adds a compiler entry point to the standard library that checks
whether the running OS version is greater than or equal to a given version
triple. The idea is that #os(...) will get SILGen'd into a call to this
function.

The standard library function calls a runtime function to actually get the OS
version. This runtime function uses -[NSProcessInfo operatingSystemVersion] when
possible, otherwise it loads the SystemVersion plist. When running under the
simulator, we use an environmental variable set by the simulator to look up the
version for the simulated OS and not the host OS.

At the moment, there is no caching for version info. I will add this in a later
patch.


Swift SVN r22303
2014-09-26 18:26:29 +00:00
Doug Gregor
a54452f34c De-Gyb Assert.swift.gyb
Swift SVN r22140
2014-09-19 18:01:12 +00:00
Dave Abrahams
1e9e7734f0 Revert "[stdlib] any/all algorithms, keyword for contains"
This reverts r21810 and r21811 due to lack of design consensus

Swift SVN r21880
2014-09-11 17:42:32 +00:00
Dave Abrahams
c467825bc2 [stdlib] any/all algorithms, keyword for contains
Expose any, all on Array and all the Lazy sequence adapters.  Make the
'contains' algorithm that takes a predecate unavailable in favor of
'any', which does the same thing.

Fixes <rdar://problem/18190149> [algorithm] `contains` syntax is ambiguous

Swift SVN r21810
2014-09-09 20:39:39 +00:00
Dmitri Hrybenko
44bf1a81a6 stdlib/Printing: print floating point numbers with appropriate precesion for
the type

Printing Float32 with %0.15g not only wastes screen space, but also causes
confusion for users, and pretends that a Float32 has more precision than it
actually does.

rdar://18043123


Swift SVN r21435
2014-08-25 13:56:38 +00:00
Mikhail Zolotukhin
4027d140d1 stdlib: Replace quicksort with introsort.
Also, unite predicated and unpredicated versions of all functions via
GYB.

Swift SVN r21280
2014-08-19 13:41:04 +00:00
Doug Gregor
0fc92aabe1 Remove empty Nil.swift from the standard library
Swift SVN r21190
2014-08-14 00:38:46 +00:00
Dmitri Hrybenko
3a04e0809f stdlib: add a function to squeeze a number in a given range from a hash value
This function mixes the bits in the hash value, which improves Dictionary
performance for keys with bad hashes.

PrecommitBenchmark changes with greater than 7% difference:

``````````Dictionary2`,```1456.00`,```1508.00`,```1502.00`,````624.00`,````607.00`,````592.00`,`864.00`,``145.9%
``````````Dictionary3`,```1379.00`,```1439.00`,```1408.00`,````585.00`,````567.00`,````552.00`,`827.00`,``149.8%
````````````Histogram`,````850.00`,````849.00`,````851.00`,```1053.00`,```1049.00`,```1048.00`,`199.00`,``-19.0%
````````````````Prims`,```1999.00`,```2005.00`,```2018.00`,```1734.00`,```1689.00`,```1701.00`,`310.00`,```18.4%
``````````StrSplitter`,```2365.00`,```2334.00`,```2316.00`,```1979.00`,```1997.00`,```2000.00`,`337.00`,```17.0%
```````````````TwoSum`,```1551.00`,```1568.00`,```1556.00`,```1771.00`,```1741.00`,```1716.00`,`165.00`,```-9.6%

Regressions are in benchmarks that use `Int` as dictionary key: we are just
doing more work than previously (hashing an `Int` was an identity function).

rdar://17962402


Swift SVN r21142
2014-08-12 12:02:26 +00:00
Nadav Rotem
e67c274cbe Convert the toString overloads to GYB.
Swift SVN r21053
2014-08-05 23:48:43 +00:00
Enrico Granata
a472b40551 Add Mirror conformances for StrideTo and StrideThrough. These are mostly there to embellish the labels for child elements, as the default struct Mirror is doing a good enough job on its own. Fixes rdar://17876067
Swift SVN r21023
2014-08-04 19:07:33 +00:00
Dave Abrahams
9bec796c94 [stdlib] Lazy and eager concatenate
Swift SVN r20978
2014-08-03 21:34:28 +00:00
Dmitri Hrybenko
142a32a944 stdlib/Assert: allow string interpolation in assertion messages
rdar://17248446


Swift SVN r20892
2014-08-01 13:44:38 +00:00
Dave Abrahams
104da6740b [stdlib] Make && and || generic
...instead of using Existentials, which don't specialize well.

Swift SVN r20837
2014-07-31 18:22:56 +00:00
Dave Abrahams
bd2bd78b23 [stdlib] Add RangeReplaceableCollectionType
Swift SVN r20791
2014-07-31 00:38:24 +00:00
Dmitri Hrybenko
ac0d9b8175 stdlib/CGFloat: GYB'ify initializers that convert between CGFloat and
integer types.  Never miss an integer type again.

rdar://17853313

Swift SVN r20751
2014-07-30 11:24:11 +00:00
Dave Abrahams
a8225dabee [stdlib] ArrayBridge.swift => ArrayCast.swift
This file is really about array casting, and not (necessarily) bridging.
Bridging may be involved in some array casts, but is not involved in all
of them.

Swift SVN r20690
2014-07-29 20:58:54 +00:00
Dave Abrahams
6d1f574089 [stdlib] Separate file for Array bridging/casting
This stuff will require a nice big comment and will go through several
rounds of cleanup; let's get it out of the regular Array flow.

Swift SVN r20642
2014-07-28 20:34:08 +00:00
Dave Abrahams
e3f8d0e630 [stdlib] rename UnsafeArray => UnsafeBufferPointer
Also,

  UnsafeMutableArray => UnsafeMutableBufferPointer
  withUnsafeMutableStorage => withUnsafeMutableBufferPointer

Swift SVN r20340
2014-07-22 22:20:37 +00:00
Doug Gregor
71cd9245ba Rename swift_stdlib_core -> swiftCore and swift_runtime -> swiftRuntime.
We can't use underscores in plists, so just makes the names consistent
<rdar://problem/17652418>.

Swift SVN r19954
2014-07-14 22:19:03 +00:00
Dave Abrahams
cb050eee52 [stdlib] Add Interval support
This allows 0.0..<10.3 and 0.1...4.4 to work properly in pattern
matching.

Fixes <rdar://problem/12016900> (#Seed 4: add a "contains" method to the
range types) by making "contains" available on Interval

Addresses <rdar://problem/16254937> (#Seed 4: Ranges with negative
strides are broken) by making the formation of an invalid Interval a
runtime error.

Fixes <rdar://problem/16304317> (Range<T> has limited awesomeness: it is
restricted to types that conform to ForwardIndex)

Fixes <rdar://problem/16736924> (#Seed 4: Enable range inclusion pattern
matching for all types that conform to Equatable and Comparable)

Addresses <rdar://problem/16846325> (#Seed 4: Introduce index range) by
distinguishing Range (which operates on indices) from Interval

Fixes <rdar://problem/17051263> (Pattern-matching a Double range with an
infinite endpoint triggers an assertion failure)

Fixes <rdar://problem/17051271> (#Seed 4: Pattern-matching Double ranges
excludes fractional values)

Addresses <rdar://problem/17171420> (Separate types for closed and
half-open ranges)

Swift SVN r19900
2014-07-13 18:49:36 +00:00
Dave Abrahams
eb1a5cfac4 [stdlib] Add Strideable protocol
And make RandomAccessIndex refine it.

* had to XFAIL
  test/Prototypes/TextFormatting.swift (<rdar://problem/17619178>)

* Had to compromise on the name of Strideable's associated
  type (<rdar://problem/17619038>)

Swift SVN r19785
2014-07-10 05:39:13 +00:00
Dave Abrahams
9918145209 [stdlib] Drop RandomAccessRange
It won't be needed in the new Range plan after all

Swift SVN r19770
2014-07-10 01:20:56 +00:00
Enrico Granata
e73b3120c0 EmptyCollection and CollectionOfOne are similar enough that they can be reflected together. I am a little unhappy with having the summary be a string argument instead of inlined, but I couldn't come up with a quick solution to do otherwise, and it didn't seem worth spending a lot of time dwelling upon that
Swift SVN r19668
2014-07-08 01:30:31 +00:00
Enrico Granata
64bb537f55 Implement Mirrors for the UTF8/16 view on Swift Strings
Swift SVN r19651
2014-07-07 23:36:00 +00:00
Enrico Granata
b0548f13cd Start using the Mirror Generator
This commit removes Mirrors for RangeGenerators, since Dave and I discussed that these won't be necessary in practice
Also, it removes the Mirrors for Range types from Range.swift.gyb, and instead adds a new RangeMirrors.swift.gyb used to generate range types Mirrors



Swift SVN r19543
2014-07-03 23:43:14 +00:00
Dave Abrahams
312c55a308 [stdlib] Range WIP 1: create RandomAccessRange
Using ..< and ... on RandomAccessIndex endpoints now produces a distinct
RandomAccessRange type that can have zero-based indexing, validation at
creation, efficient strides (the other Range should probably lose its
stride capability), and all kinds of other goodness.  This is the first
step in solving our cluster of outstanding Range-related issues.

Swift SVN r19497
2014-07-03 00:59:48 +00:00
Doug Gregor
a5bde4e3a4 CMake: Add COMPILE_FLAGS support for add_swift_library.
COMPILE_FLAGS is currently used for two purposes:
  - For any target library, add the appropriate Swift optimization flags. This eliminates the add_swift_optimization_flags boilerplate and makes these flags work for all library variants
  - For the runtime, pass the appropriate define down when SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS is set, so that all library variants get this setting.

Swift SVN r19444
2014-07-02 00:37:48 +00:00
Doug Gregor
315575e14f CMake: Add LINK_FLAGS option for add_swift_library
Swift SVN r19417
2014-07-01 17:11:38 +00:00
Doug Gregor
d95b9fad69 CMake: Skeletal infrastructure for building multiple variants of Swift libraries (for iOS, iOS simulator, etc.).
This is behind a flag because it doesn’t work yet. However, we’re starting to see semi-sensible command lines coming out of it.

Swift SVN r19404
2014-07-01 17:11:32 +00:00
Dave Abrahams
52c01c9ee4 [stdlib] Give filter() the lazy() treatment
Swift SVN r19359
2014-06-30 19:32:34 +00:00
Dmitri Hrybenko
4814e00fda stdlib/String: implement Unicode extended grapheme cluster segmentation
algorithm

The implementation uses a specialized trie that has not been tuned to the table
data.  I tried guessing parameter values that should work well, but did not do
any performance measurements.

There is no efficient way to initialize arrays with static data in Swift.  The
required tables are being generated as C++ code in the runtime library.

rdar://16013860


Swift SVN r19340
2014-06-30 14:38:53 +00:00
Dave Abrahams
6b0d2f92f0 [stdlib] Give reverse() the lazy() treatment
This one shows the unfortunate consequence that we need
Lazy[Forward|Bidirectional|RandomAccess]Collection.  There's gonna be a
whole lotta gyb'bing going on...

Swift SVN r19316
2014-06-28 01:35:34 +00:00
Dave Abrahams
a7f6b97222 [stdlib] Introduce lazy() and use it for mapping
Swift SVN r19312
2014-06-28 00:35:43 +00:00