Commit Graph

455 Commits

Author SHA1 Message Date
Dave Abrahams
94965036d5 [stdlib] Move ObjC Mirrors out of Foundation
These mirrors are the default mirrors that get used for all objective-C
object, including some that aren't defined in Foundation:

  import Dispatch
  println(dispatch_get_global_queue(0,0))

This example isn't fixed yet, because we need to pull all the string
bridging goop out of Foundation and into the core standard library.

Swift SVN r25012
2015-02-05 19:18:33 +00:00
Dave Abrahams
97ec182ba7 [stdlib] Move String bridging into Core stdlib
This change allows us to drop an egregious table-of-function-pointers
hack in favor of a much cleaner hack using SwiftShims.  It also allows
us to move the ObjC mirrors out of Foundation in an upcoming commit.

Swift SVN r25011
2015-02-05 19:18:32 +00:00
Maxwell Swadling
2eb96bafee [stdlib] reverted removal of mixed string type operators
Fixes rdar://problem/19656287

This reverts changes from r24931, r24911, r24760 and r24536.

Swift SVN r24938
2015-02-04 04:01:32 +00:00
Maxwell Swadling
a0cad601e1 [stdlib] removed mixed string type operators
Fixes rdar://problem/19656287

Swift SVN r24931
2015-02-04 00:56:36 +00:00
Maxwell Swadling
56026ee9f1 [stdlib] fixed ambiguous overloads
This fixes rdar://problem/19656287. This is a work around while we do
not have a way to remove implicit bridging conversions.
This means comparing a String and an NSString will use NSString
comparison.

Swift SVN r24911
2015-02-03 00:54:19 +00:00
Dave Abrahams
0d383f28a9 [stdlib] CGFloat : CVarArgType
Along the way, had to generalize the mechanism for detecting that a type
is handled as a Double by C's varargs.

Swift SVN r24859
2015-01-30 23:23:57 +00:00
Dmitri Hrybenko
1ca5bc414e stdlib: add an overlay for AudioBufferList
AudioBufferList contains a fake flexible array member, and is not
imported in a useable way.

rdar://18536929

Swift SVN r24843
2015-01-30 04:17:49 +00:00
Dmitri Hrybenko
6a9f1561eb CMake: sort directories
Swift SVN r24842
2015-01-30 04:17:47 +00:00
Maxwell Swadling
6cea1939e2 removed @transparent from unavailable functions
Swift SVN r24760
2015-01-27 22:18:37 +00:00
Enrico Granata
beedb4aa7a Only remove the view from the set of views that are being Mirror-drawn when you're actually done reflecting on it
The previous code would always remove the view on exit, even if it had not previously added it (default: case of the switch)

In simple cases, this didn't really matter, but if you caused the logger to be reinvoked on self in a loop, then you would end up removing the view before you were done looping over it, and eventually run out of stack space

Fixes rdar://19558026



Swift SVN r24737
2015-01-26 22:45:47 +00:00
Dave Abrahams
492c01e20c [stdlib] allow construction of UTF16Index from Int
...when Foundation is loaded.  Also, doc comments for its
RandomAccessIndexType conformance

Swift SVN r24637
2015-01-22 17:34:16 +00:00
Anna Zaks
c2a7613612 [API Notes] Address outstanding nullability issues + new audited pieces
<rdar://problem/17902944> UIView's motionEffects property should never return 'nil'
<rdar://problem/17971360> [factor-init] SKPhysicsJointPin's factory method is not converted to a Swift API initializer
<rdar://problem/18553910> #IUO UICollectionViewUpdateItem properties
<rdar://problem/18875692> NSEntityDescription subentities/subentitiesByName should be marked optional
<rdar://problem/18919879> Swift: NSTableView's preparedCellAtColumn(_:row:) should return an optional
<rdar://problem/18940072> NSPredicate's init(format:) should not be optional
<rdar://problem/18987481> NSURLRequest without NSURL crashes Swift
<rdar://problem/19034448> UIPrintInfo’s -init is banned, should use +printInfo
<rdar://problem/19147412> NSUserInterfaceItemIdentification declares identifier as a non-optional String and it should be optional or IUO
<rdar://problem/19347931> Declaration of a parameter in Cocoa API in Swift is wrong (NSDateFormatter)
+ additions to the WatchKit audit

+ additions to HealthKit and HomeKit.

Swift SVN r24630
2015-01-22 03:29:07 +00:00
Dave Abrahams
0473b79c28 [stdlib] Let Cocoa slice its own strings
Creating _NSOpaqueString offered dubious benefits, especially in the
presence of tagged pointer strings.

Swift SVN r24612
2015-01-21 21:32:12 +00:00
Maxwell Swadling
661fde2ca6 [stdlib] removed ambiguous String comparison overloads
Fixes rdar://problem/19169066

Now that some implicit bridging conversions were removed, we can remove some of
the complex String comparison overloads. We could not remove all of them yet, as
String to NSString implicit bridging still exists. To work around this,
unavailable annotations were used. This ensures the user always gets the String
comparison function they intended.

Swift SVN r24536
2015-01-19 23:18:07 +00:00
Dmitri Hrybenko
753de15e99 stdlib: simplify code
Swift SVN r24503
2015-01-19 06:52:12 +00:00
Chris Willmore
68dd563fbf <rdar://problem/18311362> TLF: Eliminate implicit bridging conversions
Require 'as' when converting from Objective-C type to native type (but
continue to allow implicit conversion from native to Objective-C). This
conversion constraint is called ExplicitConversion; all implicit
conversions are covered by the existing Conversion constraint. Update
standard library and tests to match.

Swift SVN r24496
2015-01-18 00:07:45 +00:00
Maxwell Swadling
754122f601 [stdlib] Fixed bug in NSIndexSet for empty sets
Swift SVN r24331
2015-01-09 23:13:26 +00:00
Maxwell Swadling
7668402747 [stdlib] added SequenceType to NSIndexSet
Fixes rdar://problem/17799474

Swift SVN r24329
2015-01-09 22:55:25 +00:00
Chris Willmore
03a6190a1f <rdar://problem/19031957> Change failable casts from "as" to "as!"
Previously the "as" keyword could either represent coercion or or forced
downcasting. This change separates the two notions. "as" now only means
type conversion, while the new "as!" operator is used to perform forced
downcasting. If a program uses "as" where "as!" is called for, we emit a
diagnostic and fixit.

Internally, this change removes the UnresolvedCheckedCastExpr class, in
favor of directly instantiating CoerceExpr when parsing the "as"
operator, and ForcedCheckedCastExpr when parsing the "as!" operator.

Swift SVN r24253
2015-01-08 00:33:59 +00:00
Chris Lattner
3e41339cb2 rename @__noescape to @noescape, now that it is a generally visible feature,
wrapping up rdar://16323038.  Pieces still remaining are a Clang attribute+
importer support for it, plus adoption in the stdlib (tracked by other radars).


Swift SVN r24223
2015-01-06 22:54:25 +00:00
Chris Lattner
cc68e77f9a adopt @__noescape in a couple of places. This isn't required today, but if/when
@autoclosure starts implying noescape, it will be needed to indicate that the 
autoclosure isn't actually escaped.




Swift SVN r24212
2015-01-06 06:37:49 +00:00
Dmitri Hrybenko
ce9f5887b7 Revert "adopt @__noescape in various places in the stdlib, making sure to cover all of the "
This reverts commit r24141, it broke tests:

Failing Tests (2):
    Swift :: parser/parse_stdlib.sil
    Swift :: stdlib/AssertDiagnostics.swift

Swift SVN r24147
2014-12-24 05:51:51 +00:00
Chris Lattner
a86c7902ae adopt @__noescape in various places in the stdlib, making sure to cover all of the
@transparent functions that take a closure.  NFC since these always get inlined
at the moment anyway.



Swift SVN r24141
2014-12-24 01:30:00 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
Dave Abrahams
f78b6b125a [stdlib] Conversions to String.Index
Also, hide an initializer on String.Index that was unintentionally
public/visible by giving it an underscored keyword argument.

Testing comes next.

Swift SVN r24069
2014-12-22 15:30:56 +00:00
Dmitri Hrybenko
4f819a9cf7 Remove an NSSet.copyObjectPointers() API that was unintentionally added
Swift SVN r24054
2014-12-20 03:01:34 +00:00
Chris Lattner
b8596ffccb move the stdlib to the new syntax for @autoclosure attribute.
Swift SVN r24048
2014-12-20 00:16:36 +00:00
Dave Abrahams
39efbb5e17 [stdlib] Add a comment
Swift SVN r23948
2014-12-15 22:24:30 +00:00
Dmitri Hrybenko
e87bcff79d stdlib: move String.{lowercaseString,uppercaseString} to the core
library

Swift SVN r23936
2014-12-15 09:47:03 +00:00
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Dave Abrahams
9550c02956 [stdlib] String.UTF16View.Index is bidirectional
Rather than expose random access on String.UTF16View to all Swift users,
expose it only when Foundation is loaded.  This effectively decouples
String from a UTF16 representation on non-Mac platforms.

Swift SVN r23929
2014-12-14 17:11:04 +00:00
Joe Groff
cf49e3be1e Fix multi-SDK build for GLKit.
Swift SVN r23898
2014-12-12 22:32:18 +00:00
Joe Groff
a60ae8b8e3 stdlib GLKit overlay: Tweak for better consistency with C interface.
GLKVector2 doesn't have 'r' or 'g' components, unlike the longer vector types, and GLKQuaternion has 'x', 'y', 'z', and 'w' components. Thanks Jordan for pointing these out.

Swift SVN r23895
2014-12-12 21:23:12 +00:00
Joe Groff
1c1535fbcb stdlib: Add an overlay to GLKit with projection accessors.
We can access pretty much all of the GLKit functions now, but still lacked accessors for the individual elements. gyb up some accessors to do dirty bitcasting tricks to expose the elements of GLKVectorN, GLKMatrixN, and GLKQuaternion values.

Swift SVN r23892
2014-12-12 19:19:31 +00:00
Maxwell Swadling
c889977b52 [stdlib] Makes NSSet and NSOrderedSet ArrayLiteralConvertible
Fixes rdar://problem/14661748
Also adds missing SequenceType to NSOrderedSet

Swift SVN r23863
2014-12-11 19:11:37 +00:00
Maxwell Swadling
74aa8b1a3c [stdlib] added safe unchecked comment
Swift SVN r23862
2014-12-11 18:52:21 +00:00
Maxwell Swadling
528661c212 [stdlib] Removed checks in {lower,upper}caseStirng
Swift SVN r23747
2014-12-06 00:01:13 +00:00
Maxwell Swadling
5d01edbb90 [stdlib] clarified comments for ASCII case tables
Swift SVN r23738
2014-12-05 17:47:47 +00:00
Joe Groff
e6d97e8de7 Clang importer: Add a zeroing default initializer to imported structs.
If an imported C struct has no __nonnull pointer fields, then we can give a default initializer that zeroes all of its fields. This becomes a requirement when working with partially-imported types like NSDecimal. NSDecimal has bitfields Swift can't see yet, so it's impossible to DI, but the Foundation functions that work with NSDecimal all emit their result by out parameter, and without access to its fields it is impossible to initialize an NSDecimal for use with one of these functions. Implement the initializer using a builtin that gets lowered by IRGen; this is also made necessary by the fact that Swift has only a partial view of the struct, so we can't form a complete zero initializer until we have the definitive type layout from Clang.

Swift SVN r23727
2014-12-05 05:31:22 +00:00
Maxwell Swadling
77cd08d3ae [stdlib] removed branch in ASCII {upper,lower}casestring
Swift SVN r23706
2014-12-05 00:24:38 +00:00
David Farler
e7506e8eab Remove underscore from _Set<T>
rdar://problem/19132138

Make Set<T> visible by removing the underscore. Also, remove the pesky
${_Self} gyb variable that was for a temporary convenience in hiding Set.

Swift SVN r23699
2014-12-05 00:21:35 +00:00
Maxwell Swadling
1e4b0393f7 [stdlib] Added NSEnumerator to SequenceType
Fixes rdar://problem/17925006

Swift SVN r23497
2014-11-21 00:33:26 +00:00
Maxwell Swadling
530ae1777a Added ASCII fast paths for common string operations
- ==, <, lowercaseString and uppercaseString on String now have ASCII fast paths
- Fixes rdar://problem/17962640

Swift SVN r23494
2014-11-21 00:07:32 +00:00
Maxwell Swadling
d5c6534b1c Removed unnecessary unsafeBitCast
Swift SVN r23386
2014-11-17 21:35:33 +00:00
David Farler
d0718c69fc Prefix Set<T> with underscore for API development
Swift SVN r23263
2014-11-12 07:07:01 +00:00
David Farler
c453eb4c48 Add Set type.
<rdar://problem/14661754> TLF: [data-structure] Set<T> data type + Bridging from NSSet

Swift SVN r23262
2014-11-12 07:07:00 +00:00
Dmitri Hrybenko
75876f531a XCTest: silence the warning about accessing a property that is not declared
Patch by Chris Hanson.

Swift SVN r23248
2014-11-11 22:19:48 +00:00
Maxwell Swadling
e7995d2946 [stdlib] simplified implementation of init(objects elements: AnyObject...)
Swift SVN r23217
2014-11-11 00:24:23 +00:00
Doug Gregor
3df2c11c8a Diagnose Objective-C method overrides not reflected as Swift overrides.
Diagnose cases where the use of @objc will produce Objective-C methods
that end up overriding an Objective-C method in a superclass, when
that override is not properly represented as an override in the Swift
type system. This can happen when the Objective-C methods are produced
by different kinds of entities. For example:

  class Super {
    @objc var property: Int
  }

  class Sub : Super {
    @objc func setProperty(property: Int) { }
  }

In Swift, Sub.setProperty and Super.property are completely
unrelated. However, both produce an Objective-C instance method with
the selector "setProperty:", so we end up with unexpected overriding
behavior. Diagnose this whenever it occurs, regardless of the kind of
@objc entity that produced the Objective-C methods: initializers,
deinitializers, methods, properties, or subscripts.

Implements the rest of the intended functionality of
rdar://problem/18391046, with the caveat that there are two remaining
classes of bugs:
  1) Superclasses defined in a module (or imported from a Clang
  module) aren't handled properly yet; we might not see those methods.
  2) We won't properly detect all of these failures when the methods
  are scattered across different source files in the same module.

Swift SVN r23170
2014-11-08 00:55:45 +00:00
Chris Willmore
2c3e5d0073 Add missing keyword argument following changes for rdar://problem/18778670
Swift SVN r23095
2014-11-04 03:55:22 +00:00