Commit Graph

46 Commits

Author SHA1 Message Date
Dave Abrahams
218d25eb5a [stdlib] Propagate BidirectionalIndexType docs
193 undocumented public non-operator APIs remain in core

Swift SVN r22225
2014-09-23 19:35:31 +00:00
Dave Abrahams
c38e3201b2 [stdlib] Propagate ForwardIndexType docs to models
200 undocumented public APIs remain in core

Swift SVN r22222
2014-09-23 19:20:48 +00:00
Dave Abrahams
f4a7812065 [stdlib] Propagate SequenceType docs to models
235 undocumented public APIs remain in core

Swift SVN r22210
2014-09-23 10:40:37 +00:00
Dave Abrahams
76f9313088 [stdlib] Propagate GeneratorType docs to models
Swift SVN r22208
2014-09-23 09:47:26 +00:00
Dave Abrahams
1dd7272fe9 [stdlib] Propagate CollectionType docs to models
266 undocumented public APIs remain in core

Swift SVN r22206
2014-09-23 08:19:23 +00:00
Nadav Rotem
07f84793f3 Zap the string compare API.
We used this API for benchmarking and we don't need it anymore.

Swift SVN r21398
2014-08-22 00:53:27 +00:00
Dmitri Hrybenko
7db1d04f2c stdlib: add a comment for using modular arithmetic
Swift SVN r21397
2014-08-22 00:48:02 +00:00
Nadav Rotem
5319d8d220 Remove the overflow check because the variables are indices that must point to valid elements of the array of chars.
Swift SVN r21395
2014-08-22 00:19:58 +00:00
Dmitri Hrybenko
b09698a6e6 stdlib: privatize lazyConcatenate() and related APIs
Swift SVN r21039
2014-08-05 14:55:09 +00:00
Dave Abrahams
70b388ba77 [stdlib] Add append() to ExtensibleCollectionType
If you can be grown by an arbitrary sequence of your element type, you
can be grown by a single element.

Swift SVN r20996
2014-08-04 06:44:33 +00:00
Dave Abrahams
9fc959b862 [stdlib] UnicodeScalarView : RangeReplaceableCollectionType
Fixes <rdar://problem/17860946> Full Array mutation APIs for String and UnicodeScalarView

Swift SVN r20983
2014-08-03 22:44:03 +00:00
Dmitri Hrybenko
6e401c20ca stdlib: add a mirror for the Unicode scalar String view
Swift SVN r20977
2014-08-03 20:01:34 +00:00
Dmitri Hrybenko
5746e4e9ca stdlib: rename _fatalError to _sanityCheckFailure. Name similarity between
fatalError and _fatalError has caused some damage already, as some
memory-safety checks in Mirrors are _fatalErrors.


Swift SVN r20969
2014-08-03 15:20:37 +00:00
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +00:00
Dave Abrahams
e00e41af39 [stdlib] Remove String.compare()
This was added for benchmarking purposes, without the realization that
it conflicts with the NSString API we adopt when importing Foundation.
http://oleb.net/blog/2014/07/swift-strings/#comparing-strings describes
the problem.

Fixes <rdar://problem/17800504>

Swift SVN r20517
2014-07-24 21:29:48 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dave Abrahams
c4f798e246 [stdlib] Make our BidirectionalIndexTypes Comparable
This will allow more error checking, resilient slicing, and occasionally
other useful capabilities.

Step 1 of <rdar://problem/11940897>

Swift SVN r20036
2014-07-16 20:43:42 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00
Doug Gregor
8fb9a19542 Replace the "string" property of String.UnicodeScalarView with a String initializer.
Swift SVN r19695
2014-07-08 20:25:30 +00:00
Doug Gregor
973caddc24 Replace String.UnicodeScalarView's user conversion to String with a "string" property
Swift SVN r19691
2014-07-08 20:01:50 +00:00
Jordan Rose
da29f099f0 Update stdlib for accessibility modifiers becoming context-sensitive keywords.
Swift SVN r19672
2014-07-08 02:17:46 +00:00
Dmitri Hrybenko
57df21cefe stdlib/comments: UTF-8 and UTF-16 are spelled with a dash
Swift SVN r19466
2014-07-02 15:45:38 +00:00
Manman Ren
2b2330bf5b [attribute] rename @noinline to @inline(never).
Add support for parsing inline(never), it can be easily expanded to
handle inline(always).

rdar://17527111


Swift SVN r19447
2014-07-02 01:27:05 +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
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
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
Manman Ren
0501da8f54 [stdlib] use noinline to get rid of closure.
Remove wrapping the callee in a closure to disable inlining, instead mark callee
as noinline.

No performance change is observed.


Swift SVN r19194
2014-06-25 23:50:14 +00:00
Dmitri Hrybenko
6bb6e1b0b4 stdlib/String: if we can not get a contiguous data buffer out of NSString,
don't call into CoreFoundation to perform UTF-8 transcoding.  CoreFoundation
can replace ill-formed sequences with a single byte, which is not good enough
to implement U+FFFD insertion.  Instead, use the same transcoding routine as
for contiguous buffer.

Pulled out the transcoding routine into a generic function that should be
specialized and simplified for the case when input is UnsafeArray; we should
not be losing efficiency here.

Fixes <rdar://problem/17297055> [unicode] println crashes when given string
with unpaired surrogate



Swift SVN r19157
2014-06-25 13:24:15 +00:00
Jordan Rose
cca27d02a0 Tag everything in the standard library with accessibility attributes.
Keep calm: remember that the standard library has many more public exports
than the average target, and that this contains ALL of them at once.
I also deliberately tried to tag nearly every top-level decl, even if that
was just to explicitly mark things @internal, to make sure I didn't miss
something.

This does export more than we might want to, mostly for protocol conformance
reasons, along with our simple-but-limiting typealias rule. I tried to also
mark things private where possible, but it's really going to be up to the
standard library owners to get this right. This is also only validated
against top-level access control; I haven't fully tested against member-level
access control yet, and none of our semantic restrictions are in place.

Along the way I also noticed bits of stdlib cruft; to keep this patch
understandable, I didn't change any of them.

Swift SVN r19145
2014-06-24 21:32:18 +00:00
Ted Kremenek
58558fcca3 Rename 'succ' and 'pred' to 'successor' and 'predecessor' respectively.
This is motivated by <rdar://problem/17051606>.

This ends up renaming variables as well, which seems right for
consistency since we use "predicate" as variable name.

Swift SVN r19135
2014-06-24 19:27:19 +00:00
Dmitri Hrybenko
2103b1d995 stdlib/Unicode: fix UTF-16 decoder not to crash on invalid code unit sequences
Also implemented U+FFFD insertion in UTF-16 decoder according to Unicode
reccomendation.


Swift SVN r19091
2014-06-23 14:52:24 +00:00
Dmitri Hrybenko
f370ca0746 stdlib: fix a bunch of various Unicode issues, primarily in UTF-8 decoding
In UTF-8 decoder:
- implement U+FFFD insertion according to the recommendation given in the
  Unicode spec.  This required changing the decoder to become stateful, which
  significantly increased complexity due to the need to maintain an internal
  buffer.
- reject invalid code unit sequences properly instead of crashing rdar://16767868
- reject overlong sequences rdar://16767911

In stdlib:
- change APIs that assume that UTF decoding can never fail to account for
  possibility of errors
- fix a bug in UnicodeScalarView that could cause a crash during backward
  iteration if U+8000 is present in the string
- allow noncharacters in UnicodeScalar.  They are explicitly allowed in the
  definition of "Unicode scalar" in the specification.  Disallowing noncharacters
  in UnicodeScalar prevents actually using these scalar values as internal
  special values during string processing, which is exactly the reason why they
  are reserved in the first place.
- fix a crash in String.fromCString() that could happen if it was passed a null
  pointer

In Lexer:
- allow noncharacters in string literals.  These Unicode scalar values are not
  allowed to be exchanged externally, but it is totally reasonable to have them
  in literals as long as they don't escape the program.  For example, using
  U+FFFF as a delimiter and then calling str.split("\uffff") is completely
  reasonable.

This is a lot of changes in a single commit; the primary reason why they are
lumped together is the need to change stdlib APIs to account for the
possibility of UTF decoding failure, and this has long-reaching effects
throughout stdlib where these APIs are used.


Swift SVN r19045
2014-06-20 13:07:40 +00:00
Chris Lattner
62cad3dce8 add a "..<" operator, which is an alias for ".." and switch the stdlib to use it.
Until I have a chance to update the testsuite, we'll accept both.



Swift SVN r18998
2014-06-19 05:42:29 +00:00
Nadav Rotem
1dc6de3785 Add a comment that explains how we disable inlining. NFC.
Swift SVN r18646
2014-05-27 00:32:20 +00:00
Nadav Rotem
dd4d9f5820 Make sure we don't inline the cold path by wrapping it with a closure.
Swift SVN r18641
2014-05-26 20:24:05 +00:00
Dave Abrahams
d17c4171da [stdlib] 80-column fixes
Swift SVN r18382
2014-05-19 02:08:19 +00:00
Nadav Rotem
14f4dd3a97 fix a typo
Swift SVN r18182
2014-05-16 06:06:52 +00:00
Nadav Rotem
70dfa94160 Extend the coverage of the fast path in the UTF16 comparator to more than ascii.
Swift SVN r18180
2014-05-16 05:58:39 +00:00
Nadav Rotem
2d592b6af9 Rename local variables. NFC.
Swift SVN r18176
2014-05-16 05:05:34 +00:00
Nadav Rotem
c1db20d178 Rename member_NthContiguous -> _nthContiguous
Swift SVN r18172
2014-05-16 04:26:10 +00:00
Nadav Rotem
c77b97079c Hoist the check for contiguous storage outside of the comparison loop.
Once we know that the storage is contiguous we use the new API _NthContiguous.
We can further optimize this code by specializing the access to ascii or UTF-16.



Swift SVN r18167
2014-05-16 03:44:32 +00:00
Dave Abrahams
a8bbc4c89b [stdlib] String internal API review changes
I had to XFAIL test/ClangModules/cf.swift, which is failing for reasons
I can't understand.  <rdar://problem/16911496>

Swift SVN r18071
2014-05-14 14:18:52 +00:00
Ted Kremenek
9eea282719 Switch range operators ".." and "...".
- 1..3 now means 1,2
- 1...3 now means 1,2,3

Implements <rdar://problem/16839891>

Swift SVN r18066
2014-05-14 07:36:00 +00:00
Ted Kremenek
49d4fca14d Rename UTF16Scalars to UnicodeScalarView.
Implements <rdar://problem/16821900>.

Swift SVN r17899
2014-05-11 23:51:07 +00:00