Commit Graph

37 Commits

Author SHA1 Message Date
Dmitri Hrybenko
bd0c7f4651 stdlib/Dictionary: rename variables to match the new semantics. No public API
changes.


Swift SVN r18588
2014-05-23 09:09:51 +00:00
Dmitri Hrybenko
47bae74a59 stdlib/Dictionary: fix a bug in deletion
If we were deleting a key in the middle of a collision chain, and the tail of
the collision chain had keys whose ideal bucket was located before the hole
that we just created, we would mistakenly not relocate those keys.

rdar://16984824


Swift SVN r18562
2014-05-22 10:47:22 +00:00
John McCall
5ddee671b6 Provide a hacky hook for specifying a class's instance size
and alignment for the purposes of deallocation.

If a class contains a method named __getInstanceSizeAndAlignMask,
and it takes no arguments and returns a pair of words, call
that method directly in order to get the size and alignment
mask instead of trusting the class's formal size and alignment.

This is not a replacement for a proper language solution for
custom allocation, but it'll suffice to fix some immediate
problems with HeapBufferStorage.

If we decide we like this approach, we should really raise
the deallocating destructor up to SIL.

rdar://16979846

Swift SVN r18485
2014-05-21 07:22:39 +00:00
Joe Pamer
1d34a88477 Revert "Fix two problems with implicit conversions: - rdar://problem/16776273, wherein conversions between nil and .None were permitted due to an implicit conversion between nil and COpaquePointer. - rdar://problem/16877526, where we needed to add new equality overloads to handle conversions between nil and .None given the supression of user conversions. (Thanks to Ted for the overloads and test.)"
This reverts commit r18473.

Swift SVN r18477
2014-05-21 00:28:46 +00:00
Joe Pamer
f469d8f1f6 Fix two problems with implicit conversions:
- rdar://problem/16776273, wherein conversions between nil and .None were permitted
due to an implicit conversion between nil and COpaquePointer.
- rdar://problem/16877526, where we needed to add new equality overloads to handle
conversions between nil and .None given the supression of user conversions.
(Thanks to Ted for the overloads and test.)

Swift SVN r18473
2014-05-20 23:53:34 +00:00
Dmitri Hrybenko
bbf7b0af98 stdlib/Dictionary: add 'removeAll:' API
rdar://16953595

Swift SVN r18453
2014-05-20 14:52:01 +00:00
Dmitri Hrybenko
2bc1088de3 stdlib/Dictionary: finish removing the assumption that keys and values are
bridged back from Objective-C verbatim

The internal API assertingGet(KeyType) is dead code now, so no tests.


Swift SVN r18421
2014-05-19 14:56:32 +00:00
Dmitri Hrybenko
af11f8f8b7 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes == operator.


Swift SVN r18420
2014-05-19 14:48:53 +00:00
Dmitri Hrybenko
0d20e71f51 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes generate: API and DictionaryGenerator.


Swift SVN r18415
2014-05-19 11:48:44 +00:00
Dmitri Hrybenko
6d3026266f stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes removeValueForKey: API.


Swift SVN r18413
2014-05-19 11:33:25 +00:00
Dmitri Hrybenko
2aabfeaaca stdlib/Dictionary: remove comment that is no longer true
Swift SVN r18412
2014-05-19 11:21:07 +00:00
Dmitri Hrybenko
72354e8a47 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes removeAtIndex: API.


Swift SVN r18411
2014-05-19 11:20:34 +00:00
Dmitri Hrybenko
c4492b4544 stdlib/Dictionary: continue removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes subscript(KeyType) API.


Swift SVN r18409
2014-05-19 10:36:11 +00:00
Dmitri Hrybenko
785aabd53e stdlib/Dictionary: start removing the assumption that keys and values are
bridged back from Objective-C verbatim

Fixes subscript(Index) API.


Swift SVN r18408
2014-05-19 10:03:59 +00:00
Dave Abrahams
215da18af9 [stdlib] Publicize Map, add lazy map()
As declared, Dictionary's keys and values were private.  Instead of
hiding Map away as _Map, give it a "nice" verbose name and expose it
through a "nice" lowercase global function called map(), which we
overload so it works on both Collections and Sequences, returning a
Collection when that's what it started on.

We'll follow this pattern for filter, which was requested on Array.  The
implementation is easy once you have a lazy view!

Swift SVN r18340
2014-05-18 19:00:42 +00:00
Dmitri Hrybenko
948ddb3a39 Revert "Make 'maybeGet' and 'assertingGet' private API."
These are private APIs already because they are inside private types.


Swift SVN r18322
2014-05-18 14:01:24 +00:00
Ted Kremenek
a8c2b61cdb Always make 'allKeys' a property (coincides with Foundation).
Swift SVN r18305
2014-05-18 04:20:07 +00:00
Ted Kremenek
ef2d73fb16 Make 'maybeGet' and 'assertingGet' private API.
Swift SVN r18303
2014-05-18 04:07:20 +00:00
Ted Kremenek
16dea15a24 Hide CocoaArray ('_' to mark as private API).
Swift SVN r18302
2014-05-18 04:03:32 +00:00
Ted Kremenek
eab7f90a81 Per design discussion today, rename UnsafePointer ".pointee" to ".memory".
Swift SVN r18269
2014-05-17 20:35:16 +00:00
Dmitri Hrybenko
0d5b40a0e8 stdlib/Dictionary: s/removeObjectForKey/removeValueForKey/ per API review
emails


Swift SVN r18268
2014-05-17 20:15:40 +00:00
Dmitri Hrybenko
6a2192f76f stdlib/Dictionary: add doc comments for new APIs
Swift SVN r18267
2014-05-17 20:11:40 +00:00
Dmitri Hrybenko
d213355030 stdlib/Dictionary: address internal API review
Add 'removeObjectForKey:'


Swift SVN r18265
2014-05-17 19:47:48 +00:00
Dmitri Hrybenko
fbb9ed3729 stdlib/Dictionary: address internal API review
Add 'removeAtIndex:'


Swift SVN r18222
2014-05-16 22:42:09 +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
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
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
Dmitri Hrybenko
b966c9583f stdlib/{Array, Dictionary}: make debugDescription forward to debugDescription
of container elements

rdar://16929672


Swift SVN r18132
2014-05-15 22:08:07 +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
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
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Dmitri Hrybenko
29cebdf797 Splitting the standard library: step 1: move stdlib -> stdlib/core
Swift SVN r5864
2013-06-28 02:31:01 +00:00