Commit Graph

431 Commits

Author SHA1 Message Date
Dave Abrahams
d4de1bf5e9 [stdlib] Propagate BooleanType docs to models
265 undocumented public APIs remain in core

Swift SVN r22207
2014-09-23 08:37:24 +00:00
Anna Zaks
505257ae9b API Notes: This contains audit for most of AppKit!
Plus, smaller enhancements on the other frameworks.
Removes the need for _PrintableNSObjectType hack (rdar://problem/16883288)

Swift SVN r22185
2014-09-22 21:47:22 +00:00
Ben Langmuir
531f31130d Add missing Security dependency
Foundation depends on Security, so now that we have an overlay for it we
need to build swiftSecurity first.

Swift SVN r22138
2014-09-19 16:48:49 +00:00
Dmitri Hrybenko
ea460fa713 Revert changes that I did not intend to commit
Swift SVN r22128
2014-09-19 14:08:50 +00:00
Dmitri Hrybenko
ae8c52969b StdlibUnittest: make testing return-autoreleased optimization reliable
On some platforms (for example, x86_64), the first call to
`objc_autoreleaseReturnValue` will always autorelease because it would
fail to verify the instruction sequence in the caller.  On x86_64
certain PLT entries would be still pointing to the resolver function,
and sniffing the call sequence would fail.

This change adds a "warmup" return-autoreleased sequence to the test
harness.

rdar://18385128

Swift SVN r22127
2014-09-19 14:06:57 +00:00
Doug Gregor
3ebf5cb3da Switch the string literal protocols over to initializer requirements.
Swift SVN r22076
2014-09-18 15:48:42 +00:00
Doug Gregor
d42563291e Switch DictionaryLiteralConvertible over to an initializer requirement.
Swift SVN r22033
2014-09-17 19:42:31 +00:00
Doug Gregor
3972316d25 Switch ArrayLiteralConvertible over to an initializer requirement.
Swift SVN r22024
2014-09-17 17:46:26 +00:00
Doug Gregor
6a19c1235e Convert FloatLiteralConvertible to initializers
Swift SVN r21992
2014-09-16 22:45:09 +00:00
Doug Gregor
4dca192b18 Switch IntegerLiteralConvertible over to initializers.
Swift SVN r21986
2014-09-16 21:59:15 +00:00
Doug Gregor
7f80e00d37 Swift NilLiteralConvertible to an initializer requirement
Swift SVN r21980
2014-09-16 20:43:35 +00:00
Doug Gregor
c1399cf229 Allow SDK overlays to add 'required' initializers.
Removes the initWithBool: hack from the Clang importer. We can now
express NSNumber's conformance to the BooleanLiteralConvertible
protocol in the overlay.

Swift SVN r21976
2014-09-16 17:09:58 +00:00
Dmitri Hrybenko
e6e17ac7d4 stdlib: replace _CocoaArrayType with _SwiftNSArrayRequiredOverridesType
Swift SVN r21972
2014-09-16 12:53:00 +00:00
Doug Gregor
d93eaed9f7 Switch BooleanLiteralConvertible over to an initializer requirement.
Conforming to BooleanLiteralConvertible now requires

  init(booleanLiteral: Bool)

rather than

  static func convertFromBooleanLiteral(value: Bool) -> Self

This posed a problem for NSNumber's conformance to
BooleanLiteralConvertible. A class needs a required initializer to
satisfy an initializer requirement, but one cannot add a required
initializer via an extension. To that end, we hack the Clang importer
to import NSNumber's initWithBool with the name

  init(booleanLiteral:)

and add back the expected init(bool:) initializer in the
overlay. These tricks make NSNumber even harder to subclass, but we
don't really care: it's nearly impossible to do well anyway, and is
generally a Bad Idea.

Part of rdar://problem/18154091.

Swift SVN r21961
2014-09-15 23:59:30 +00:00
Anna Zaks
22b4dcda36 Create an overlay for ALAssetsLibrary:enumerateGroupsWithTypes which accepts ALAssetsGroup types.
This is a case of type mismatch due to the parameter type not being a proper
NS_OPTIONS enum. However, it crashes at runtime on 32 bit, so let's introduce an
overlay while waiting for the proper fix.

Addresses radar://18201112

Swift SVN r21957
2014-09-15 22:10:51 +00:00
Anna Zaks
ec46eefb2f Overload dispatch_get_global_queue to work with QOS_CLASS.. constants
Addresses radar://18272350

Swift SVN r21956
2014-09-15 22:10:50 +00:00
Joe Groff
491e47cb83 Rename RawRepresentable.raw -> rawValue.
Per API review with Ali. While we're here, give the initializer a corresponding 'rawValue' argument label, and change the associated type name to RawValue to match.

Swift SVN r21888
2014-09-11 20:13:47 +00:00
Jordan Rose
d438ebc228 Sink Swift's adapter for NSZone into the ObjectiveC overlay.
While Foundation actually defines the NSZone typedef and what you can do with
it, the ObjectiveC module makes use of it in its raw form: "struct _NSZone *".
To avoid a circular dependency, sink our adapter down to the ObjectiveC
overlay.

Swift SVN r21827
2014-09-10 02:32:52 +00:00
Anna Zaks
122ea9dc92 Add overlay cover for dispatch_data_empty
Swift SVN r21821
2014-09-10 00:50:43 +00:00
Anna Zaks
7be3363210 Reapply Swift Overlay: Make most common security return codes work with OSStatus
This reverts commit 043dbaafa20f3a1bbb1c71cd748a651ad57ba7b4.

Swift SVN r21794
2014-09-09 01:47:03 +00:00
Joe Groff
419ba5cbea Change RawRepresentable to use failable initializers and property requirements.
Redefine the RawRepresentable protocol to use an 'init?' method instead of 'fromRaw(Raw)', and a 'raw' get-only property instead of 'toRaw()'. Update the compiler to support deriving conformances for enums and option sets with the new protocol. rdar://problem/18216832

Swift SVN r21762
2014-09-06 18:40:14 +00:00
Anna Zaks
ecf471bbff Revert "Swift Overlay: Make most common security return codes work with OSStatus"
This is causing buildbot breakage while building the Security library.

Swift SVN r21761
2014-09-06 05:30:23 +00:00
Anna Zaks
d51c1736f0 Swift Overlay: Make most common security return codes work with OSStatus
Swift SVN r21759
2014-09-06 00:46:21 +00:00
Anna Zaks
412d59009c CGVector initializers should have named parameters.
This ensures they are consistent with other types like CGPoint.

Swift SVN r21758
2014-09-06 00:46:19 +00:00
Dmitri Hrybenko
2f15883283 stdlib/NSString APIs: fix indentation
Swift SVN r21713
2014-09-04 18:06:37 +00:00
Doug Gregor
eaefb5e2b0 String's NSString API: Replace factory methods with failable initializers.
Addresses rdar://problem/18225788.


Swift SVN r21710
2014-09-04 17:21:33 +00:00
Doug Gregor
692ff2f52a Enable imports of failable initializers by default.
Swift SVN r21699
2014-09-04 06:32:12 +00:00
Dmitri Hrybenko
60cf5d3d1b SwiftIntTypes.py: remove transitional '_new' suffix from a function name
Swift SVN r21579
2014-08-29 15:38:22 +00:00
Dmitri Hrybenko
cb9e5c2c86 stdlib: use simpler interface to iterate over integer types
Swift SVN r21573
2014-08-29 14:32:46 +00:00
Enrico Granata
b3f6219ebe Add a very rough mutual exclusion mechanism to prevent a UIView from trying to provide its QuickLook object recursively. The same logic used for NSView is also used here basically verbatim. This is because in playgrounds, you can get a view to log itself as part of its drawRect method due to the way we defined our instrumentation. This very simple mechanism only works because drawing can only happen on the main thread - otherwise, we'd need something smarter than an NSSet of UIView pointers. Fixes rdar://17895769
Swift SVN r21444
2014-08-25 21:11:18 +00:00
Dmitri Hrybenko
1a5e9b486c Restore building SpriteKit overlay that I accidentally disabled
Swift SVN r21438
2014-08-25 16:12:33 +00:00
Dmitri Hrybenko
ea48185358 stdlib: don't silently truncate Float80 literals
We used to first truncate them to Float64, and then construct a Float80.

Swift SVN r21433
2014-08-25 13:21:54 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Doug Gregor
d603db43f2 Make factory methods unavailable when there is already a corresponding initializer.
Depending on visitation order, we would occasionally leave the factory
method available if we had completely imported the initializer
first. Fixes <rdar://problem/17261609>.

Swift SVN r21361
2014-08-21 16:45:17 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Doug Gregor
ebf4c1e5ca Allow "return nil" in a failable initializer to initiate failure.
Basic semantic analysis only; AST to follow.

Swift SVN r21309
2014-08-20 17:22:34 +00:00
Dmitri Hrybenko
a64dceed58 stdlib: remove a stale FIXME, '!= nil' is now required to test Optionals for
the presence of a value


Swift SVN r21230
2014-08-15 10:19:54 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Greg Parker
5a71cacec3 Remove nib-lookup hacks from UIViewController. Fixes rdar://17327189.
Swift SVN r21183
2014-08-13 20:57:55 +00:00
Anna Zaks
c519ecfe4f API Notes File: The product of the 2d nullability audit of Foundation.
As well as the required test/stdlib modifications.

Swift SVN r21181
2014-08-13 19:39:59 +00:00
Doug Gregor
8df878c02a Give CGRect/CGSize/CGVector initializers that take Doubles.
Now that CGFloat is its own distinct type, it's useful to have Double
initializers to go along with the Int initializers we added a while
back <rdar://problem/17224725>.

Swift SVN r21156
2014-08-12 21:54:50 +00:00
Doug Gregor
916e9a7eb5 Fix computation of “favored” constraints for binary expressions <rdar://problem/17943223>.
The determination of “favored” constraints for binary expressions was comparing the second argument to the first parameter to decide if the constraint is favored. Coupled with implicit bridging conversions through NSNumber, this meant that “1.0/10” would become Int when Foundation was imported, and hilarity ensued.

Fix the heuristic for favored constraints, tidy up this code a bit, and add ==(NSString, NSString) to cope with the ambiguity this creates.

Swift SVN r21154
2014-08-12 21:16:59 +00:00
Chris Hanson
b644ff5888 XCTAssert(true, "Pass") crashes in Swift
Instead of trying to bridge NSDictionary to [String:String], XCTest needs to
just request the objects from the NSDictionary as String.

Also, move the unwrapping of the optional from the might-throw block such that
it only happens when the block hasn't thrown. Unwrapping the optional if the
block has thrown would crash, because the optional would still be unset.

Addresses <rdar://problem/17952584>.

Swift SVN r21119
2014-08-08 22:51:30 +00:00
Anna Zaks
95d7e655ee Proactively, ensure that the overlay works with NSDictionary::objectForKey: optional return type.
Swift SVN r21117
2014-08-08 22:22:25 +00:00
Dmitri Hrybenko
6f20c51e3e stdlib: fix crashes in CGPoint, CGSize, CGRect mirrors
rdar://17933906


Swift SVN r21091
2014-08-07 15:59:24 +00:00
Jordan Rose
73cce9702e [CMake] Remove the CMakeLists file from apinotes/.
Also, move the ObjectiveC overlay into its own directory, so that we can
use the directory name as an indicator of what overlays exist.

This is in preparation for DevPubs providing the contents of the apinotes/
directory. The downside here is that adding new apinotes files doesn't
automatically trigger a rebuild; I intend to mitigate that somewhat by at
least triggering one when the revision number of the DevPubs repo changes.

Swift SVN r21078
2014-08-06 23:07:24 +00:00
Dmitri Hrybenko
8c41e1892b stdlib/NSString APIs on String: change stringByRemovingPercentEncoding property
type to be an optional string; add tests


Swift SVN r21021
2014-08-04 18:02:14 +00:00
Dmitri Hrybenko
67de904c15 stdlib/NSString APIs on String: change stringByAppendingPathExtension() to
return an optional String.  This behavior is not documeted, though.


Swift SVN r21016
2014-08-04 16:41:37 +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
edc664c36f stdlib/NSString APIs on String: change return type of
stringByAddingPercentEncodingWithAllowedCharacters() and
stringByAddingPercentEscapesUsingEncoding() to String?, and add API notes for
NSString to the same effect


Swift SVN r21007
2014-08-04 14:13:46 +00:00