mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[stdlib] Rename [_]elementStorage=>[_]baseAddress
Swift SVN r20342
This commit is contained in:
@@ -193,7 +193,7 @@ extension _ArrayBuffer {
|
||||
}
|
||||
|
||||
/// If this buffer is backed by a _ContiguousArrayBuffer, return it.
|
||||
/// Otherwise, return nil. Note: the result's elementStorage may
|
||||
/// Otherwise, return nil. Note: the result's baseAddress may
|
||||
/// not match ours, if we are a _SliceBuffer.
|
||||
public
|
||||
func requestNativeBuffer() -> NativeBuffer? {
|
||||
@@ -297,7 +297,7 @@ extension _ArrayBuffer {
|
||||
|
||||
// Tell Cocoa to copy the objects into our storage
|
||||
cocoa.buffer.getObjects(
|
||||
UnsafeMutablePointer(result.elementStorage),
|
||||
UnsafeMutablePointer(result.baseAddress),
|
||||
range: _SwiftNSRange(location: subRange.startIndex, length: subRangeCount)
|
||||
)
|
||||
|
||||
@@ -307,9 +307,9 @@ extension _ArrayBuffer {
|
||||
/// If the elements are stored contiguously, a pointer to the first
|
||||
/// element. Otherwise, nil.
|
||||
public
|
||||
var elementStorage: UnsafeMutablePointer<T> {
|
||||
var baseAddress: UnsafeMutablePointer<T> {
|
||||
if (_fastPath(_isNative)) {
|
||||
return _native.elementStorage
|
||||
return _native.baseAddress
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -366,7 +366,7 @@ extension _ArrayBuffer {
|
||||
indirect.replaceStorage(_copyCollectionToNativeArrayBuffer(self))
|
||||
}
|
||||
}
|
||||
let ret = body(self.elementStorage)
|
||||
let ret = body(self.baseAddress)
|
||||
_fixLifetime(self)
|
||||
return ret
|
||||
}
|
||||
@@ -378,10 +378,10 @@ extension _ArrayBuffer {
|
||||
body: (UnsafeMutablePointer<T>)->R
|
||||
) -> R {
|
||||
_sanityCheck(
|
||||
elementStorage != nil || count == 0,
|
||||
baseAddress != nil || count == 0,
|
||||
"Array is bridging an opaque NSArray; can't get a pointer to the elements"
|
||||
)
|
||||
let ret = body(elementStorage)
|
||||
let ret = body(baseAddress)
|
||||
_fixLifetime(self)
|
||||
return ret
|
||||
}
|
||||
@@ -397,7 +397,7 @@ extension _ArrayBuffer {
|
||||
/// have the same identity and count.
|
||||
public
|
||||
var identity: Word {
|
||||
let p = elementStorage
|
||||
let p = baseAddress
|
||||
return p != nil ? reinterpretCast(p) : reinterpretCast(owner)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public protocol _ArrayBufferType : MutableCollectionType {
|
||||
/// If this buffer is backed by a uniquely-referenced mutable
|
||||
/// _ContiguousArrayBuffer that can be grown in-place to allow the self
|
||||
/// buffer store minimumCapacity elements, returns that buffer.
|
||||
/// Otherwise, returns nil. Note: the result's elementStorage may
|
||||
/// Otherwise, returns nil. Note: the result's baseAddress may
|
||||
/// not match ours, if we are a _SliceBuffer.
|
||||
///
|
||||
/// Note: this function must remain mutating; otherwise the buffer
|
||||
@@ -57,7 +57,7 @@ public protocol _ArrayBufferType : MutableCollectionType {
|
||||
mutating func isMutableAndUniquelyReferenced() -> Bool
|
||||
|
||||
/// If this buffer is backed by a _ContiguousArrayBuffer, return it.
|
||||
/// Otherwise, return nil. Note: the result's elementStorage may
|
||||
/// Otherwise, return nil. Note: the result's baseAddress may
|
||||
/// not match ours, if we are a _SliceBuffer.
|
||||
func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>?
|
||||
|
||||
@@ -97,7 +97,7 @@ public protocol _ArrayBufferType : MutableCollectionType {
|
||||
|
||||
/// If the elements are stored contiguously, a pointer to the first
|
||||
/// element. Otherwise, nil.
|
||||
var elementStorage: UnsafeMutablePointer<Element> {get}
|
||||
var baseAddress: UnsafeMutablePointer<Element> {get}
|
||||
|
||||
/// A value that identifies first mutable element, if any. Two
|
||||
/// arrays compare === iff they are both empty, or if their buffers
|
||||
|
||||
@@ -37,7 +37,7 @@ internal protocol ArrayType
|
||||
|
||||
/// If the elements are stored contiguously, a pointer to the first
|
||||
/// element. Otherwise, nil.
|
||||
var _elementStorageIfContiguous: UnsafeMutablePointer<Element> {get}
|
||||
var _baseAddressIfContiguous: UnsafeMutablePointer<Element> {get}
|
||||
|
||||
subscript(index: Int) -> Self.Generator.Element {get set}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public struct ${Self}<T> : MutableCollectionType, Sliceable {
|
||||
var newBuffer = _ContiguousArrayBuffer<T>(
|
||||
count: buffer.count, minimumCapacity: buffer.count)
|
||||
let target = buffer._uninitializedCopy(
|
||||
0..<count, target: newBuffer.elementStorage)
|
||||
0..<count, target: newBuffer.baseAddress)
|
||||
buffer = _Buffer(newBuffer)
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ extension ${Self} : ArrayType {
|
||||
_precondition(count >= 0, "Can't construct ${Self} with count < 0")
|
||||
_buffer = _Buffer()
|
||||
reserveCapacity(count)
|
||||
var p = _buffer.elementStorage
|
||||
var p = _buffer.baseAddress
|
||||
for _ in 0..<count {
|
||||
p++.initialize(repeatedValue)
|
||||
}
|
||||
@@ -205,13 +205,13 @@ extension ${Self} : ArrayType {
|
||||
|
||||
/// If the elements are stored contiguously, a pointer to the first
|
||||
/// element. Otherwise, nil.
|
||||
public var _elementStorageIfContiguous: UnsafeMutablePointer<Element> {
|
||||
return _buffer.elementStorage
|
||||
public var _baseAddressIfContiguous: UnsafeMutablePointer<Element> {
|
||||
return _buffer.baseAddress
|
||||
}
|
||||
|
||||
%if Self != 'Array': # // Array does not necessarily have contiguous storage
|
||||
var _elementStorage: UnsafeMutablePointer<Element> {
|
||||
return _buffer.elementStorage
|
||||
var _baseAddress: UnsafeMutablePointer<Element> {
|
||||
return _buffer.baseAddress
|
||||
}
|
||||
%end
|
||||
//===--- basic mutations ------------------------------------------------===//
|
||||
@@ -227,7 +227,7 @@ extension ${Self} : ArrayType {
|
||||
var newBuffer = _ContiguousArrayBuffer<T>(
|
||||
count: count, minimumCapacity: minimumCapacity)
|
||||
|
||||
_buffer._uninitializedCopy(0..<count, target: newBuffer.elementStorage)
|
||||
_buffer._uninitializedCopy(0..<count, target: newBuffer.baseAddress)
|
||||
_buffer = _Buffer(newBuffer)
|
||||
}
|
||||
_sanityCheck(capacity >= minimumCapacity)
|
||||
@@ -377,12 +377,12 @@ extension ${Self} : Printable, DebugPrintable {
|
||||
extension ${Self} {
|
||||
@transparent
|
||||
func _cPointerArgs() -> (AnyObject?, Builtin.RawPointer) {
|
||||
let p = _elementStorageIfContiguous
|
||||
let p = _baseAddressIfContiguous
|
||||
if _fastPath(p != nil || count == 0) {
|
||||
return (_owner, p.value)
|
||||
}
|
||||
let n = _extractOrCopyToNativeArrayBuffer(self._buffer)
|
||||
return (n.owner, n.elementStorage.value)
|
||||
return (n.owner, n.baseAddress.value)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -429,7 +429,7 @@ extension ${Self} {
|
||||
|
||||
// Create an UnsafeBufferPointer over work that we can pass to body
|
||||
var a = UnsafeMutableBufferPointer(
|
||||
start: work._buffer.elementStorage, length: work.count)
|
||||
start: work._buffer.baseAddress, length: work.count)
|
||||
|
||||
// Invoke the body
|
||||
let ret = body(&a)
|
||||
@@ -505,7 +505,7 @@ func _arrayNonSliceInPlaceReplace<
|
||||
let growth = insertCount - eraseCount
|
||||
target.count = oldCount + growth
|
||||
|
||||
let elements = target.elementStorage
|
||||
let elements = target.baseAddress
|
||||
_sanityCheck(elements != nil)
|
||||
|
||||
let oldTailIndex = subRange.endIndex
|
||||
@@ -644,7 +644,7 @@ where C.Generator.Element == T
|
||||
max(newCount, _growArrayCapacity(capacity))
|
||||
: newCount)
|
||||
|
||||
var p = lhs._buffer.elementStorage + oldCount
|
||||
var p = lhs._buffer.baseAddress + oldCount
|
||||
for x in rhs {
|
||||
(p++).initialize(x)
|
||||
}
|
||||
@@ -726,18 +726,18 @@ func _arrayOutOfPlaceUpdate<
|
||||
|
||||
let sourceCount = source.count
|
||||
let oldCount = sourceCount - headCount - tailCount
|
||||
let destStart = dest!.elementStorage
|
||||
let destStart = dest!.baseAddress
|
||||
let newStart = destStart + headCount
|
||||
let newEnd = newStart + newCount
|
||||
|
||||
// Check to see if we have storage we can move from
|
||||
if let backing = source.requestUniqueMutableBackingBuffer(sourceCount) {
|
||||
let sourceStart = source.elementStorage
|
||||
let sourceStart = source.baseAddress
|
||||
let oldStart = sourceStart + headCount
|
||||
|
||||
// Destroy any items that may be lurking in a _SliceBuffer before
|
||||
// its real first element
|
||||
let backingStart = backing.elementStorage
|
||||
let backingStart = backing.baseAddress
|
||||
let sourceOffset = sourceStart - backingStart
|
||||
backingStart.destroy(sourceOffset)
|
||||
|
||||
@@ -788,7 +788,7 @@ func _arrayAppend<_Buffer: _ArrayBufferType>(
|
||||
let oldCount = buffer.count
|
||||
var newBuffer = _createUniqueMutableBuffer(&buffer, oldCount + 1)
|
||||
if _fastPath(!newBuffer) {
|
||||
(buffer.elementStorage + oldCount).initialize(newValue)
|
||||
(buffer.baseAddress + oldCount).initialize(newValue)
|
||||
}
|
||||
else {
|
||||
_arrayOutOfPlaceUpdate(
|
||||
@@ -843,7 +843,7 @@ func _arrayAppendSequence<
|
||||
nextItem = stream.next()
|
||||
while nextItem {
|
||||
let capacity = buffer.capacity
|
||||
let base = buffer.elementStorage
|
||||
let base = buffer.baseAddress
|
||||
|
||||
while nextItem && count < capacity {
|
||||
(base + count++).initialize(nextItem!)
|
||||
|
||||
@@ -23,7 +23,7 @@ final internal class _ContiguousArrayStorage<T> : _NSSwiftArray {
|
||||
|
||||
deinit {
|
||||
let b = Buffer(self)
|
||||
b.elementStorage.destroy(b.count)
|
||||
b.baseAddress.destroy(b.count)
|
||||
b._base._value.destroy()
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
|
||||
/// Make a buffer with uninitialized elements. After using this
|
||||
/// method, you must either initialize the count elements at the
|
||||
/// result's .elementStorage or set the result's .count to zero.
|
||||
/// result's .baseAddress or set the result's .count to zero.
|
||||
public init(count: Int, minimumCapacity: Int)
|
||||
{
|
||||
_base = HeapBuffer(
|
||||
@@ -135,27 +135,27 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
|
||||
/// If the elements are stored contiguously, a pointer to the first
|
||||
/// element. Otherwise, nil.
|
||||
public var elementStorage: UnsafeMutablePointer<T> {
|
||||
return _base.hasStorage ? _base.elementStorage : nil
|
||||
public var baseAddress: UnsafeMutablePointer<T> {
|
||||
return _base.hasStorage ? _base.baseAddress : nil
|
||||
}
|
||||
|
||||
/// A pointer to the first element, assuming that the elements are stored
|
||||
/// contiguously.
|
||||
var _unsafeElementStorage: UnsafeMutablePointer<T> {
|
||||
return _base.elementStorage
|
||||
return _base.baseAddress
|
||||
}
|
||||
|
||||
public func withUnsafePointerToElements<R>(
|
||||
body: (UnsafePointer<T>)->R
|
||||
) -> R {
|
||||
let p = _base.elementStorage
|
||||
let p = _base.baseAddress
|
||||
return withExtendedLifetime(_base) { body(p) }
|
||||
}
|
||||
|
||||
public mutating func withUnsafeMutablePointerToElements<R>(
|
||||
body: (UnsafeMutablePointer<T>)->R
|
||||
) -> R {
|
||||
let p = _base.elementStorage
|
||||
let p = _base.baseAddress
|
||||
return withExtendedLifetime(_base) { body(p) }
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
}
|
||||
|
||||
/// If this buffer is backed by a _ContiguousArrayBuffer, return it.
|
||||
/// Otherwise, return nil. Note: the result's elementStorage may
|
||||
/// Otherwise, return nil. Note: the result's baseAddress may
|
||||
/// not match ours, if we are a _SliceBuffer.
|
||||
public func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
|
||||
return self
|
||||
@@ -270,7 +270,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
_sanityCheck(subRange.endIndex <= count)
|
||||
|
||||
var dst = target
|
||||
var src = elementStorage + subRange.startIndex
|
||||
var src = baseAddress + subRange.startIndex
|
||||
for i in subRange {
|
||||
dst++.initialize(src++.memory)
|
||||
}
|
||||
@@ -284,7 +284,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
{
|
||||
return _SliceBuffer(
|
||||
owner: _base.storage,
|
||||
start: elementStorage + subRange.startIndex,
|
||||
start: baseAddress + subRange.startIndex,
|
||||
count: subRange.endIndex - subRange.startIndex,
|
||||
hasNativeBuffer: true)
|
||||
}
|
||||
@@ -328,7 +328,7 @@ public struct _ContiguousArrayBuffer<T> : _ArrayBufferType {
|
||||
/// have the same identity and count.
|
||||
public
|
||||
var identity: Word {
|
||||
return reinterpretCast(elementStorage)
|
||||
return reinterpretCast(baseAddress)
|
||||
}
|
||||
|
||||
/// Return true iff we have storage for elements of the given
|
||||
@@ -384,7 +384,7 @@ public func += <
|
||||
|
||||
if _fastPath(newCount <= lhs.capacity) {
|
||||
lhs.count = newCount
|
||||
(lhs.elementStorage + oldCount).initializeFrom(rhs)
|
||||
(lhs.baseAddress + oldCount).initializeFrom(rhs)
|
||||
}
|
||||
else {
|
||||
let newLHS = _ContiguousArrayBuffer<T>(
|
||||
@@ -392,12 +392,12 @@ public func += <
|
||||
minimumCapacity: _growArrayCapacity(lhs.capacity))
|
||||
|
||||
if lhs._base.hasStorage {
|
||||
newLHS.elementStorage.moveInitializeFrom(lhs.elementStorage,
|
||||
newLHS.baseAddress.moveInitializeFrom(lhs.baseAddress,
|
||||
count: oldCount)
|
||||
lhs._base.value.count = 0
|
||||
}
|
||||
lhs._base = newLHS._base
|
||||
(lhs._base.elementStorage + oldCount).initializeFrom(rhs)
|
||||
(lhs._base.baseAddress + oldCount).initializeFrom(rhs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ internal func _copyCollectionToNativeArrayBuffer<
|
||||
minimumCapacity: 0
|
||||
)
|
||||
|
||||
var p = result.elementStorage
|
||||
var p = result.baseAddress
|
||||
for x in GeneratorSequence(source.generate()) {
|
||||
(p++).initialize(x)
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ final class _NativeDictionaryStorageImpl<Key : Hashable, Value> :
|
||||
reinterpretCast(self) as DictionaryHeapBuffer.Storage)
|
||||
let body = buffer.value
|
||||
buffer._value.destroy()
|
||||
buffer.elementStorage.destroy(body.capacity)
|
||||
buffer.baseAddress.destroy(body.capacity)
|
||||
}
|
||||
final func __getInstanceSizeAndAlignMask() -> (Int,Int) {
|
||||
let buffer = DictionaryHeapBuffer(
|
||||
@@ -290,7 +290,7 @@ struct _NativeDictionaryStorage<Key : Hashable, Value> :
|
||||
|
||||
@transparent
|
||||
var elements: UnsafeMutablePointer<Element?> {
|
||||
return buffer.elementStorage
|
||||
return buffer.baseAddress
|
||||
}
|
||||
|
||||
init(capacity: Int) {
|
||||
@@ -2208,7 +2208,7 @@ func _stdlib_NSDictionary_allKeys(nsd: _SwiftNSDictionaryType)
|
||||
let count = nsd.count
|
||||
var buffer = HeapBuffer<Int, AnyObject>(
|
||||
HeapBufferStorage<Int, AnyObject>.self, count, count)
|
||||
nsd.getObjects(nil, andKeys: buffer.elementStorage)
|
||||
nsd.getObjects(nil, andKeys: buffer.baseAddress)
|
||||
return buffer
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ func _malloc_size(heapMemory: UnsafeMutablePointer<Void>) -> Int
|
||||
/// template <class Value, class Element>
|
||||
/// struct HeapBuffer {
|
||||
/// Value value;
|
||||
/// Element elementStorage[]; // length determined at creation time
|
||||
/// Element baseAddress[]; // length determined at creation time
|
||||
///
|
||||
/// HeapBuffer() = delete
|
||||
/// static shared_ptr<HeapBuffer> create(Value init, int capacity);
|
||||
@@ -115,7 +115,7 @@ public struct HeapBuffer<Value, Element> : Equatable {
|
||||
HeapBuffer._valueOffset() + _address)
|
||||
}
|
||||
|
||||
var elementStorage: UnsafeMutablePointer<Element> {
|
||||
var baseAddress: UnsafeMutablePointer<Element> {
|
||||
return UnsafeMutablePointer(HeapBuffer._elementOffset() + _address)
|
||||
}
|
||||
|
||||
@@ -177,10 +177,10 @@ public struct HeapBuffer<Value, Element> : Equatable {
|
||||
|
||||
subscript(i: Int) -> Element {
|
||||
get {
|
||||
return elementStorage[i]
|
||||
return baseAddress[i]
|
||||
}
|
||||
nonmutating set(newValue) {
|
||||
elementStorage[i] = newValue
|
||||
baseAddress[i] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class _NSSwiftArray : HeapBufferStorageBase, _CocoaArrayType {
|
||||
|
||||
if _fastPath(buffer.value.elementTypeIsBridgedVerbatim) {
|
||||
dst.initializeFrom(
|
||||
UnsafeMutablePointer(buffer.elementStorage + range.location),
|
||||
UnsafeMutablePointer(buffer.baseAddress + range.location),
|
||||
count: range.length)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class _NSSwiftArray : HeapBufferStorageBase, _CocoaArrayType {
|
||||
return 0
|
||||
}
|
||||
enumerationState.mutationsPtr = _fastEnumerationStorageMutationsPtr
|
||||
enumerationState.itemsPtr = reinterpretCast(buffer.elementStorage)
|
||||
enumerationState.itemsPtr = reinterpretCast(buffer.baseAddress)
|
||||
enumerationState.state = 1
|
||||
state.memory = enumerationState
|
||||
return buffer.value.count
|
||||
|
||||
@@ -49,9 +49,9 @@ func _convertMutableArrayToPointerArgument<
|
||||
|
||||
// Call reserve to force contiguous storage.
|
||||
a.reserveCapacity(0)
|
||||
_debugPrecondition(a._elementStorageIfContiguous != nil || a.count == 0)
|
||||
_debugPrecondition(a._baseAddressIfContiguous != nil || a.count == 0)
|
||||
|
||||
return (a._owner, ToPointer(a._elementStorageIfContiguous.value))
|
||||
return (a._owner, ToPointer(a._baseAddressIfContiguous.value))
|
||||
}
|
||||
|
||||
/// Derive a pointer argument from a value array parameter.
|
||||
|
||||
@@ -35,7 +35,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
public
|
||||
init(_ buffer: NativeBuffer) {
|
||||
owner = buffer._storage
|
||||
start = buffer.elementStorage
|
||||
start = buffer.baseAddress
|
||||
_countAndFlags = (UInt(buffer.count) << 1) | (owner ? 1 : 0)
|
||||
_invariantCheck()
|
||||
}
|
||||
@@ -83,7 +83,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
_sanityCheck(_hasNativeBuffer && isUniquelyReferenced())
|
||||
|
||||
var native = reinterpretCast(owner) as NativeBuffer
|
||||
let offset = start - native.elementStorage
|
||||
let offset = start - native.baseAddress
|
||||
let eraseCount = countElements(subRange)
|
||||
let growth = insertCount - eraseCount
|
||||
|
||||
@@ -140,7 +140,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
// function isn't called for subscripting, this won't slow
|
||||
// down that case.
|
||||
var backing = reinterpretCast(owner) as NativeBuffer
|
||||
let offset = self.elementStorage - backing.elementStorage
|
||||
let offset = self.baseAddress - backing.baseAddress
|
||||
let backingCount = backing.count
|
||||
let myCount = count
|
||||
|
||||
@@ -163,7 +163,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
}
|
||||
|
||||
/// If this buffer is backed by a _ContiguousArrayBuffer, return it.
|
||||
/// Otherwise, return nil. Note: the result's elementStorage may
|
||||
/// Otherwise, return nil. Note: the result's baseAddress may
|
||||
/// not match ours, since we are a _SliceBuffer.
|
||||
public
|
||||
func requestNativeBuffer() -> _ContiguousArrayBuffer<Element>? {
|
||||
@@ -189,7 +189,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
}
|
||||
|
||||
public
|
||||
var elementStorage: UnsafeMutablePointer<T> {
|
||||
var baseAddress: UnsafeMutablePointer<T> {
|
||||
return start
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
return count
|
||||
}
|
||||
let n = nativeBuffer
|
||||
if (count + start) == (n.count + n.elementStorage) {
|
||||
if (count + start) == (n.count + n.baseAddress) {
|
||||
return count + (n.capacity - n.count)
|
||||
}
|
||||
return count
|
||||
|
||||
@@ -102,7 +102,7 @@ public struct _StringBuffer {
|
||||
return (result, hadError)
|
||||
}
|
||||
else {
|
||||
var p = result._storage.elementStorage
|
||||
var p = result._storage.baseAddress
|
||||
let hadError = transcode(encoding, UTF16.self, input.generate(),
|
||||
SinkOf {
|
||||
(p++).memory = $0
|
||||
@@ -117,7 +117,7 @@ public struct _StringBuffer {
|
||||
|
||||
/// a pointer to the start of this buffer's data area
|
||||
public var start: UnsafeMutablePointer<RawByte> {
|
||||
return UnsafeMutablePointer(_storage.elementStorage)
|
||||
return UnsafeMutablePointer(_storage.baseAddress)
|
||||
}
|
||||
|
||||
/// a past-the-end pointer for this buffer's stored data
|
||||
|
||||
@@ -66,7 +66,7 @@ public struct Unsafe${Mutable}BufferPointer<T> : ${Mutable}CollectionType {
|
||||
return UnsafeBufferPointerGenerator(position: _position, end: _end)
|
||||
}
|
||||
|
||||
public var elementStorage: Unsafe${Mutable}Pointer<T> {
|
||||
public var baseAddress: Unsafe${Mutable}Pointer<T> {
|
||||
return _position
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public func _encodeBitsAsWords<T: CVarArgType>(x: T) -> [Word] {
|
||||
count: (sizeof(T.self) + sizeof(Word.self) - 1) / sizeof(Word.self),
|
||||
repeatedValue: 0)
|
||||
var tmp = x
|
||||
_memcpy(dest: UnsafeMutablePointer(result._elementStorageIfContiguous),
|
||||
_memcpy(dest: UnsafeMutablePointer(result._baseAddressIfContiguous),
|
||||
src: UnsafeMutablePointer(Builtin.addressof(&tmp)),
|
||||
size: UInt(sizeof(T.self)))
|
||||
return result
|
||||
@@ -155,7 +155,7 @@ class VaListBuilder {
|
||||
func va_list() -> CVaListPointer {
|
||||
return CVaListPointer(
|
||||
fromUnsafeMutablePointer: UnsafeMutablePointer<Void>(
|
||||
storage._elementStorageIfContiguous))
|
||||
storage._baseAddressIfContiguous))
|
||||
}
|
||||
|
||||
var storage = [Word]()
|
||||
@@ -202,9 +202,9 @@ class VaListBuilder {
|
||||
}
|
||||
|
||||
func va_list() -> CVaListPointer {
|
||||
header.reg_save_area = storage._elementStorageIfContiguous
|
||||
header.reg_save_area = storage._baseAddressIfContiguous
|
||||
header.overflow_arg_area
|
||||
= storage._elementStorageIfContiguous + _x86_64RegisterSaveWords
|
||||
= storage._baseAddressIfContiguous + _x86_64RegisterSaveWords
|
||||
return CVaListPointer(
|
||||
fromUnsafeMutablePointer: UnsafeMutablePointer<Void>(
|
||||
Builtin.addressof(&self.header)))
|
||||
|
||||
@@ -547,7 +547,7 @@ extension NSArray : ArrayLiteralConvertible {
|
||||
// + (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
|
||||
let x = _extractOrCopyToNativeArrayBuffer(elements._buffer)
|
||||
let result = self(
|
||||
objects: UnsafeMutablePointer(x.elementStorage), count: x.count)
|
||||
objects: UnsafeMutablePointer(x.baseAddress), count: x.count)
|
||||
_fixLifetime(x)
|
||||
return result
|
||||
}
|
||||
@@ -800,9 +800,9 @@ final public class NSFastGenerator : GeneratorType {
|
||||
func refresh() {
|
||||
n = 0
|
||||
count = enumerable.countByEnumeratingWithState(
|
||||
state._elementStorageIfContiguous,
|
||||
state._baseAddressIfContiguous,
|
||||
objects: AutoreleasingUnsafeMutablePointer(
|
||||
objects._elementStorageIfContiguous),
|
||||
objects._baseAddressIfContiguous),
|
||||
count: STACK_BUF_SIZE)
|
||||
}
|
||||
|
||||
@@ -1092,7 +1092,7 @@ extension NSArray {
|
||||
// @objc(initWithObjects:count:)
|
||||
// init(withObjects objects: UnsafePointer<AnyObject?>,
|
||||
// count cnt: Int)
|
||||
self.init(objects: UnsafeMutablePointer(x.elementStorage), count: x.count)
|
||||
self.init(objects: UnsafeMutablePointer(x.baseAddress), count: x.count)
|
||||
_fixLifetime(x)
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ extension NSOrderedSet {
|
||||
// @objc(initWithObjects:count:)
|
||||
// init(withObjects objects: UnsafePointer<AnyObject?>,
|
||||
// count cnt: Int)
|
||||
self.init(objects: UnsafeMutablePointer(x.elementStorage), count: x.count)
|
||||
self.init(objects: UnsafeMutablePointer(x.baseAddress), count: x.count)
|
||||
_fixLifetime(x)
|
||||
}
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ extension NSSet {
|
||||
// Imported as:
|
||||
// @objc(initWithObjects:count:)
|
||||
// init(withObjects objects: UnsafePointer<AnyObject?>, count cnt: Int)
|
||||
self.init(objects: UnsafeMutablePointer(x.elementStorage), count: x.count)
|
||||
self.init(objects: UnsafeMutablePointer(x.baseAddress), count: x.count)
|
||||
_fixLifetime(x)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class FixedSizedRefArrayOfOptionalStorage<T> : HeapBufferStorage<Int, T?> {
|
||||
deinit {
|
||||
let buffer = Buffer(self)
|
||||
for i in 0..<buffer.value {
|
||||
(buffer.elementStorage + i).destroy()
|
||||
(buffer.baseAddress + i).destroy()
|
||||
}
|
||||
}
|
||||
override func __getInstanceSizeAndAlignMask() -> (Int,Int) {
|
||||
@@ -123,7 +123,7 @@ struct FixedSizedRefArrayOfOptional<T>
|
||||
{
|
||||
buffer = Storage.Buffer(Storage.self, capacity, capacity)
|
||||
for var i = 0; i < capacity; ++i {
|
||||
(buffer.elementStorage + i).initialize(.None)
|
||||
(buffer.baseAddress + i).initialize(.None)
|
||||
}
|
||||
|
||||
buffer.value = capacity
|
||||
@@ -132,12 +132,12 @@ struct FixedSizedRefArrayOfOptional<T>
|
||||
subscript(i: Int) -> T? {
|
||||
get {
|
||||
assert(i >= 0 && i < buffer.value)
|
||||
return (buffer.elementStorage + i).memory
|
||||
return (buffer.baseAddress + i).memory
|
||||
}
|
||||
nonmutating
|
||||
set {
|
||||
assert(i >= 0 && i < buffer.value)
|
||||
(buffer.elementStorage + i).memory = newValue
|
||||
(buffer.baseAddress + i).memory = newValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1592,7 +1592,7 @@ func slurpFastEnumeration(
|
||||
var pairs = Array<(Int, Int)>()
|
||||
while true {
|
||||
var returnedCount = fe.countByEnumeratingWithState(
|
||||
&state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.elementStorage),
|
||||
&state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
|
||||
count: stackBufLength)
|
||||
assert(state.state != 0)
|
||||
assert(state.mutationsPtr != .null())
|
||||
@@ -1609,7 +1609,7 @@ func slurpFastEnumeration(
|
||||
|
||||
for i in 0..<3 {
|
||||
let returnedCount = fe.countByEnumeratingWithState(
|
||||
&state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.elementStorage),
|
||||
&state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
|
||||
count: stackBufLength)
|
||||
assert(returnedCount == 0)
|
||||
}
|
||||
@@ -1760,7 +1760,7 @@ class ParallelArrayDictionary : NSDictionary {
|
||||
var theState = state.memory
|
||||
if theState.state == 0 {
|
||||
theState.state = 1
|
||||
theState.itemsPtr = AutoreleasingUnsafeMutablePointer(keys._elementStorageIfContiguous)
|
||||
theState.itemsPtr = AutoreleasingUnsafeMutablePointer(keys._baseAddressIfContiguous)
|
||||
theState.mutationsPtr = _fastEnumerationStorageMutationsPtr
|
||||
state.memory = theState
|
||||
return 4
|
||||
|
||||
@@ -18,7 +18,7 @@ a.value.name = "DaveA"
|
||||
a.value.locations.append("Princeton")
|
||||
a.value.locations.append("San Jose")
|
||||
for x in 0..<10 {
|
||||
(a.elementStorage + x).initialize(x)
|
||||
(a.baseAddress + x).initialize(x)
|
||||
}
|
||||
|
||||
println("buffer has storage: \(a.storage.boolValue)")
|
||||
@@ -55,7 +55,7 @@ println("locations[1]=\(a.value.locations[1])")
|
||||
// CHECK-NEXT: locations[1]=San Jose
|
||||
|
||||
for x in 0..<10 {
|
||||
print(a.elementStorage[x])
|
||||
print(a.baseAddress[x])
|
||||
}
|
||||
println("")
|
||||
// CHECK-NEXT: 0123456789
|
||||
|
||||
@@ -73,7 +73,7 @@ func printSequence<T: SequenceType>(x: T) {
|
||||
}
|
||||
|
||||
func bufferID<T : ArrayType>(x: T) -> Int {
|
||||
return reinterpretCast(x._buffer.elementStorage) as Int
|
||||
return reinterpretCast(x._buffer.baseAddress) as Int
|
||||
}
|
||||
|
||||
func checkReallocation<T : ArrayType>(
|
||||
|
||||
@@ -261,11 +261,11 @@ func additionalUtf16Tests() {
|
||||
|
||||
u16.withUnsafeMutableBufferPointer {
|
||||
(u16)->() in
|
||||
let p16 = u16.elementStorage
|
||||
let p16 = u16.baseAddress
|
||||
|
||||
u8.withUnsafeMutableBufferPointer {
|
||||
(u8)->() in
|
||||
let p8 = u8.elementStorage
|
||||
let p8 = u8.baseAddress
|
||||
|
||||
// CHECK-NEXT: [ 0, 1, 2, 9, 10, 11 ]
|
||||
UTF16.copy(p8, destination: p16, count: 3)
|
||||
|
||||
Reference in New Issue
Block a user