Commit Graph

13406 Commits

Author SHA1 Message Date
Jordan Rose
2836c474ec [Accessibility] Public enum cases cannot have private payloads.
...because you can't match them properly in switches.

In the future, we could consider allowing private enum cases in a
resilient public enum, which essentially forces the user to consider the
default case.

Swift SVN r19620
2014-07-07 18:39:35 +00:00
Jordan Rose
2ebcd5d831 Hide the representations of DictionaryIndex and DictionaryGenerator.
Enum cases can't be less public than the enum type in 1.0, so add a trivial
layer of indirection to these types so the "enum-ness" is internal while the
type itself remains public.

Swift SVN r19619
2014-07-07 18:39:33 +00:00
Doug Gregor
0c31ff5681 Move bridging conversions into the type checker.
Previously, bridged value types and their corresponding Objective-C
classes allow inter-conversion via a number of user-defined conversion
functions in the Foundation module. Instead, make this a general
feature of the type checker so we can reason about it more
directly. Fixes <rdar://problem/16956098> and
<rdar://problem/17134986>, and eliminates 11 (half) of the
__conversion functions from the standard library and overlays.

A few notes:
  - The XCTest changes are because a String can no longer directly
  conform to CVarArg: this is a Good Thing (TM), because it should be
  ambiguous: did you mean to pass it as an NSString or a C string?
  - The Objective-C representations for the bridged collections are
  hard-coded in the type checker. This is unfortunate and can be
  remedied by adding another associated type to the
  _BridgedToObjectiveC protocol.

Swift SVN r19618
2014-07-07 18:04:18 +00:00
Dmitri Hrybenko
b20abdfcbe stdlib: fix grammar in Array comments (they used to say 'a Array')
rdar://17075487


Swift SVN r19612
2014-07-07 15:31:11 +00:00
Dmitri Hrybenko
09bbec7464 stdlib: fix a crash in String.rangeOfString when the result is NSNotFound
rdar://17550857


Swift SVN r19611
2014-07-07 15:25:10 +00:00
Dmitri Hrybenko
a9ee1f88ac stdlib: remove withUnsafePointerToObject
It is completely unused, and I am not even convinced it is safe.  It
assumes that size of ImplicitlyUnwrappedOptional<T> is equal to pointer
size (while this is true for Objective-C pointer types, there was no
precondition that enforced this).

Swift SVN r19604
2014-07-07 10:53:34 +00:00
Dmitri Hrybenko
6f5a2e5d87 stdlib: remove LifetimeManager, it is completely unused,
withUnsafePointer-like functions provide safer idioms

Swift SVN r19603
2014-07-07 10:32:19 +00:00
Dmitri Hrybenko
f61bf5d8ba stdlib: remove withObjectAtPlusZero(), now we have built-in CF bridging
support

Swift SVN r19601
2014-07-07 10:13:44 +00:00
Dmitri Hrybenko
1911aaed9f stdlib: hide isUniquelyReferenced
Swift SVN r19598
2014-07-07 10:01:48 +00:00
Dmitri Hrybenko
62c772ad6a stdlib: hide Objective-C bridging implementation details
Swift SVN r19595
2014-07-07 09:46:07 +00:00
Dmitri Hrybenko
00fe3bcda3 stdlib: hide swift_keepAlive
Swift SVN r19594
2014-07-07 09:46:02 +00:00
Dmitri Hrybenko
735bf5e785 stdlib: hide swift_bufferAllocate
Swift SVN r19593
2014-07-07 09:45:59 +00:00
Dmitri Hrybenko
8a3c73e08a stdlib: hide countLeadingZeros
Swift SVN r19592
2014-07-07 09:45:56 +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
1b589e15ca stdlib: Remove a redundant _precondition from _asUTF16CodeUnit
Swift SVN r19583
2014-07-06 12:58:45 +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
81f1e660a0 stdlib: hide encodeBitsAsWords
rdar://17315534


Swift SVN r19569
2014-07-04 17:04:48 +00:00
Dmitri Hrybenko
594dfe5e2d stdlib: hide swift_MagicMirrorData_summaryImpl
rdar://17315534


Swift SVN r19568
2014-07-04 16:08:29 +00:00
Dmitri Hrybenko
7f351643d9 stdlib: hide roundUpToAlignment
rdar://17315534


Swift SVN r19566
2014-07-04 15:57:47 +00:00
Dmitri Hrybenko
29ab26ca39 stdlib/UnicodeScalar: hide UnicodeScalar.isPrint(), it is not
Unicode-aware

rdar://17550187

Swift SVN r19564
2014-07-04 13:13:42 +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
cf2c5386a9 stdlib: change ReverseRange.isEmpty() into a property
Swift SVN r19562
2014-07-04 12:46:21 +00:00
Dmitri Hrybenko
ac7fee3a64 stdlib: add Dictionary.isEmpty property
Swift SVN r19561
2014-07-04 11:27:48 +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
8361bccc5a stdlib: fix some 80-cols violations
Swift SVN r19559
2014-07-04 08:09:44 +00:00
Chris Lattner
7a56499d61 Start making @objc not start with an @ sign:
- Change the parser to accept "objc" without an @ sign as a contextual
   keyword, including the dance to handle the general parenthesized case.
 - Update all comments to refer to "objc" instead of "@objc".
 - Update all diagnostics accordingly.
 - Update all tests that fail due to the diagnostics change.
 - Switch the stdlib to use the new syntax.

This does not switch all tests to use the new syntax, nor does it warn about
the old syntax yet.  That will be forthcoming.  Also, this needs a bit of 
refactoring, which will be coming up.



Swift SVN r19555
2014-07-04 05:57:57 +00:00
Anna Zaks
c1537fdcdd Reject explicit uses of CFRetain/CFRelease/CFAutorelease
Ban use of CFRetain, CFRelease, CFAutorelease used for manual memory management as well as a bunch of other similar APIs, such as CGColorRelease.
Addresses radar://16892185

Swift SVN r19552
2014-07-04 02:29:05 +00:00
Jordan Rose
bdd1ec3116 Update stdlib and tests for accessibility, again.
I'll be turning on access control early next week.

Swift SVN r19551
2014-07-04 01:53:53 +00:00
Jordan Rose
cdd8532f33 Remove @private from the stdlib.
@private can't safely be used with inlineable code at this time, which
unfortunately covers the entire standard library.

Swift SVN r19550
2014-07-04 01:53:52 +00:00
Enrico Granata
314dbc6ed1 Forgot to add the most important part of the patch to the previous commit.
Swift SVN r19544
2014-07-03 23:44:21 +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
Anna Zaks
6aadb1a647 APIs in XCTest now uses UInt, not Int.
Fixup for r19536.

Swift SVN r19538
2014-07-03 22:33:07 +00:00
Enrico Granata
d6586cb7a7 The Mirrors Generator
This is a .gyb file based upon Dave's trick of allowing boilerplate templates (r19490)
As per comments, this will generate all the common cruft of getting a Mirror up and running - yes including the Reflectable conformance on the type!

It could likely be extended to specify a full Mirror, either by defaulting missing parts, or by letting you specify them as arguments to the template
However, since we can have other templates that use this as a foundation, those expansions might be best served being their own templates based upon this

Also, the members this doesn't generate for you are usually the ones you care about when writing a Mirror, so probably passing them as arguments to this template generator would only make things look uglier/less obvious when skimming through the code



Swift SVN r19534
2014-07-03 21:46:13 +00:00
Dave Abrahams
8db106ea17 [stdlib] Optimize Array member sort
Have it use withUnsafeMutableStorage just like the overloaded free
algorithm does.

Swift SVN r19533
2014-07-03 21:45:50 +00:00
Dave Abrahams
1f68ff48cc [stdlib] Detect/fix potential memory-safety issue
When a user violates the inout rules by "re-entering" an array that is
currently undergoing mutation, it must not admit a memory-safety
violation.  To ensure that it doesn't, temporarily make the buffer being
operated on inaccessible through the original array.

Swift SVN r19532
2014-07-03 21:44:49 +00:00
Dmitri Hrybenko
0c205b3e5e stdlib/OutputStream: fix println() comments
Swift SVN r19525
2014-07-03 19:57:51 +00:00
Doug Gregor
0598b6db5e Casting runtime: Use the runtime's constant for reserved bits in an ObjC pointer.
Previously, we had a predicate that only worked properly for 64-bit
architectures; the 32-bit platforms don't have tagged pointers, and
have an annoying tendency to allocate objects with the high bit of the
address set. Fixes <rdar://problem/17544277>.

Swift SVN r19523
2014-07-03 17:55:38 +00:00
Jordan Rose
8080ca6820 [Accessibility] Public functions/initializers may not use private types.
Also, don't diagnose accessibility violations on implicit decls. Every now
and then the compiler needs to bend the rules, such as when providing an ==
implementation for a local enum.

Swift SVN r19519
2014-07-03 17:45:36 +00:00
Dave Abrahams
6dde77adca [stdlib] Delete Range.swift
This was a part of r19497 that I failed to commit.

Swift SVN r19517
2014-07-03 17:15:21 +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
7802479519 stdlib: don't use '\returns' in comments
Swift SVN r19512
2014-07-03 14:25:46 +00:00
Doug Gregor
37d69a4207 Allocator: round the size of an allocation up to the alignment on all allocation and deallocation paths.
We were rounding the size up to the alignment when allocating a new object (swift_allocObject) but not when directly allocating memory for a non-object (swift_slowAlloc). The deallocation code wasn’t rounding the size up to the alignment at all. Overall, this meant that we would get the wrong index into the allocation cache when deallocating an object whose size got rounded in a way that affects the index.

Fixes <rdar://problem/17542859>, where println(5) would fail on the 32-bit iOS simulator when building the runtime without NDEBUG (so we get extra checking) and the standard library is built without optimization (which keeps a certain 33-byte allocation on the heap). The Interpreter/SDK/objc_cast.swift test triggers this when built under those conditions.

Swift SVN r19499
2014-07-03 02:11:50 +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
Chris Hanson
d459ee4a3d Since all NSObject subclasses are Equatable, we can just use XCTAssertEqual/XCTAssertNotEqual.
Addresses <rdar://problem/17257148>

Swift SVN r19496
2014-07-03 00:31:08 +00:00
Jordan Rose
1769dd9a0b Mark some more things public...and mark ArrayType internal again!
Swift SVN r19492
2014-07-02 23:54:48 +00:00
Doug Gregor
2618061168 Eliminate a pointless and wrong initialization from swift_bridgeNonVerbatimFromObjectiveCConditional.
Fixes part of <rdar://problem/17411843>.

Swift SVN r19485
2014-07-02 22:15:47 +00:00
Joe Groff
1a332dbc80 Remove the UIKit overlay for UIApplicationMain.
UIApplicationMain now naturally gets imported with the correct argv type.

Swift SVN r19481
2014-07-02 20:53:10 +00:00
Joe Groff
c34b4f6a9e Enable string-to-pointer conversions and remove CString.
There is some follow-up work remaining:

- test/stdlib/UnicodeTrie test kills the type checker without manual type annotations. <rdar://problem/17539704>
- test/Sema/availability test raises a type error on 'a: String == nil', which we want, but probably not as a side effect of string-to-pointer conversions. I'll fix this next.

Swift SVN r19477
2014-07-02 19:15:10 +00:00