Commit Graph

177 Commits

Author SHA1 Message Date
Dave Abrahams
c91e0f98a0 [stdlib] bugfix: Copy bridged NSMutableArray's
When NSArrays are bridged into Array<T>, they weren't being .copy()'d.
As a result, changes to an NSMutableArray (cast to NSArray), could cause
"unrelated" Swift Arrays to mutate.  Found by inspection while
bottlenecking unsafeBitCast's in Array implementation, which also
happens in this commit.

Swift SVN r20678
2014-07-29 17:59:41 +00:00
Dave Abrahams
9a13a7148b [stdlib] Consolidate bridging protocols
Squash _[Conditionally]BridgedToObjectiveC into one protocol.  This
change results in simpler bridging code with fewer dynamic protocol
conformance checks, and solves the nasty naming/semantics problem that
resulted from having _ConditionallyBridgedToObjectiveC refining
_BridgedToObjectiveC.

Also, rename things so they're more symmetrical and less confusing.

Swift SVN r20664
2014-07-29 01:30:27 +00:00
Doug Gregor
bd75425b0e Remove the notion of non-inheritable conformances entirely <rdar://problem/16880016>.
Swift SVN r20627
2014-07-28 16:29:05 +00:00
Doug Gregor
3cb58e833a Restrict non-final class protocol conformance when Self is part of the requirement signature.
When a non-final class satisfies a method requirement that returns
Self, it must do so with a method that also returns (dynamic)
Self. This ensures conformance will be inheritable, closing off an
awful type-safety hole <rdar://problem/16880016>. Other
non-contravariant uses of Self in the signatures of requirements cause
the protocol to be unusable by non-final classes.

I had to leave a tiny little gaping hole for the ~> operator, whose
removal is covered by <rdar://problem/17828741>. We can possibly put
this on firm footing with clever handling of generic witnesses, but
it's not important right now.



Swift SVN r20626
2014-07-28 16:15:16 +00:00
Dmitri Hrybenko
ca07053adc stdlib: rename fatalError() to debugTrap()
Part of rdar://17792445


Swift SVN r20619
2014-07-28 11:14:52 +00:00
Dmitri Hrybenko
729266205d stdlib: mark Float.value as private
Swift SVN r20590
2014-07-26 19:48:03 +00:00
Doug Gregor
d3012a0c26 Replace an 'override' with a 'required' for init(coder:).
Swift SVN r20496
2014-07-24 17:01:03 +00:00
Doug Gregor
5fc8ac7fd1 Require the 'override' keyword for initializers that override designated initializers.
Swift SVN r20490
2014-07-24 15:38:33 +00:00
Dave Abrahams
d00e888d95 [stdlib] Rename reinterpretCast => unsafeBitCast
Also give unsafeBitCast an explicit type parameter.  So

  let x: T = reinterpretCast(y)

becomes

  let x = unsafeBitCast(y, T.self)

Swift SVN r20487
2014-07-24 13:17:36 +00:00
Dmitri Hrybenko
89420772a2 stdlib/String: move enough bridging machinery into the core standard
library so that core library can bridge a String to Objective-C

Part of rdar://17498444

Swift SVN r20485
2014-07-24 13:07:12 +00:00
Doug Gregor
b1b6886fda Add missing required initializers to _NSContiguousString and _NSOpaqueString.
Swift SVN r20449
2014-07-23 23:47:02 +00:00
Dave Abrahams
a3211d0d68 [stdlib] dynamic NSString.localizedStringWithFormat
It used to always construct an NSString; now it constructs the class it
was called through

Swift SVN r20439
2014-07-23 22:59:27 +00:00
Dmitri Hrybenko
766c9816de stdlib: underscore-prefix String.core
Swift SVN r20411
2014-07-23 16:28:57 +00:00
Dmitri Hrybenko
d168ad3d13 stdlib: don't use Builtin types in public APIs, this is quite pointless
Swift SVN r20392
2014-07-23 13:05:37 +00:00
Dave Abrahams
00f9ca5eda [stdlib] Rename [_]elementStorage=>[_]baseAddress
Swift SVN r20342
2014-07-22 22:29:03 +00:00
Dave Abrahams
1438d617cd [stdlib] Rename ConstUnsafePointer=>UnsafePointer
Swift SVN r20318
2014-07-22 17:10:54 +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
2c3ab47cf2 [stdlib] O(1) Array<non-verbatim> round-tripping
Arrays of non-verbatim-bridged types (such as Int, and today's String)
are converted to Objective-C lazily, with the objects created due to
element conversion being autoreleased when necessary.

Fixes <rdar://problem/17360154>

Note: test/SIL/Parser/array_roundtrip.swift was XFAIL'd;
see <rdar://problem/17758203>

Swift SVN r20293
2014-07-22 04:42:47 +00:00
Joe Groff
436acb00f3 Foundation: Remove the prepareWithInvocationTarget overlay.
Giving the invocation target proxy a type will be bogus when we turn on 'dynamic'. This breaks the NSUndoManager tests because we still can't work with lvalues through AnyObject. <rdar://problem/17755906>

Swift SVN r20283
2014-07-22 00:23:34 +00:00
Fariborz Jahanian
5197fe0f9d Move noErr to Darwin with OSStatus as its type.
rdar://17285288


Swift SVN r20279
2014-07-21 21:14:27 +00:00
Fariborz Jahanian
55e3e4b028 declare 'noErr' in the overlay to be of type Int32
(to make it compatible with OSStatus) rdar://17285288
This line, and those below, will be ignored--

M    stdlib/objc/Foundation/Foundation.swift


Swift SVN r20278
2014-07-21 20:43:55 +00:00
Fariborz Jahanian
ff02defe06 Adding "typealias NSRectEdge = CGRectEdge" in the
overlay. rdar://16593744


Swift SVN r20269
2014-07-21 19:06:35 +00:00
Dave Abrahams
8091436114 [stdlib] Bridge the types NSValue wraps explicitly
NSRange, NSPoint, NSSize, and NSRect.  This time, using Jordan's
suggestion for iOS portability.

Fixes <rdar://problem/16973060>


Conflicts:
	stdlib/objc/Foundation/CMakeLists.txt
	stdlib/objc/Foundation/Foundation.swift

Swift SVN r20241
2014-07-21 04:18:40 +00:00
Ted Kremenek
3075dee511 Mark 'NSConstantString' unavailable. Implements <rdar://problem/17306671>.
Swift SVN r20208
2014-07-19 05:14:06 +00:00
Dave Abrahams
ac1a050732 [stdlib] make some bridging classes final
Swift SVN r20186
2014-07-18 22:07:07 +00:00
Dmitri Hrybenko
4c4f83fb52 stdlib: underscore-prefix requirements of _BridgedToObjectiveCType and
_ConditionallyBridgedToObjectiveCType protocols

rdar://17283639


Swift SVN r20079
2014-07-17 09:42:19 +00:00
Dmitri Hrybenko
f04a37ffd3 stdlib: make NSDictionary.Generator initializer private (users should call
NSDictionary.generate())


Swift SVN r20022
2014-07-16 09:05:22 +00:00
Dmitri Hrybenko
d9d789f418 stdlib: rename NSDictionaryGenerator to NSDictionary.Generator
rdar://17674077


Swift SVN r20021
2014-07-16 08:59:37 +00:00
Dave Abrahams
d85a7f5d0c [stdlib] Pointer types are not BooleanType's
Fixes <rdar://problem/17597917>.  Someone still needs to do this for the
Optional types.

Swift SVN r19901
2014-07-13 19:21:54 +00:00
Dmitri Hrybenko
45f9706c22 stdlib/Dictionary: remove 'public' from more Dictionary implementation details
Swift SVN r19898
2014-07-13 12:21:20 +00:00
Dmitri Hrybenko
08d6650828 stdlib/Dictionary: move implementation of Dictionary.bridgeToObjectiveC() from
Foundation overlay to core stdlib, and remove 'public' from some Dictionary
implementation details


Swift SVN r19897
2014-07-13 11:51:23 +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
Dmitri Hrybenko
355316a49b stdlib/Dictionary: when bridging from Objective-C, recognize bridged
native Dictionary storage and adopt it if KeyType and ValueType match
exactly

This was the last missing piece to allow Dictionary to round-trip
thorough objc entrypoints of Swift methods in O(1).

Fixes rdar://17556319, partially fixes rdar://17010353

Swift SVN r19873
2014-07-12 01:17:13 +00:00
Dmitri Hrybenko
9cbf6df734 stdlib/Dictionary: add _DictionaryBuilder, which is faster than adding elements
one by one.

Use _DictionaryBuilder in Foundation overlay instead of poking Dictionary's
internals directly.


Swift SVN r19855
2014-07-11 17:35:32 +00:00
Dmitri Hrybenko
ee06efdd2c stdlib/Dictionary: when bridging Dictionary of non-verbatim-bridged
types to NSDictionary, perform bridging operation in O(1), and defer
bridging of the contents until the NSDictionary is accessed

There is no cache for bridged keys and values; the Swift NSDictionary
will return values with different pointer values when a given key is
repeatedly accessed.

Part of rdar://17556319

Does not fix the O(N) performance of objc thunks, because Dictionary is
not recognizing its own native storage when bridging from Objective-C.
This tracked by rdar://17010353

Swift SVN r19853
2014-07-11 17:24:06 +00:00
Enrico Granata
2cd27ad3d2 Tweaks to get PlaygroundLogger to build and work in a world of accessibility-enforced rules
1) Add an ObjCObject disposition that tells us this Mirror is reflecting upon an ObjC-imported type
2) Change the default summary of _ClassMirror and _StructMirror to be the mangled typename, with no children count



Swift SVN r19817
2014-07-10 18:54:25 +00:00
Dmitri Hrybenko
86f58123f9 stdlib/Array: hide some Array implementation details:
ArrayBuffer
ArrayBufferType
ContiguousArrayBuffer
ContiguousArrayStorage
IndirectArrayBuffer
SliceBuffer

Unfortunately, can not remove 'public' from them since they are used by
Foundation overlay in bridging code.


Swift SVN r19810
2014-07-10 14:30:54 +00:00
Dmitri Hrybenko
54efce9aa5 stdlib/Dictionary bridging: optimize NSDictionary to Dictionary conversion
during eager bridging

rdar://17325454


Swift SVN r19808
2014-07-10 13:18:07 +00:00
Dmitri Hrybenko
0e59dcac1f stdlib/Dictionary bridging: don't wrap NSDictionary in Dictionary<K, V> when
either K or V is bridged non-verbatim

rdar://17325454


Swift SVN r19807
2014-07-10 12:02:22 +00:00
Dmitri Hrybenko
febc98d5a4 stdlib/Dictionary: change internal bridging interfaces so that wrong code (that
does not copy NSDictionary) looks wrong


Swift SVN r19804
2014-07-10 09:45:42 +00:00
Chris Lattner
5b49d59c57 Remove the @ from @final and @lazy, the last major piece of
rdar://17168115.

Also, reinstate the ARM driver change and testcase that I removed
in my last patch.


Swift SVN r19790
2014-07-10 06:23:27 +00:00
Doug Gregor
2f3f6acf21 Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean
literals. Take "true" and "false" as real keywords (which is most of the
reason for the testsuite churn). Make Bool BooleanLiteralConvertible
and the default Boolean literal type, and ObjCBool
BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the
recent regression that made ObjCBool not work with true/false.


Swift SVN r19728
2014-07-09 16:57:35 +00:00
Dmitri Hrybenko
435a8ddf0c stdlib/Dictionary: copy the NSDictionary before wrapping it, so that
NSMutableDictionary and other mutable NSDictionary subclasses don't break
Dictionary's value semantics

rdar://17442261


Swift SVN r19726
2014-07-09 15:13:17 +00:00
Chris Lattner
02999cac51 Reinstate the @ on the @objc attribute. This is largely a revert of r19555 with a few tweaks.
Swift SVN r19706
2014-07-08 21:50:34 +00:00
Doug Gregor
e6a71b8363 Remove the implicit CFString -> String conversion
Swift SVN r19693
2014-07-08 20:07:49 +00:00
Doug Gregor
ed54826e1c Replace the implicit NSRange -> Range<Int> conversion with a toRange method
Swift SVN r19692
2014-07-08 20:05:09 +00:00
Doug Gregor
9e2b68c4f9 Introduce CGFloat as a distinct struct type.
CGFloat is 32-bit on 32-bit architectures and 64-bit on 64-bit
architectures for historical reasons. Rather than having it alias
either Float (32-bit) or Double (64-bit), introduce a distinct struct
type for CGFloat. CGFloat provides a complete set of comparisons and
arithmetic operators (including tgmath functions), initializers allows
explicit conversion between it an Int, UInt, Float, and Double, as
well as conforming to all of the protocols that Float/Double do.

This formulation of CGFloat makes use of CGFloat
architecture-independent, although it still requires a number of casts.
Fixes <rdar://problem/17224725>

Swift SVN r19689
2014-07-08 19:00:18 +00:00
Dmitri Hrybenko
95ac813af3 stdlib/Dictionary: coding style, comments, renamed type generic parameters
Swift SVN r19687
2014-07-08 16:48:11 +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
Enrico Granata
15b42fdfcd Move the Foundation-specific Mirrors in their own file. These are not as obviously boilerplate as other ones, so there is less to be saved, but Foundation.swift is an over-crowded file anyway
Swift SVN r19659
2014-07-08 00:56:55 +00:00