Commit Graph

49 Commits

Author SHA1 Message Date
Graham Batty
dc6a776d10 stdlib: Use config directives to work without objective-c.
Swift SVN r23211
2014-11-10 20:06:25 +00:00
Graham Batty
373414864d Revert "Use config directives to carve out a 'portable' kernel stdlib."
This reverts commit r23202 pending further discussion.

Swift SVN r23205
2014-11-10 18:46:42 +00:00
Graham Batty
dfa260fab1 Use config directives to carve out a 'portable' kernel stdlib.
Swift SVN r23202
2014-11-10 18:03:09 +00:00
Dmitri Hrybenko
ca4df0cbf2 stdlib: use 'count' for parameter name consistently
rdar://18665454

Swift SVN r22871
2014-10-22 00:58:31 +00:00
Dave Abrahams
a7f3e4222e [stdlib] finish public non-protocol docs
The 58 undocumented public non-operator APIs still present in core are
all on non-exposed (underscored) APIs.

Swift SVN r22263
2014-09-24 12:31:45 +00:00
Dmitri Hrybenko
a75c7a427a stdlib/NSString APIs on String: add more tests and fix a crash in
_countFormatSpecifiers() that was triggered by non-BMP characters in the format
string


Swift SVN r21014
2014-08-04 15:37:58 +00:00
Dmitri Hrybenko
06a9ea552c stdlib/String: fix hasPrefix() and hasSuffix() to perform proper Unicode
comparison

rdar://17498444


Swift SVN r20603
2014-07-27 18:12:02 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dmitri Hrybenko
52f3ba25b4 stdlib: underscore a private String initializer
Swift SVN r20408
2014-07-23 16:15:17 +00:00
Dave Abrahams
fd2c67c89c [stdlib] Generic String init from integers
also, dump a bunch of other init() functions from other types.

Fixes <rdar://problem/16925296> #Seed 5: Remove unneeded String initializers

Swift SVN r20395
2014-07-23 14:09:01 +00:00
Dave Abrahams
21669b3aee [stdlib] Add "Mutable" to [Autoreleasing]UnsafePointer
UnsafePointer becomes UnsafeMutablePointer
AutoreleasingUnsafePointer becomes AutoreleasingUnsafeMutablePointer

Swift SVN r20316
2014-07-22 16:56:23 +00:00
Dave Abrahams
3731a0d1d2 [stdlib] Deal with various zero-division scenarios
Primarily, this means becoming resilient to Builtin.strideof(x) == 0.
Pretty much the only way to get pointers and arrays to make sense is to
treat zero-sized elements as having a stride of 1, so we do that in our
wrapper for Builtin.strideof.  Other points include precondition checks
for radixes in number formatting.

Fixes <rdar://problem/17097768>

Swift SVN r20242
2014-07-21 05:21:22 +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
Jordan Rose
56ec3c901c [Accessibility] Properly treat typealiases as distinct types.
getAnyNominal() looks through sugar, so it was matching typealiases to
nominal types before the specific check for typealiases.

Swift SVN r19586
2014-07-06 22:07:28 +00:00
Dmitri Hrybenko
e95a9e9b72 stdlib: rename private API _asUnicodeCodePoint to _asUnicodeScalar
Swift SVN r19582
2014-07-06 12:50:07 +00:00
Chris Lattner
190d4901ae improve the doc comment on toInt to be more specific about what it does.
Swift SVN r19577
2014-07-04 21:18:47 +00:00
Chris Lattner
0ad1c248c8 fix <rdar://problem/17493994> String.toInt() returns 0 (not nil) for some non-numeric characters
Swift SVN r19575
2014-07-04 21:02:49 +00:00
Dmitri Hrybenko
6e5060d471 stdlib/UnicodeScalar: remove arithmetic operations, they interact in
non-obvious ways with double-quoted literal sytax; "1" - "1" used to compile

rdar://17225816


Swift SVN r19563
2014-07-04 13:11:52 +00:00
Dmitri Hrybenko
3422201d21 stdlib/String: move lowercaseString and uppercaseString properties to
Foundation, and have them forward to Foundation.

This is slower than it could be, but at least this way we produce correct
results.

Another part of rdar://17550187


Swift SVN r19560
2014-07-04 09:27:32 +00:00
Dmitri Hrybenko
c2ae63ba72 stdlib/UnicodeScalar: hide APIs that don't work with non-ASCII correctly
rdar://17550187


Swift SVN r19513
2014-07-03 14:47:35 +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
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
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
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
Doug Gregor
37df5c430c Update standard library to use [T] array syntax.
Swift SVN r19190
2014-06-25 23:39:20 +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
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
Dave Abrahams
f58196f954 [stdlib] String API Review: drop size()
Swift SVN r18515
2014-05-21 20:36:40 +00:00
Dave Abrahams
8445618f1d [stdlib] String API Review: hide "split" and "lines"
Swift SVN r18514
2014-05-21 20:30:23 +00:00
Dave Abrahams
ee261fb348 [stdlib] String API Review: kill byteLength()
Swift SVN r18513
2014-05-21 20:30:22 +00:00
Dave Abrahams
57347d54b5 [stdlib] String API Review: kill asUTF8()
Swift SVN r18512
2014-05-21 20:30:21 +00:00
Dave Abrahams
f14cc969dc [stdlib] String API Review: repeatedValue
Make the API for repeating a single Collection element consistent with
that for Array

Swift SVN r18511
2014-05-21 20:30:21 +00:00
Dave Abrahams
13962588a9 [stdlib] add reverse(c), s/Reverse/ReverseView/g
Now reverse() is available as a peer to map() and filter()
Addresses <rdar://problem/15919204>

Swift SVN r18389
2014-05-19 04:30:16 +00:00
Dave Abrahams
92307dee66 [stdlib] Array API Review: swap init parameters
Swift SVN r18325
2014-05-18 15:54:33 +00:00
Ted Kremenek
eab7f90a81 Per design discussion today, rename UnsafePointer ".pointee" to ".memory".
Swift SVN r18269
2014-05-17 20:35:16 +00:00
Ted Kremenek
dce90aed78 Change remaining standard library cases of isEmpty() to a property isEmpty.
Swift SVN r18266
2014-05-17 20:01:17 +00:00
Dmitri Hrybenko
a4d9dcf1a7 stdlib: extinguish \brief and \c
Swift SVN r18261
2014-05-17 18:10:51 +00:00
Ted Kremenek
4bb475a1c8 Rename UnsafePointer.get/set to a "ptr.pointee" property.
Implements <rdar://problem/16531067>.

Swift SVN r18178
2014-05-16 05:48:05 +00:00
Dave Abrahams
b666651e3f [stdlib] Rename NativeArray => ContiguousArray
Per API review feedback.

Swift SVN r18140
2014-05-15 23:24:09 +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
Dmitri Hrybenko
de9a0c8ff0 stdlib/printing: remove ReplPrintable protocol
It is replaced by debugPrint() family of functions, that are called by REPL.

There is a regression in printing types that don't conform to Printable, this
is tracked by rdar://16898708


Swift SVN r18006
2014-05-13 16:22:56 +00:00
Dmitri Hrybenko
2cc8fe40d4 stdlib/printing: replace four printing systems with one new one
The old ones were:

- print/println
- printAny
- printf
- Console

The new printing story is just print/println.  Every object can be printed.
You can customize the way it is printed by adopting Printable protocol.  Full
details in comments inside stdlib/core/OutputStream.swift.

Printing is not completely finished yet.  We still have ReplPrintable, which
should be removed, string interpolation still uses String constructors, and
printing objects that don't conform to Printable will result in printing
mangled names.


Swift SVN r18001
2014-05-13 13:07:59 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Dave Abrahams
21186b5dc1 [stdlib] Break String source into manageable pieces
Swift SVN r12453
2014-01-17 01:47:29 +00:00