Commit Graph

121 Commits

Author SHA1 Message Date
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Maxim Moiseev
7372e9e045 COpaquePointer => OpaquePointer 2015-12-07 16:52:45 -08:00
Dmitri Gribenko
047e4002af stdlib: Fix coding style 2015-12-01 18:32:50 -08:00
Andrew Trick
b3604aaa83 Remove the fake _CocoaStringType protocol, NFC.
Adding a conformance to Foundation doesn't work because NSString can
be used without loading Foundation. debugDescription is one example of
this.

The only value we derive from the _CocoaStringType is its name, which
makes some APIs more readable. Adding a type safe wrapper around it
serves no purpose since we're almost always immediately casting back
and forth from an 'id'. This was previously done with unsafeBitCast,
which should be avoided unless we really need to reinterpret a bit
pattern.
2015-11-18 18:40:45 -08:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -08:00
Jordan Rose
6e1bf0d10d Rename @exported to @_exported for now.
At some point I want to propose a revised model for exports, but for now
just mark that support for '@exported' is still experimental and subject
to change. (Thanks, Max.)
2015-11-05 11:59:00 -08:00
Enrico Granata
cd26857b0a Take 2 - make NSObject conform to CustomDebugStringConvertible
Comes with a test case, and should now work since Jordan fixed the deserialization test case!



Swift SVN r32948
2015-10-28 21:49:25 +00:00
Enrico Granata
1f04d0955d Revert my previous commit as it breaks the buildbots
Swift SVN r32912
2015-10-27 17:24:57 +00:00
Enrico Granata
daea9036e5 Make NSObject conform to CustomDebugStringConvertible
NSObject vends a debugDescription member, but it was not marked accordingly in the overlay



Swift SVN r32904
2015-10-27 00:51:13 +00:00
Dmitri Hrybenko
2e51d23875 Un-ifdef object literals
Swift SVN r32880
2015-10-25 07:50:53 +00:00
Dmitri Hrybenko
6536edd68c stdlib: fix coding style
Swift SVN r32425
2015-10-03 21:13:15 +00:00
Dmitri Hrybenko
4375a463a7 stdlib: rename Int**.value and Float**.value to _value per naming convention
rdar://21357661

Swift SVN r32096
2015-09-20 00:01:13 +00:00
Dmitri Hrybenko
6402fda0c5 stdlib: remove a bunch of dynamic initializers from the library and overlays
Swift SVN r31403
2015-08-22 04:51:39 +00:00
Jordan Rose
5a82ddfd08 [ClangImporter] If a name contains "unsigned", import NSUInteger as UInt.
This takes care of things like NSNumber's 'init(unsignedInteger:)' and
'unsignedIntegerValue'.

rdar://problem/19134055

Swift SVN r31354
2015-08-19 22:10:48 +00:00
Chris Willmore
51f08e0285 Add FileReference object literals and _FileReferenceLiteralConvertible protocol.
<rdar://problem/21781451> Add file literal to Swift

Swift SVN r31232
2015-08-13 22:38:55 +00:00
Jordan Rose
ff7b6b74fe Foundation overlay: Add a generic NSCoder.decodeObjectOfClass(_:forKey:).
Like decodeTopLevelObjectOfClass(_:forKey:), this API works very nicely
as a generic method in Swift, and this one is actually the one we expect
to be commonly used. One thing to note here is that these methods are
stricter than their ObjC counterparts: they will do a forced checked cast
even when the unarchiver does not use "secure" coding.

This depends on the previous commit; without it, we do not actually
enforce type safety for these methods.

The API notes change is to make the non-generic version of this method
unavailable so that it does not participate in overload resolution.
Without this we prefer the non-generic method unless there's a contextual
type for the result. I've filed rdar://problem/22243198 to track taking
this out once Foundation has updated their headers.

rdar://problem/17060110 (again)

Swift SVN r31154
2015-08-12 01:36:08 +00:00
Dmitri Hrybenko
050a2cdea8 Foundation overlay: adopt @warn_unused_result
Reviewed by Michael J LeHew Jr.

Swift SVN r31064
2015-08-06 23:50:53 +00:00
Dmitri Hrybenko
e587ef0086 SDK overlay: adopt @warn_unused_result
Swift SVN r31051
2015-08-06 15:54:52 +00:00
David Farler
f924e8e007 ArraySlice indexes no longer zero-based
ArraySlice indices now map directly onto the collection it is slicing
and maintains that mapping even after mutations.

Before:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 0..<5
s[0] = 111
s                // [111, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 1..<5

After:

var a = Array(0..<10)
var s = a[5..<10]
s.indices        // 5..<10
s[5] = 99
s                // [99, 6, 7, 8, 9]
s.removeFirst()
s.indices        // 6..<10

- Refactor some of the internals of the buffer types to make it easier
  to read and understand.
- Add Array, ArraySlice, and ContiguousArray to the test suite at the
  RangeReplaceable test entry points, subjecting them to the same tests
  as all of our collections.
- Update existing test expectations for the indexing changes.

rdar://problem/21866825

Swift SVN r30840
2015-07-31 03:25:29 +00:00
Dmitri Hrybenko
3ba51ad202 Foundation overlay: fix coding style
Swift SVN r30350
2015-07-18 00:39:46 +00:00
Dmitri Hrybenko
109add8131 Foundation overlay: add NSCoder.decodeObjectOfClasses(_:forKey:)
Due to the fact that AnyClass is not Hashable, and that currently
NSKeyedArchiver/Unarchiver work with NSObject-derived, NSCoding
compliant classes, we are marking the decodeObjectOfClasses API refined
for Swift in our objc header and providing the desired overlay in our
overlay as shown below.

Arrays were also considered (for both API), but the underlying
implementation is entirely set-based, and using Arrays in Swift vs Sets
in objective C felt like too far a deviation.

Patch by Michael LeHew Jr.

Changes to the Dictionary test are caused by bumping the Fonudation API
epoch and taking in a fix in the types used in an NSDictionary
initializer.

rdar://21486551

Swift SVN r30297
2015-07-17 03:07:47 +00:00
Dmitri Hrybenko
82c6b23239 SDK overlay: use AnyObject instead of AnyClass to pass an id-compatible
Class representation

As Joe explained, when Swift passes a metatype like AnyClass for an type
defined in Objective-C, it will pass the Swift metadata pointer instead
of an id-compatible Class.

Swift SVN r30268
2015-07-16 17:34:09 +00:00
Dmitri Hrybenko
d9726efbb2 stdlib: rename Set's generic parameter from T to Element
Same for SetGenerator and SetIndex.

Part of rdar://21429126

Swift SVN r29619
2015-06-24 20:41:51 +00:00
Dmitri Hrybenko
51e236c609 stdlib: rename Array's generic parameter from T to Element
Same for ArraySlice and ContiguousArray.

Part of rdar://21429126

Swift SVN r29618
2015-06-24 20:41:49 +00:00
Dmitri Hrybenko
d46cb9db6e Foundation overlay: remove initWithObjectsAndKeys:_,...
<rdar://problem/21384187> NSDictionary's convenience init(objects:
[AnyObject], forKeys keys: [AnyObject]) is unsound

This method is unsound / unsafe for Swift.  There is not a way to
correctly express the alternating variadic type constant:
AnyObject, NSCopying,...

The overlay already defines a tuple based method that serves the same
role.

Patch by Michael J LeHew Jr.

Swift SVN r29497
2015-06-18 23:24:19 +00:00
Jordan Rose
99768eb346 Revert "Switch overlays from using @exported to -import-underlying-module."
This reverts r29441 because it breaks the Linux build. I'll talk to Dmitri
about this tomorrow.

See rdar://problem/21254367

Swift SVN r29444
2015-06-17 05:02:21 +00:00
Jordan Rose
c8bfc87c4e Switch overlays from using @exported to -import-underlying-module.
Some day we'll close the hole for @exported in the previous commit.

Swift SVN r29441
2015-06-17 04:48:06 +00:00
Dmitri Hrybenko
adda8a980d Foundation overlay: add throwing and generic variants for NSCoder APIs
rdar://21166220

Swift SVN r29415
2015-06-17 00:27:22 +00:00
Joe Groff
d7b9ae72aa Sema: Require '.init' when constructing from a dynamic metatype.
This makes it clearer that expressions like "foo.myType.init()" are creating new objects, instead of invoking a weird-looking method. The last part of rdar://problem/21375845.

Swift SVN r29375
2015-06-14 19:50:06 +00:00
Dmitri Hrybenko
76e9ab86b0 stdlib: expand an abbreviation in an internal function
Swift SVN r29270
2015-06-03 03:48:58 +00:00
Dmitri Hrybenko
20e0a04367 Foundation overlay: make registerUndoWithTarget work with Swift classes
Patch by Michael LeHew Jr.

rdar://21177512

Swift SVN r29200
2015-06-01 18:02:16 +00:00
Dmitri Hrybenko
4f464763cd stdlib: note that the CFXyzCreateCopy bugs were fixed
Since Swift deploys back to OS X 10.9 and iOS 7.0, we should continue to
use the API that works everywhere.

Swift SVN r29057
2015-05-27 04:20:51 +00:00
Dmitri Hrybenko
3cc2161e6f SDK overlay: add generic API overlays for NSUndoManager
Patch by Michael J LeHew Jr.

Swift SVN r28833
2015-05-20 18:02:00 +00:00
Dmitri Hrybenko
53f3ccf850 stdlib: change CollectionType.count() into a property
Swift SVN r28829
2015-05-20 09:14:43 +00:00
Dmitri Hrybenko
313701286b stdlib: Various punctuation and markup improvements to the comments.
Patch by Brian Lanier.

Swift SVN r28659
2015-05-16 03:04:51 +00:00
Dmitri Hrybenko
d8d50e1815 stdlib: in Array bridging code, use the same pattern as Set and Dictionary use
Also, simplify the code by removing an unused parameter.  NFC.

Swift SVN r28607
2015-05-15 03:44:37 +00:00
Dmitri Hrybenko
7c8a394cb1 Move NSObject extensions to the ObjectiveC overlay
NSObject is defined in the ObjectiveC module, not in Foundation.

rdar://20526438

Swift SVN r28591
2015-05-15 00:34:25 +00:00
Ted Kremenek
62feb5c949 Change @availability to @available.
This came out of today's language review meeting.
The intent is to match #available with the attribute
that describes availability.

This is a divergence from Objective-C.

Swift SVN r28484
2015-05-12 20:06:13 +00:00
Dave Abrahams
5c55682d8b [stdlib] Capitalize keywords in doc comments
Again, the text is a lot more readable that way.

Swift SVN r28472
2015-05-12 16:59:13 +00:00
Dave Abrahams
106b39a497 [stdlib] Indent bullet continuations in doc comments
The text is a lot more readable that way.

Swift SVN r28471
2015-05-12 16:59:08 +00:00
Chris Lattner
c1df892d47 improve stdlib hygiene a bit.
Swift SVN r28392
2015-05-10 02:55:18 +00:00
Ted Kremenek
9f9bb725cf Rename '_ErrorType' to 'ErrorType'.
Swift SVN r28293
2015-05-07 21:59:29 +00:00
Dmitri Hrybenko
8b392eeea9 Revert "Remove Array.count, it is redundant with protocol extensions"
This reverts commit r28247 while we discuss the change.

Swift SVN r28292
2015-05-07 21:45:30 +00:00
Dmitri Hrybenko
58601fafc8 Remove Array.count, it is redundant with protocol extensions
Swift SVN r28247
2015-05-07 00:30:41 +00:00
Dmitri Hrybenko
c109ec9125 stdlib: protocol extensions: de-underscore count()
Swift SVN r28246
2015-05-07 00:30:38 +00:00
Dmitri Hrybenko
0453656f31 Adapt to Foundation API modernization: NSRectEdge is now an enum
This commit adds the initializers requested in rdar://20169260.

Swift SVN r28185
2015-05-05 22:50:59 +00:00
Joe Groff
3cad008353 stdlib: Comment out NSArray: CollectionType conformance.
Dmitri notes that this should be API reviewed.

Swift SVN r28002
2015-04-30 22:26:13 +00:00
Joe Groff
b66675237a stdlib: Uncomment FIXME'd NSArray: CollectionType conformance.
Swift SVN r27999
2015-04-30 21:59:44 +00:00
Chris Lattner
31c01eab73 Change the meaning of "if let x = foo()" back to Xcode 6.4 semantics. The compiler
includes a number of QoI things to help people write the correct code.  I will commit
the testcase for it as the next patch.

The bulk of this patch is moving the stdlib, testsuite and validation testsuite to
the new syntax.  I moved a few uses of "as" patterns back to as? expressions in the 
stdlib as well.



Swift SVN r27959
2015-04-30 04:38:13 +00:00
Dmitri Hrybenko
44ef30a5af stdlib: fix grammar in an error message
Swift SVN r27734
2015-04-26 00:08:13 +00:00