Commit Graph

21665 Commits

Author SHA1 Message Date
Dmitri Hrybenko
d213355030 stdlib/Dictionary: address internal API review
Add 'removeObjectForKey:'


Swift SVN r18265
2014-05-17 19:47:48 +00:00
Joe Groff
0540da70e2 Replace an 'as T' hack with a 'reinterpretCast' hack.
The runtime implementation of 'as T' freaks out in cases involving protocols. This is an expedient workaround that fixes <rdar://problem/16950035>.

Swift SVN r18263
2014-05-17 19:23:52 +00:00
Dmitri Hrybenko
a4d9dcf1a7 stdlib: extinguish \brief and \c
Swift SVN r18261
2014-05-17 18:10:51 +00:00
Dmitri Hrybenko
5c453ce2bc stdlib/Dictionary: add tests for trapping during bridging a Dictionary
whose KeyType is not NSCopyable

Swift SVN r18259
2014-05-17 17:24:58 +00:00
Dmitri Hrybenko
6808737952 stdlib/CString printing: fix a null dereference in writeTo, similar to one that
was fixed in debugDescription


Swift SVN r18258
2014-05-17 17:15:52 +00:00
Doug Gregor
bed81488c1 Revert r18232, r18220: we're not doing T* now.
Swift SVN r18250
2014-05-17 16:36:02 +00:00
Dave Abrahams
d6e4964ace [stdlib] Make _convertNSArrayToArray meet spec
I believe this correctly implements the "forced conversion" part of the
Arrays.rst document.

Swift SVN r18248
2014-05-17 14:08:33 +00:00
Dave Abrahams
2fc6414b5d [stdlib/Array] Improve another comment
Swift SVN r18245
2014-05-17 06:25:56 +00:00
Dave Abrahams
6b0c79a0f2 [stdlib/Array] Eliminate or label unused functions
Swift SVN r18244
2014-05-17 06:25:56 +00:00
Dave Abrahams
129e550fcb [stdlib/Array] Add deferred typechecking
When an NSArray is force-downcast to T[] at an API boundary, we need to
remember that each element needs to be dynamically checked when
accessed.  No deferred casts are being generated yet, so NFC

Swift SVN r18243
2014-05-17 05:56:56 +00:00
Dave Abrahams
3e8eb46f58 [stdlib] Improve comments and a name
Swift SVN r18242
2014-05-17 05:56:55 +00:00
Dave Abrahams
175f7400eb [stdlib] delete unwanted FIXME
Turns out we really want to use reinterpretCast when we know it will
work, rather than a checked downcast + forced optional unwrapping.  The
latter will only be as fast as the former in -Ofast

Swift SVN r18241
2014-05-17 05:33:27 +00:00
Dave Abrahams
f57c2b8e47 [stdlib] Remove unused functions
Swift SVN r18240
2014-05-17 05:33:26 +00:00
Dave Abrahams
3dc699ee0d [stdlib] Remove asNSArray; it's obsolete
Swift SVN r18239
2014-05-17 05:33:26 +00:00
Dave Abrahams
89be40afb3 [stdlib] line length fix
Swift SVN r18238
2014-05-17 05:01:40 +00:00
Dave Abrahams
bbbf548a28 [stdlib] Do verbatim bridging entirely in Swift
This not only removes some code, but should allow more optimization and
inlining in the common case where the Swift type is a class or @objc
existential such as AnyObject

Swift SVN r18237
2014-05-17 05:01:04 +00:00
Joe Groff
e8f71c12a2 Rename ObjCMutablePointer to AutoreleasingUnsafePointer.
This relates its interface and behavior to that of UnsafePointer, and draws an analogy to '__autoreleasing *' in ARC.

Swift SVN r18236
2014-05-17 04:44:44 +00:00
Dave Abrahams
46388dd5e2 [stdlib] Unwrap some lines shrunken by T*
Concision FTW!

Swift SVN r18232
2014-05-17 00:27:43 +00:00
Dave Zarzycki
732486f8a0 Heap: simplify forEach logic
Swift SVN r18228
2014-05-16 23:57:22 +00:00
Dmitri Hrybenko
fbb9ed3729 stdlib/Dictionary: address internal API review
Add 'removeAtIndex:'


Swift SVN r18222
2014-05-16 22:42:09 +00:00
Dave Zarzycki
46f36e19df Heap: hashing bug feedback
I personally like ~(cast)0, but (cast)-1 felt more consistent with LLVM
style; and the waffling before finishing my coffee this morning made the
code wrong. Whoops.

Swift SVN r18221
2014-05-16 22:39:34 +00:00
Doug Gregor
73f02d1a69 Switch a bunch of UnsafePointer<T>'s over to T*
Swift SVN r18220
2014-05-16 22:32:01 +00:00
Dmitri Hrybenko
432961f652 stdlib/Assert: extinguish \brief
Swift SVN r18215
2014-05-16 21:36:12 +00:00
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
Arnold Schwaighofer
ddb874e045 Rename _isDebug and friends to _isDebugAssertConfiguration
Really we want those nullary functions be computed properties using enums.

  var _assertConfiguration : _AssertConfiguration {
    let assertConfig = Int32(Builtin.assert_configuration())
    if assertConfig == 0 {
      return .Debug
    }
    if assertConfig == 1 {
      return .Release
    }
    return .Fast
  }

  if _assertConfiguration == .Debug {
    _fatal_error_message("assertion failed", message, file, line)
  }

In my tests the enums were not optimized away. So for the short term leave
these functions as nullary functions.

Swift SVN r18211
2014-05-16 20:49:50 +00:00
Greg Clayton
2a74838159 Extensions to Objective-C objects fail in REPL if the class is not already initialized and LLDB now gets Objective C categories and extensions initialized properly.
Prior to this fix this would fail:
(swift) import Foundation
(swift) extension NSDate { func foo() { println("foo") }}   

As the Class for NSDate was not initialized.

<rdar://problem/16934080>



Swift SVN r18206
2014-05-16 19:49:41 +00:00
Ted Kremenek
fc47f11a29 Fix crash in CString's 'debugDescription' when the underlying pointer is null.
Fixes <rdar://problem/16227050>

Swift SVN r18202
2014-05-16 18:03:51 +00:00
Ted Kremenek
def1f53b7d Make printing of double's locale-insensitive.
I've never used 'newlocale' before, so I may be using it wrong.

Also, this may not be 100% thread safe; worst case we create
multiple locale objects when swift_doubleToString() is called
at the same time.  We can fix this if we care.

Swift SVN r18201
2014-05-16 17:43:54 +00:00
Dave Zarzycki
dbd023029e Heap: delete dead code
Swift SVN r18200
2014-05-16 17:30:23 +00:00
Dave Zarzycki
4bd4a4a6bc Heap: Add tombstones to make the not-found case faster
This should fix: <rdar://problem/16936107>

Swift SVN r18199
2014-05-16 17:19:13 +00:00
Dave Zarzycki
5455014d96 Heap: fix pointer-to-arena lookup
Swift SVN r18198
2014-05-16 16:43:48 +00:00
Dmitri Hrybenko
92335b2f91 tdlib/Dictionary: address internal API review
Removed 'find:'
Added 'indexForKey:'


Swift SVN r18197
2014-05-16 16:03:56 +00:00
Dmitri Hrybenko
2c1715fe78 stdlib/Dictionary: address internal API review: preallocate storage when
creating a Dictionary from a dictionary literal

Also fixes rdar://16876745, because once the code moved to using lower-level
interfaces, it became trivial to detect duplicate keys without a performance
hit.


Swift SVN r18193
2014-05-16 14:41:03 +00:00
Dmitri Hrybenko
b054a086e8 stdlib/Dictionary: add some comments
Swift SVN r18192
2014-05-16 12:45:23 +00:00
Dmitri Hrybenko
70c062814a stdlib/Dictionary: address internal API review
Removed 'itemsAsArray'


Swift SVN r18190
2014-05-16 11:53:14 +00:00
Dmitri Hrybenko
9abf7a9fa3 stdlib/Dictionary: address internal API review requests
Removed 'add:value:'
Added 'updateValue:forKey:'


Swift SVN r18188
2014-05-16 11:37:25 +00:00
Dmitri Hrybenko
828acd2738 stdlib: hide _NSSwiftArray, _NSSwiftDictionary, _NSSwiftEnumerator
Swift SVN r18187
2014-05-16 08:29:17 +00:00
Dmitri Hrybenko
522f332703 stdlib/bridging: update comments according to runtime function updates.
Swift SVN r18186
2014-05-16 07:59:40 +00:00
Ted Kremenek
178e2a32df Printing routines should append ".0" to floats, *not* taking locales into account.
Implements <rdar://problem/16895801>.

Swift SVN r18185
2014-05-16 07:27:54 +00:00
Nadav Rotem
14f4dd3a97 fix a typo
Swift SVN r18182
2014-05-16 06:06:52 +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
Nadav Rotem
70dfa94160 Extend the coverage of the fast path in the UTF16 comparator to more than ascii.
Swift SVN r18180
2014-05-16 05:58:39 +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
df4429fc5d Perform the class-or-ObjC-existential checks first in the runtime bridging entrypoints.
We decided that classes and Objective-C existentials are always going
to be bridged verbatim, ignoring any _BridgedToObjectiveC conformances.
While the compiler isn't preventing conformance of a class type to
_BridgedToObjectiveC, we ignore this case and will find a way to lock
it down if _BridgedToObjectiveC loses its underscore.

The motivation here is that (1) we don't really have a use case for a
class that bridges to Objective-C in any way other than just being an
Objective-C class, and (2) the class-or-ObjC-existential check is
ridiculously cheap compared to the
thread-safe-hash-table-over-a-dlsym-call used to find witness tables,
so do the cheap, common check first.



Swift SVN r18177
2014-05-16 05:18:34 +00:00
Nadav Rotem
2d592b6af9 Rename local variables. NFC.
Swift SVN r18176
2014-05-16 05:05:34 +00:00
Nadav Rotem
c1db20d178 Rename member_NthContiguous -> _nthContiguous
Swift SVN r18172
2014-05-16 04:26:10 +00:00
Nadav Rotem
c77b97079c Hoist the check for contiguous storage outside of the comparison loop.
Once we know that the storage is contiguous we use the new API _NthContiguous.
We can further optimize this code by specializing the access to ascii or UTF-16.



Swift SVN r18167
2014-05-16 03:44:32 +00:00
John McCall
e1aaa80ac0 Tweaks to the Unmanaged API: remove the bridge methods,
add conveniences for unsafely bridging unmanaged pointers
into void*.

Swift SVN r18162
2014-05-16 01:48:25 +00:00
John McCall
059ed4cd10 Propagate alignment arguments around through the
slow allocation/deallocation APIs.

Swift SVN r18160
2014-05-16 01:40:36 +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