Commit Graph

1309 Commits

Author SHA1 Message Date
Dmitri Hrybenko
3f2006a00b stdlib/UnicodeTrie: add more comments, replace a _precondition()/#if
pair with _sanityCheck

Swift SVN r19395
2014-07-01 13:18:20 +00:00
Dmitri Hrybenko
27abfcb271 stdlib/String: add a performance FIXME
Swift SVN r19394
2014-07-01 13:18:18 +00:00
Dmitri Hrybenko
124eb2ae83 stdlib: reword trap messages in response to review from Dave
Swift SVN r19393
2014-07-01 13:18:16 +00:00
Enrico Granata
f59f6abc4e The bot is unhappy that these are not marked @public, so mark them @public
Swift SVN r19388
2014-07-01 01:47:13 +00:00
Enrico Granata
9abfdb372e Add a Mirror for UnsafePointer
The one design choice here was whether to expose the pointee directly through the Mirror

My choice was against that. Instead, we present UnsafePointer as UnsafePointer(0x123) and the child we expose is the 0x123 numeric pointer value

The other option, of course, would be to present it as UnsafePointer(reflect(memory)) - but that seems risky to do by default
UnsafePointers are allowed to be in, guess what, unsafe states, and the stakes of having playgrounds try and dereference at all times are quite too high.

If the user really wants to reflect the pointee reflect(pointer.memory) will do it for them - and then any crashes will be theirs to enjoy.

Of course, I am very open to arguments as to why reflect(memory) would be a better choice.



Swift SVN r19386
2014-07-01 00:54:52 +00:00
Jordan Rose
748efed913 [Accessibility] Protocol witnesses must be as accessible as the protocol.
...unless the type has less accessibility than the protocol, in which case
they must be as accessible as the type.

This restriction applies even with access control checking disabled, but
shouldn't affect any decls not already marked with access control modifiers.

Swift SVN r19382
2014-06-30 23:38:35 +00:00
Dave Abrahams
8e7d45f2c0 [stdlib] Normalize .gyb files
- Follow LLVM conventions for emacs mode specification

- Use local variables suffix to make the output read-only (at least on
  Emacs)

- But drop the admonitions not to edit the generated files;
  line-directive mostly takes care of that problem now.

Swift SVN r19381
2014-06-30 23:24:17 +00:00
Enrico Granata
0f706ba86c Add a Mirror for EmptyCollection. Oh, and test cases too.
Swift SVN r19380
2014-06-30 23:21:08 +00:00
Dave Abrahams
e38c32742b [stdlib] Dictionary: fix 80-column/endline violations
Swift SVN r19375
2014-06-30 22:12:16 +00:00
Dave Abrahams
c703a76cdc [stdlib] Add missing precondition check
Fixes <rdar://problem/17392712> UnsafeArray.init() should _precondition(length >= 0)

Swift SVN r19373
2014-06-30 21:59:42 +00:00
Dave Abrahams
c04aae5dce [stdlib] Add some missing mode lines for gyb files
Swift SVN r19372
2014-06-30 21:55:30 +00:00
Dave Abrahams
9825954746 [stdlib] That's not a doc comment!
Fixes <rdar://problem/17028678> comments for sort() don't make sense in
the synthesized header.  Putting the right comments in there is
<rdar://problem/17511801> Algorithm.swift needs doc comments

Swift SVN r19370
2014-06-30 21:46:19 +00:00
Enrico Granata
fcebadb355 Bit needs a Mirror too. It would be nice if we had automagical reflection for C-style enums, then this would just work OOTB
Swift SVN r19369
2014-06-30 21:16:50 +00:00
Dave Abrahams
127a3e59d2 [stdlib] give filter() the eager treatment, too
Swift SVN r19368
2014-06-30 20:56:11 +00:00
Nadav Rotem
715565e4ea Rename a member function
Swift SVN r19364
2014-06-30 20:16:26 +00:00
Enrico Granata
676547c5f7 Add Mirror support for CollectionOfOne
Swift SVN r19363
2014-06-30 20:14:31 +00:00
Dave Abrahams
52c01c9ee4 [stdlib] Give filter() the lazy() treatment
Swift SVN r19359
2014-06-30 19:32:34 +00:00
Joe Groff
e99fc08a36 stdlib: Add a _convertConstStringToUTF8PointerArgument entry point to assist string-to-pointer conversion.
Swift SVN r19358
2014-06-30 19:32:03 +00:00
Jordan Rose
5e59d30c6f Update stdlib for memberwise access control.
As before, there may be more things marked @public than we actually want
public. Judicious use of the frontend option -disable-access-control may
help reduce the public surface area of the stdlib.

Swift SVN r19353
2014-06-30 18:50:50 +00:00
Jordan Rose
8c1fcfa055 Make some more stdlib things public.
Swift SVN r19351
2014-06-30 18:50:46 +00:00
Dmitri Hrybenko
68c7a45c9b stdlib/printing: change Optional<T> representation in print to be Optional(...)
Because we are adding text to show internal representation, change the
conformance from Printable to DebugPrintable.

rdar://16950055


Swift SVN r19341
2014-06-30 15:23:51 +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
Dmitri Hrybenko
50a5b303a1 stdlib/String.UnicodeScalarView: rename _base to _core
NFC; improves readability of future commits.

Swift SVN r19337
2014-06-30 12:02:36 +00:00
Dmitri Hrybenko
450c21f4ec stdlib/String.UnicodeScalarView: fix out-of-bounds read of the
underlying NSString when it ends in a high-surrogate code unit

The tests did not catch this because they were creating CFString, which,
as it turns out, does not perform bounds checking.  Replaced the use of
CFString with a custom NSString subclass.

Swift SVN r19329
2014-06-30 11:54:51 +00:00
Chris Lattner
68be2902c2 remove some operator definitions that aren't implemented anywhere. We should add these
back when/if they are added to the stdlib.


Swift SVN r19326
2014-06-29 00:46:32 +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
ab322aead3 [stdlib] Introduce/use a free array-yeilding map()
Some of the lazy() instances in the previous commit that were being
immediately array'd are now even simpler.

Swift SVN r19313
2014-06-28 00:35:43 +00:00
Dave Abrahams
a7f6b97222 [stdlib] Introduce lazy() and use it for mapping
Swift SVN r19312
2014-06-28 00:35:43 +00:00
Dave Abrahams
e18d8b02ba [stdlib] filter(x) never creates a Collection
It's both more rigorously correct and should prevent surprise when
constructing an Array from a filtered sequence.  See the comments
in-code for details.

Swift SVN r19304
2014-06-27 19:44:46 +00:00
Joe Groff
bf102f8ca4 IRGen: Fix extended method encoding for protocol members that take a single-parameter block parameter.
We were falling back to void(^)() encoding for block types whose input type was not a tuple.

Swift SVN r19299
2014-06-27 18:13:17 +00:00
Joe Groff
47fde864e9 Remove UnsafePointer.withUnsafePointer.
This is no longer necessary for API parity with CMutablePointer now that pointer conversions are in.

Swift SVN r19296
2014-06-27 16:54:51 +00:00
Joe Groff
39dbb30b57 Remove staging typealiases from the stdlib.
Swift SVN r19287
2014-06-27 02:48:38 +00:00
Doug Gregor
f0159f40a1 Ban the "new" syntax for creating an array <rdar://problem/16951969>.
We haven't been advertising this syntax much, and it's closure form
was completely broken anyway, so don't jump through hoops to provide
great Fix-Its here. 


Swift SVN r19277
2014-06-26 23:51:47 +00:00
Joe Groff
e47a4e2e5a Missed a #if. Unbreak the build for people who don't have -DENABLE_POINTER_CONVERSIONS set.
Swift SVN r19276
2014-06-26 23:49:03 +00:00
Joe Groff
cb48fbd24b Enable pointer conversions.
Swift SVN r19274
2014-06-26 23:26:31 +00:00
Joe Groff
d064fd7307 stdlib: Disable AutoreleasingUnsafePointer's inout conversion when building with intrinsic pointer conversions.
Swift SVN r19269
2014-06-26 22:37:26 +00:00
Joe Groff
7717b30d99 stdlib: Add a default initializer for AutoreleasingUnsafePointer.
Swift SVN r19268
2014-06-26 22:37:26 +00:00
Doug Gregor
bea1d3d9b3 Use dictionary type sugar in the standard library.
Swift SVN r19264
2014-06-26 22:26:58 +00:00
Chris Lattner
4ac0f31852 add an 'overflow' label to the second result of the "withoverflow" aritmetic operations,
as suggested by Dmitri



Swift SVN r19251
2014-06-26 21:00:32 +00:00
Chris Lattner
4dcd6cf4d1 implement <rdar://problem/17101613> standard library should provide a way to test for overflow
This just renames the existing "uncheckedAdd" (and related) functions to addWithOverflow.  These
were already "checked" and return the partial result + bool that we want.


Swift SVN r19246
2014-06-26 20:33:17 +00:00
Dave Abrahams
c1539b3e5d [stdlib] Put the "unsafe" in withUnsafeMutableStorage
This API exposes unmediated access to memory, and most users will never
see the UnsafeArray argument that's passed to the closure, so best to be
explicit.

Swift SVN r19243
2014-06-26 18:22:54 +00:00
Dmitri Hrybenko
108ab1a83e stdlib/Unicode: restore the comment that explains why the function is
@noinline; it might be useful for someone reading the code


Swift SVN r19233
2014-06-26 14:07:20 +00:00
Dmitri Hrybenko
0e8d76f13b stdlib/Unicode: add @noinline to a large error handling function
Swift SVN r19232
2014-06-26 14:04:37 +00:00
Dmitri Hrybenko
4671211ce3 stdlib/String: fix two bugs in UnicodeScalarView
If underlying NSString contained isolated surrogates, then we were crashing in
following ways:

- subscripting by index could crash;

- index pointing to the second code unit sequence was not moved backwards
  correctly.  Instead of moving it to pointing to the beginning of the view it
  could be moved to point to the code unit before the beginning of the view.



Swift SVN r19230
2014-06-26 13:47:00 +00:00
Dmitri Hrybenko
990960850f stdlib, tests: fix some more 'predecessor' names that should have been
changed to 'predicate' instead


Swift SVN r19229
2014-06-26 09:13:02 +00:00
Dave Abrahams
1fb11d623b [stdlib] Remove _buffer requirement from ArrayType
Until we get an optimizer pass to remove get/set pairs, passing a
property that is a protocol requirement as inout from generic code is
always going to cause an extra retain, causing many unintended Array
copies.

Because this dropped reference counts to 1 in some cases, it exercised
previously-untested code paths and uncovered bugs, particularly in the
handling of subrange replacement on Slice<T>.

There are still differences in speed for short arrays of CGPoint that bear
investigation, but at least as things scale up, the ratio of time goes
to 1.

Fixes <rdar://problem/17040913> append and += on an array have
completely different performance

Swift SVN r19228
2014-06-26 08:54:07 +00:00
Dave Abrahams
321d608935 [stdlib] 80-column / endline layout fix
Swift SVN r19227
2014-06-26 08:53:50 +00:00
Joe Groff
687e1c5174 stdlib: Migrate some stdlib convenience APIs to UnsafePointer.
Give UnsafePointer versions of CMutablePointer._setIfNonNil and _withBridgeObject/Value. Also provide a version of 'withUnsafePointer' as a staging aid so that UnsafePointer can be used in place of CMutablePointer.

Swift SVN r19215
2014-06-26 01:51:45 +00:00
Dave Abrahams
d1aa6fe2b8 [stdlib] Rename Array internals for clarity
Because _demandUniqueMutableBuffer returns nil if the buffer already
exists, rename to _createUniqueMutableBuffer.

Because _requestUniqueMutableBuffer may return native backing storage
for a slice whose bounds don't exactly match the backing storage, rename
to _requestUniqueMutableBackingBuffer

Swift SVN r19214
2014-06-26 01:49:54 +00:00
Dave Abrahams
f146b40401 [stdlib] 80-column fix
Swift SVN r19213
2014-06-26 01:49:53 +00:00