Commit Graph

455 Commits

Author SHA1 Message Date
Arnold Schwaighofer
da6d9152b6 Differentiate between user assertion and preconditions and the like
assert() and fatalError()
These functions are meant to be used in user code. They are enabled in debug
mode and disabled in release or fast mode.

_precondition() and _preconditionFailure()
These functions are meant to be used in library code to check preconditions at
the api boundry. They are enabled in debug mode (with a verbose message) and
release mode (trap). In fast mode they are disabled.

_debugPrecondition() and _debugPreconditionFailure()
These functions are meant to be used in library code to check preconditions that
are not neccesarily comprehensive for safety (UnsafePointer can be null or an
invalid pointer but we can't check both). They are enabled only in debug mode.

_sanityCheck() and _fatalError()
These are meant to be used for internal consistency checks. They are only
enabled when the library is build with -DSWIFT_STDLIB_INTERNAL_CHECKS=ON.

I modified the code in the standard library to the best of my judgement.

rdar://16477198

Swift SVN r18212
2014-05-16 20:49:54 +00:00
Dmitri Hrybenko
828acd2738 stdlib: hide _NSSwiftArray, _NSSwiftDictionary, _NSSwiftEnumerator
Swift SVN r18187
2014-05-16 08:29:17 +00:00
Doug Gregor
b756fc29ec Don't require paretheses when mixing optional types and array types...
... unless we actually hit one of the confusing cases involving
multi-dimensional arrays (e.g., Int[]?[]), at which point one needs to
write parentheses <rdar://problem/16737035>.



Swift SVN r18181
2014-05-16 06:03:26 +00:00
Ted Kremenek
4bb475a1c8 Rename UnsafePointer.get/set to a "ptr.pointee" property.
Implements <rdar://problem/16531067>.

Swift SVN r18178
2014-05-16 05:48:05 +00:00
Doug Gregor
ad18ed81fb Start importing NSArray* as (AnyObject[])! by default <rdar://problem/16535097>.
Swift SVN r18157
2014-05-16 01:10:13 +00:00
Greg Parker
3b0e45b497 Fix -[NSUndoManager prepareWithInvocationTarget:].
This method returns a proxy object. Swift cannot current cast proxy objects 
to their proxied types. The workaround for now is to add a generic overlay 
for -prepareWithInvocationTarget: so the declared type of the returned 
proxy is the proxied type. This is good enough to make undo proxies work with 
objc-dispatched calls.


Swift SVN r18155
2014-05-16 01:07:22 +00:00
Jordan Rose
3f782ceed3 Drop QuartzCore overlay.
The code is incorrect and depends on functions introduced in this year's OSs.
Additionally, CoreImage is a top-level framework on iOS, so we have to be
more careful if/when we add this back.

Swift SVN r18135
2014-05-15 22:59:15 +00:00
Fariborz Jahanian
ee401b6ed5 Fixes a typo.
Swift SVN r18134
2014-05-15 22:52:27 +00:00
Jordan Rose
6f8dbe907d [CMake] QuartzCore depends on Foundation.
Swift SVN r18130
2014-05-15 22:03:27 +00:00
Fariborz Jahanian
6635feb32b Provide sdk vararg overlays for CIFilter and
CISampler per rdar://16726822
(also removed a comment in Foundation.swift).


Swift SVN r18123
2014-05-15 20:13:55 +00:00
Doug Gregor
01f3f7777e Make _convertNSArrayToArray work for non-verbatim bridged types.
The runtime diagnostics here are awful, but the monkey dances
<rdar://problem/16899681>.



Swift SVN r18121
2014-05-15 19:25:58 +00:00
Joe Pamer
a74c44a6e4 Fix two crashing bugs related to checked downcasts - rdar://problem/16093456 and rdar://problem/16892211.
Swift SVN r18118
2014-05-15 18:36:44 +00:00
Dmitri Hrybenko
acb7465f4b stdlib: underscore-prefix NSContiguousString and NSOpaqueString
Swift SVN r18114
2014-05-15 18:02:30 +00:00
Dmitri Hrybenko
d50a8b476d stdlib/Foundation overlay: add Printable conformance to Selector
rdar://16897592


Swift SVN r18109
2014-05-15 17:25:43 +00:00
Dmitri Hrybenko
8ee468e974 stdlib/Foundation overlay: add Printable conformance to ObjCBool
rdar://16897579


Swift SVN r18108
2014-05-15 17:02:40 +00:00
Dmitri Hrybenko
f183e493bf stdlib/bridging: bridgeFromObjectiveC() can fail to bridge the Objective-C
object to the desired type.  Model this with an optional return type.


Swift SVN r18077
2014-05-14 19:49:22 +00:00
Dave Abrahams
aceb11edb1 [stdlib] bridgeFromObjectiveC for String
Seemed pretty obvious so I just did it.

Swift SVN r18073
2014-05-14 16:44:49 +00:00
Dave Abrahams
a8bbc4c89b [stdlib] String internal API review changes
I had to XFAIL test/ClangModules/cf.swift, which is failing for reasons
I can't understand.  <rdar://problem/16911496>

Swift SVN r18071
2014-05-14 14:18:52 +00:00
Dmitri Hrybenko
eb9c3a406d stdlib/runtime: implement bridgeFromObjectiveC()
Swift SVN r18070
2014-05-14 13:40:46 +00:00
Ted Kremenek
9eea282719 Switch range operators ".." and "...".
- 1..3 now means 1,2
- 1...3 now means 1,2,3

Implements <rdar://problem/16839891>

Swift SVN r18066
2014-05-14 07:36:00 +00:00
Enrico Granata
8478cd9905 Add a mirror for NSSet
Part of the playgrounds effort



Swift SVN r18038
2014-05-13 23:20:32 +00:00
Doug Gregor
d5a9c2ab94 Only supersede initializers with other imported initializers when the types match.
This fixes a case where the Swift-variadic and C-varargs versions of
various initializers were superseding each other
<rdar://problem/16801456>.

It also uncovered some more cases where we weren't getting quite the
right semantics for factory-methods-as-initializers, which are also
fixed here.

Swift SVN r18010
2014-05-13 16:49:39 +00:00
Dmitri Hrybenko
de9a0c8ff0 stdlib/printing: remove ReplPrintable protocol
It is replaced by debugPrint() family of functions, that are called by REPL.

There is a regression in printing types that don't conform to Printable, this
is tracked by rdar://16898708


Swift SVN r18006
2014-05-13 16:22:56 +00:00
Dmitri Hrybenko
2cc8fe40d4 stdlib/printing: replace four printing systems with one new one
The old ones were:

- print/println
- printAny
- printf
- Console

The new printing story is just print/println.  Every object can be printed.
You can customize the way it is printed by adopting Printable protocol.  Full
details in comments inside stdlib/core/OutputStream.swift.

Printing is not completely finished yet.  We still have ReplPrintable, which
should be removed, string interpolation still uses String constructors, and
printing objects that don't conform to Printable will result in printing
mangled names.


Swift SVN r18001
2014-05-13 13:07:59 +00:00
Doug Gregor
795f568898 Start diagnosing the use of '`' rather than '#', with a Fix-It.
<rdar://problem/16891828>.

Swift SVN r17982
2014-05-13 00:03:05 +00:00
Doug Gregor
1efd9fba5b Start accepting '#' in addition to '`' to mark a keyword argument <rdar://problem/16891828>.
Update the standard library, tests, diagnostics, and Fix-Its.

Swift SVN r17981
2014-05-13 00:03:04 +00:00
Doug Gregor
93f7ac2e48 Fix the name of the initializer for initWithObjectsAndKeys.
Swift SVN r17974
2014-05-12 23:21:44 +00:00
Doug Gregor
73528dc0e0 Enable importing factory methods as initializers by default.
Finishes <rdar://problem/16509024>.

Swift SVN r17972
2014-05-12 23:01:20 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Jordan Rose
d410bd0acd [CMake] Re-enable -autolink-force-load to cause the buildbot to fail.
I can't reproduce this locally, so I'll need to run this on the buildbot
and inspect the output.

Swift SVN r17795
2014-05-09 19:11:11 +00:00
Greg Parker
fba2e4bd7c Add overlay covers for DISPATCH_QUEUE_CONCURRENT and DISPATCH_SOURCE_TYPE_*.
Swift SVN r17766
2014-05-09 07:06:10 +00:00
Argyrios Kyrtzidis
786ab593dd Revert "[CMake] Build the SDK overlays with -autolink-force-load."
This reverts commit r17752, because it caused link failures of Interpreter and stdlib tests.

Swift SVN r17758
2014-05-09 04:02:54 +00:00
Jordan Rose
20fb4513e2 [CMake] Fix dependencies for swiftDispatch.
Without proper dependencies among the overlays, we may try to load an
outdated overlay module while building another overlay.

Swift SVN r17753
2014-05-09 01:20:34 +00:00
Jordan Rose
90c5fbe029 [CMake] Build the SDK overlays with -autolink-force-load.
Final part of <rdar://problem/16829587>

Swift SVN r17752
2014-05-09 01:20:33 +00:00
Argyrios Kyrtzidis
4f0776936a [stdlib] Dispatch depends on Darwin.
Swift SVN r17749
2014-05-09 01:04:44 +00:00
Greg Parker
f1d020e11a <rdar://16848707> Add Dispatch overlay with covers for some libdispatch macros.
Swift SVN r17693
2014-05-08 09:47:00 +00:00
Ted Kremenek
05e9efb093 Don't compile XCTest overlay as being Application Extension safe.
Swift SVN r17682
2014-05-08 04:49:00 +00:00
Ted Kremenek
3d248270ca Add prototype for KVO API overlay ("KVOContext") to NSObject, and provide test case.
This change adds a new variant of "addObserver:forKeyPath:options:context:"
that takes a "KVOContext" instead of an unsafe void*.  The variant
delegates to the original method, but first 'retain's the object
before turning it into an unsafe pointer.  The API is then matched
with a variant of 'removeObserver:forKeyPath:context:' which
delegates to the original method and then 'release's it.

This vision here is that Swift clients of this API will use this
variant, and not the unsafe one.  A refinement (later) is to
not expose the original methods at all, and provide a new method
'observeValueForKeyPath:ofObject:change:kvoContext:' that implements
a thunk that delegates to 'observeValueForKeyPath:ofObject:change:context:'
and does the void* cast (which the code in the test case does).

This needs to go through API review; names are strawman names.

Swift SVN r17325
2014-05-03 20:06:28 +00:00
Joe Groff
5ea0a0734e UIKit overlay: Add our own designated initializers for UIActionSheet and UIAlertView.
The true designated initializers take a variadic argument, which we can't directly support in Swift, so we'll map those definitions to refer to versions that drop the variadic parameters altogether, and reimplement the variadic interface in the overlay.

Swift SVN r16711
2014-04-23 19:52:39 +00:00
Argyrios Kyrtzidis
65971bc7f4 [CMake] ObjectiveC module depends on the Darwin one.
Swift SVN r16675
2014-04-22 23:48:26 +00:00
Dmitri Hrybenko
b94b1bcc65 Un-disable XCTest build that I accidentally disabled
Swift SVN r16202
2014-04-11 06:33:01 +00:00
Dmitri Hrybenko
110f85bc16 Move @exported to use new attribute infrastructure
Swift SVN r16158
2014-04-10 13:35:35 +00:00
Dave Zarzycki
d5452d84c4 SDK Overlay: Add Darwin overlay
Swift SVN r16140
2014-04-10 00:04:03 +00:00
Dmitri Hrybenko
98c429ee2b Untabify
Swift SVN r16104
2014-04-09 07:28:59 +00:00
Chris Hanson
8ff35e9c23 Check for a proper XCTest.framework in the platform
Check whether the XCTest.framework in the platform has headers before deciding whether to look there or in the SDK for it.

Swift SVN r16084
2014-04-08 23:55:34 +00:00
Chris Hanson
0e2e76ad03 Start building XCTest overlay for all platforms again.
Swift SVN r16083
2014-04-08 23:55:33 +00:00
Greg Parker
0275393c6d [stdlib] Add a CoreGraphics overlay with additions to CGPoint/CGSize/CGRect.
Swift SVN r16029
2014-04-07 22:54:14 +00:00
Doug Gregor
ba67a09362 Allow one to disable building the XCTest overlay via the CMake option SWIFT_BUILD_XCTEST.
Swift SVN r15922
2014-04-04 04:07:03 +00:00
Chris Hanson
42f36febd6 Build the XCTest overlay only for OS X for now.
Once the iOS pieces are in place we'll re-enable building for all platforms.

Swift SVN r15918
2014-04-04 02:50:25 +00:00
Chris Hanson
190c5c8477 Implement an XCTest overlay with basic assertions
Adds an overlay for Xcode's XCTest testing framework.

It implements most of the familiar test assertion macros as equivalent
Swift functions. The assertion macros that aren't currently implemented
are only those that deal specifically with floating-point equality and
Objective-C exceptions. Additionally, the implemented assertions don't
currently handle Objective-C exceptions thrown out of some code called
during an assertion as test failures.

Swift SVN r15917
2014-04-04 01:55:08 +00:00