stdlib: remove Word and UWord

These types are leftovers from the early pre-1.0 times when Int and UInt
were always 64-bit on all platforms.  They serve no useful purpose
today.  Int and UInt are defined to be word-sized and should be used
instead.

rdar://18693488

Swift SVN r30564
This commit is contained in:
Dmitri Hrybenko
2015-07-24 05:01:32 +00:00
parent ef553f47cf
commit f5de8757e4
58 changed files with 1073 additions and 1080 deletions

View File

@@ -31,7 +31,7 @@
public func assert(
@autoclosure condition: () -> Bool,
@autoclosure _ message: () -> String = String(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
// Only assert in debug mode.
if _isDebugAssertConfiguration() {
@@ -61,7 +61,7 @@ public func assert(
public func precondition(
@autoclosure condition: () -> Bool,
@autoclosure _ message: () -> String = String(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
// Only check in debug and release mode. In release mode just trap.
if _isDebugAssertConfiguration() {
@@ -95,7 +95,7 @@ public func precondition(
@inline(__always)
public func assertionFailure(
@autoclosure message: () -> String = String(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
if _isDebugAssertConfiguration() {
_assertionFailed("fatal error", message(), file, line)
@@ -123,7 +123,7 @@ public func assertionFailure(
@transparent @noreturn
public func preconditionFailure(
@autoclosure message: () -> String = String(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
// Only check in debug and release mode. In release mode just trap.
if _isDebugAssertConfiguration() {
@@ -138,7 +138,7 @@ public func preconditionFailure(
@transparent @noreturn
public func fatalError(
@autoclosure message: () -> String = String(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
_assertionFailed("fatal error", message(), file, line)
}
@@ -152,7 +152,7 @@ public func fatalError(
@transparent
public func _precondition(
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
// Only check in debug and release mode. In release mode just trap.
if _isDebugAssertConfiguration() {
@@ -168,7 +168,7 @@ public func _precondition(
@transparent @noreturn
public func _preconditionFailure(
message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__) {
file: StaticString = __FILE__, line: UInt = __LINE__) {
_precondition(false, message, file:file, line: line)
@@ -181,7 +181,7 @@ public func _preconditionFailure(
@transparent
public func _overflowChecked<T>(
args: (T, Bool),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) -> T {
let (result, error) = args
if _isDebugAssertConfiguration() {
@@ -205,7 +205,7 @@ public func _overflowChecked<T>(
@transparent
public func _debugPrecondition(
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
// Only check in debug mode.
if _isDebugAssertConfiguration() {
@@ -218,7 +218,7 @@ public func _debugPrecondition(
@transparent @noreturn
public func _debugPreconditionFailure(
message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__) {
file: StaticString = __FILE__, line: UInt = __LINE__) {
if _isDebugAssertConfiguration() {
_precondition(false, message, file: file, line: line)
}
@@ -234,7 +234,7 @@ public func _debugPreconditionFailure(
@transparent
public func _sanityCheck(
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
#if INTERNAL_CHECKS_ENABLED
if !_branchHint(condition(), true) {
@@ -246,7 +246,7 @@ public func _sanityCheck(
@transparent @noreturn
public func _sanityCheckFailure(
message: StaticString = StaticString(),
file: StaticString = __FILE__, line: UWord = __LINE__
file: StaticString = __FILE__, line: UInt = __LINE__
) {
_sanityCheck(false, message, file: file, line: line)
_conditionallyUnreachable()

View File

@@ -58,27 +58,27 @@ func _isStdlibInternalChecksEnabled() -> Bool {
@asmname("swift_reportFatalErrorInFile")
func _reportFatalErrorInFile(
prefix: UnsafePointer<UInt8>, _ prefixLength: UWord,
_ message: UnsafePointer<UInt8>, _ messageLength: UWord,
_ file: UnsafePointer<UInt8>, _ fileLength: UWord,
_ line: UWord)
prefix: UnsafePointer<UInt8>, _ prefixLength: UInt,
_ message: UnsafePointer<UInt8>, _ messageLength: UInt,
_ file: UnsafePointer<UInt8>, _ fileLength: UInt,
_ line: UInt)
@asmname("swift_reportFatalError")
func _reportFatalError(
prefix: UnsafePointer<UInt8>, _ prefixLength: UWord,
_ message: UnsafePointer<UInt8>, _ messageLength: UWord)
prefix: UnsafePointer<UInt8>, _ prefixLength: UInt,
_ message: UnsafePointer<UInt8>, _ messageLength: UInt)
@asmname("swift_reportUnimplementedInitializerInFile")
func _reportUnimplementedInitializerInFile(
className: UnsafePointer<UInt8>, _ classNameLength: UWord,
_ initName: UnsafePointer<UInt8>, _ initNameLength: UWord,
_ file: UnsafePointer<UInt8>, _ fileLength: UWord,
_ line: UWord, _ column: UWord)
className: UnsafePointer<UInt8>, _ classNameLength: UInt,
_ initName: UnsafePointer<UInt8>, _ initNameLength: UInt,
_ file: UnsafePointer<UInt8>, _ fileLength: UInt,
_ line: UInt, _ column: UInt)
@asmname("swift_reportUnimplementedInitializer")
func _reportUnimplementedInitializer(
className: UnsafePointer<UInt8>, _ classNameLength: UWord,
_ initName: UnsafePointer<UInt8>, _ initNameLength: UWord)
className: UnsafePointer<UInt8>, _ classNameLength: UInt,
_ initName: UnsafePointer<UInt8>, _ initNameLength: UInt)
/// This function should be used only in the implementation of user-level
/// assertions.
@@ -88,7 +88,7 @@ func _reportUnimplementedInitializer(
@noreturn @inline(never)
func _assertionFailed(
prefix: StaticString, _ message: StaticString,
_ file: StaticString, _ line: UWord
_ file: StaticString, _ line: UInt
) {
prefix.withUTF8Buffer {
(prefix) -> () in
@@ -97,9 +97,9 @@ func _assertionFailed(
file.withUTF8Buffer {
(file) -> () in
_reportFatalErrorInFile(
prefix.baseAddress, UWord(prefix.count),
message.baseAddress, UWord(message.count),
file.baseAddress, UWord(file.count), line)
prefix.baseAddress, UInt(prefix.count),
message.baseAddress, UInt(message.count),
file.baseAddress, UInt(file.count), line)
Builtin.int_trap()
}
}
@@ -115,7 +115,7 @@ func _assertionFailed(
@noreturn @inline(never)
func _assertionFailed(
prefix: StaticString, _ message: String,
_ file: StaticString, _ line: UWord
_ file: StaticString, _ line: UInt
) {
prefix.withUTF8Buffer {
(prefix) -> () in
@@ -125,9 +125,9 @@ func _assertionFailed(
file.withUTF8Buffer {
(file) -> () in
_reportFatalErrorInFile(
prefix.baseAddress, UWord(prefix.count),
messageUTF8.baseAddress, UWord(messageUTF8.count),
file.baseAddress, UWord(file.count), line)
prefix.baseAddress, UInt(prefix.count),
messageUTF8.baseAddress, UInt(messageUTF8.count),
file.baseAddress, UInt(file.count), line)
}
}
}
@@ -143,7 +143,7 @@ func _assertionFailed(
@noreturn @inline(never)
@_semantics("stdlib_binary_only")
func _fatalErrorMessage(prefix: StaticString, _ message: StaticString,
_ file: StaticString, _ line: UWord) {
_ file: StaticString, _ line: UInt) {
#if INTERNAL_CHECKS_ENABLED
prefix.withUTF8Buffer {
(prefix) in
@@ -152,9 +152,9 @@ func _fatalErrorMessage(prefix: StaticString, _ message: StaticString,
file.withUTF8Buffer {
(file) in
_reportFatalErrorInFile(
prefix.baseAddress, UWord(prefix.count),
message.baseAddress, UWord(message.count),
file.baseAddress, UWord(file.count), line)
prefix.baseAddress, UInt(prefix.count),
message.baseAddress, UInt(message.count),
file.baseAddress, UInt(file.count), line)
}
}
}
@@ -164,8 +164,8 @@ func _fatalErrorMessage(prefix: StaticString, _ message: StaticString,
message.withUTF8Buffer {
(message) in
_reportFatalError(
prefix.baseAddress, UWord(prefix.count),
message.baseAddress, UWord(message.count))
prefix.baseAddress, UInt(prefix.count),
message.baseAddress, UInt(message.count))
}
}
#endif
@@ -180,8 +180,8 @@ public // COMPILER_INTRINSIC
func _unimplemented_initializer(className: StaticString,
initName: StaticString = __FUNCTION__,
file: StaticString = __FILE__,
line: UWord = __LINE__,
column: UWord = __COLUMN__) {
line: UInt = __LINE__,
column: UInt = __COLUMN__) {
// This function is marked @transparent so that it is inlined into the caller
// (the initializer stub), and, depending on the build configuration,
// redundant parameter values (__FILE__ etc.) are eliminated, and don't leak
@@ -195,9 +195,9 @@ func _unimplemented_initializer(className: StaticString,
file.withUTF8Buffer {
(file) in
_reportUnimplementedInitializerInFile(
className.baseAddress, UWord(className.count),
initName.baseAddress, UWord(initName.count),
file.baseAddress, UWord(file.count), line, column)
className.baseAddress, UInt(className.count),
initName.baseAddress, UInt(initName.count),
file.baseAddress, UInt(file.count), line, column)
}
}
}
@@ -207,8 +207,8 @@ func _unimplemented_initializer(className: StaticString,
initName.withUTF8Buffer {
(initName) in
_reportUnimplementedInitializer(
className.baseAddress, UWord(className.count),
initName.baseAddress, UWord(initName.count))
className.baseAddress, UInt(className.count),
initName.baseAddress, UInt(initName.count))
}
}
}

View File

@@ -94,7 +94,7 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
///
/// This is a fundamentally unsafe conversion.
@transparent
public init(bitPattern: Word) {
public init(bitPattern: Int) {
_rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
}
@@ -102,7 +102,7 @@ public struct COpaquePointer : Equatable, Hashable, NilLiteralConvertible {
///
/// This is a fundamentally unsafe conversion.
@transparent
public init(bitPattern: UWord) {
public init(bitPattern: UInt) {
_rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
}

View File

@@ -15,7 +15,7 @@ import SwiftShims
% traversals = ['Forward', 'Bidirectional', 'RandomAccess']
@noreturn @inline(never)
internal func _abstract(file: StaticString = __FILE__, line: UWord = __LINE__) {
internal func _abstract(file: StaticString = __FILE__, line: UInt = __LINE__) {
fatalError("Method must be overridden", file: file, line: line)
}

View File

@@ -449,7 +449,6 @@ extension ${Self} {
extension ${Self} : SignedNumberType {}
% end
%# FIXME: checked conversions of Word types
// construction from other integer types
@transparent
extension ${Self} {
@@ -649,10 +648,10 @@ public func _assumeNonNegative(x: ${Self}) -> ${Self} {
% end
//===--- End loop over all integer types ----------------------------------===//
/// A signed integer type that occupies one machine word.
@available(*, unavailable, renamed="Int")
public typealias Word = Int
/// An unsigned integer type that occupies one machine word.
@available(*, unavailable, renamed="UInt")
public typealias UWord = UInt
// ${'Local Variables'}:

View File

@@ -246,7 +246,7 @@ internal struct _UnmanagedAnyObjectArray {
/// Underlying pointer, typed as an integer to escape from reference
/// counting.
internal var value: UnsafeMutablePointer<Word>
internal var value: UnsafeMutablePointer<Int>
internal init(_ up: UnsafeMutablePointer<AnyObject>) {
self.value = UnsafeMutablePointer(up)
@@ -257,7 +257,7 @@ internal struct _UnmanagedAnyObjectArray {
return _reinterpretCastToAnyObject(value[i])
}
nonmutating set(newValue) {
value[i] = unsafeBitCast(newValue, Word.self)
value[i] = unsafeBitCast(newValue, Int.self)
}
}
}

View File

@@ -99,7 +99,7 @@ public func _stdlib_getDemangledTypeName<T>(value: T) -> String {
@asmname("swift_stdlib_demangleName")
func _stdlib_demangleNameImpl(
mangledName: UnsafePointer<UInt8>,
_ mangledNameLength: UWord,
_ mangledNameLength: UInt,
_ demangledName: UnsafeMutablePointer<String>)
public func _stdlib_demangleName(mangledName: String) -> String {
@@ -108,7 +108,7 @@ public func _stdlib_demangleName(mangledName: String) -> String {
(mangledNameUTF8) in
let (_, demangledName) = _withUninitializedString {
_stdlib_demangleNameImpl(
mangledNameUTF8.baseAddress, UWord(mangledNameUTF8.endIndex),
mangledNameUTF8.baseAddress, UInt(mangledNameUTF8.endIndex),
$0)
}
return demangledName

View File

@@ -298,8 +298,8 @@ struct _Buffer72 {
@asmname("swift_float${bits}ToString")
func _float${bits}ToStringImpl(
buffer: UnsafeMutablePointer<UTF8.CodeUnit>,
_ bufferLength: UWord, _ value: Float${bits}
) -> UWord
_ bufferLength: UInt, _ value: Float${bits}
) -> UInt
func _float${bits}ToString(value: Float${bits}) -> String {
_sanityCheck(sizeof(_Buffer32.self) == 32)
@@ -326,9 +326,9 @@ func _float${bits}ToString(value: Float${bits}) -> String {
@asmname("swift_int64ToString")
func _int64ToStringImpl(
buffer: UnsafeMutablePointer<UTF8.CodeUnit>,
_ bufferLength: UWord, _ value: Int64,
_ bufferLength: UInt, _ value: Int64,
_ radix: Int64, _ uppercase: Bool
) -> UWord
) -> UInt
func _int64ToString(
value: Int64, radix: Int64 = 10, uppercase: Bool = false
@@ -363,8 +363,8 @@ func _int64ToString(
@asmname("swift_uint64ToString")
func _uint64ToStringImpl(
buffer: UnsafeMutablePointer<UTF8.CodeUnit>,
_ bufferLength: UWord, _ value: UInt64, _ radix: Int64, _ uppercase: Bool
) -> UWord
_ bufferLength: UInt, _ value: UInt64, _ radix: Int64, _ uppercase: Bool
) -> UInt
public // @testable
func _uint64ToString(
@@ -399,7 +399,7 @@ func _uint64ToString(
func _rawPointerToString(value: Builtin.RawPointer) -> String {
var result = _uint64ToString(
UInt64(unsafeBitCast(value, UWord.self)), radix: 16, uppercase: false)
UInt64(unsafeBitCast(value, UInt.self)), radix: 16, uppercase: false)
for _ in 0..<(2 * sizeof(Builtin.RawPointer) - result.utf16.count) {
result = "0" + result
}

View File

@@ -75,7 +75,7 @@ public struct StaticString
_precondition(
!hasPointerRepresentation,
"StaticString should have Unicode scalar representation")
return UnicodeScalar(UInt32(unsafeBitCast(_startPtrOrData, UWord.self)))
return UnicodeScalar(UInt32(unsafeBitCast(_startPtrOrData, UInt.self)))
}
/// If `self` stores a pointer to ASCII or UTF-8 code units, the
@@ -84,11 +84,11 @@ public struct StaticString
/// If `self` stores a single Unicode scalar value, the value of
/// `byteSize` is unspecified.
@transparent
public var byteSize: Word {
public var byteSize: Int {
_precondition(
hasPointerRepresentation,
"StaticString should have pointer representation")
return Word(_byteSize)
return Int(_byteSize)
}
/// `true` iff `self` stores a pointer to ASCII or UTF-8 code units.
@@ -158,7 +158,7 @@ public struct StaticString
unicodeScalar: Builtin.Int32
) {
self._startPtrOrData =
unsafeBitCast(UWord(UInt32(unicodeScalar)), COpaquePointer.self)._rawValue
unsafeBitCast(UInt(UInt32(unicodeScalar)), COpaquePointer.self)._rawValue
self._byteSize = 0._builtinWordValue
self._flags = UnicodeScalar(unicodeScalar).isASCII()
? (0x3 as UInt8).value

View File

@@ -28,13 +28,13 @@ public struct _StringCore {
//===--------------------------------------------------------------------===//
// Internals
public var _baseAddress: COpaquePointer
var _countAndFlags: UWord
var _countAndFlags: UInt
public var _owner: AnyObject?
/// (private) create the implementation of a string from its component parts.
init(
baseAddress: COpaquePointer,
_countAndFlags: UWord,
_countAndFlags: UInt,
owner: AnyObject?
) {
self._baseAddress = baseAddress
@@ -75,12 +75,12 @@ public struct _StringCore {
}
/// Bitmask for the count part of `_countAndFlags`.
var _countMask: UWord {
return UWord.max >> 2
var _countMask: UInt {
return UInt.max >> 2
}
/// Bitmask for the flags part of `_countAndFlags`.
var _flagMask: UWord {
var _flagMask: UInt {
return ~_countMask
}
@@ -147,12 +147,12 @@ public struct _StringCore {
self._baseAddress = baseAddress
self._countAndFlags
= (UWord(elementShift) << (UWord._sizeInBits - 1))
| ((hasCocoaBuffer ? 1 : 0) << (UWord._sizeInBits - 2))
| UWord(count)
= (UInt(elementShift) << (UInt._sizeInBits - 1))
| ((hasCocoaBuffer ? 1 : 0) << (UInt._sizeInBits - 2))
| UInt(count)
self._owner = owner
_sanityCheck(UWord(count) & _flagMask == 0, "String too long to represent")
_sanityCheck(UInt(count) & _flagMask == 0, "String too long to represent")
_invariantCheck()
}
@@ -187,15 +187,15 @@ public struct _StringCore {
return Int(_countAndFlags & _countMask)
}
set(newValue) {
_sanityCheck(UWord(newValue) & _flagMask == 0)
_countAndFlags = (_countAndFlags & _flagMask) | UWord(newValue)
_sanityCheck(UInt(newValue) & _flagMask == 0)
_countAndFlags = (_countAndFlags & _flagMask) | UInt(newValue)
}
}
/// Left shift amount to apply to an offset N so that when
/// added to a UnsafeMutablePointer<RawByte>, it traverses N elements.
var elementShift: Int {
return Int(_countAndFlags >> (UWord._sizeInBits - 1))
return Int(_countAndFlags >> (UInt._sizeInBits - 1))
}
/// The number of bytes per element.
@@ -216,7 +216,7 @@ public struct _StringCore {
/// Are we using an `NSString` for storage?
public var hasCocoaBuffer: Bool {
return Word((_countAndFlags << 1).value) < 0
return Int((_countAndFlags << 1).value) < 0
}
public var startASCII: UnsafeMutablePointer<UTF8.CodeUnit> {
@@ -272,12 +272,12 @@ public struct _StringCore {
"subscript: subRange extends past String end")
let newCount = subRange.endIndex - subRange.startIndex
_sanityCheck(UWord(newCount) & _flagMask == 0)
_sanityCheck(UInt(newCount) & _flagMask == 0)
if hasContiguousStorage {
return _StringCore(
baseAddress: _pointerToNth(subRange.startIndex),
_countAndFlags: (_countAndFlags & _flagMask) | UWord(newCount),
_countAndFlags: (_countAndFlags & _flagMask) | UInt(newCount),
owner: _owner)
}
#if _runtime(_ObjC)

View File

@@ -81,7 +81,7 @@ extension _SwiftNativeNSArrayWithContiguousStorage: _NSArrayCoreType {
// These objects are "returned" at +0, so treat them as values to
// avoid retains.
UnsafeMutablePointer<Word>(aBuffer).initializeFrom(
UnsafeMutablePointer<Int>(aBuffer).initializeFrom(
UnsafeMutablePointer(objects.baseAddress + range.location),
count: range.length)
}

View File

@@ -68,7 +68,7 @@ public struct ${Self}<Memory>
///
/// This is a fundamentally unsafe conversion.
@transparent
public init(bitPattern: Word) {
public init(bitPattern: Int) {
self._rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
}
@@ -76,7 +76,7 @@ public struct ${Self}<Memory>
///
/// This is a fundamentally unsafe conversion.
@transparent
public init(bitPattern: UWord) {
public init(bitPattern: UInt) {
self._rawValue = Builtin.inttoptr_Word(bitPattern._builtinWordValue)
}

View File

@@ -41,7 +41,7 @@ public protocol CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
var _cVarArgEncoding: [Word] { get }
var _cVarArgEncoding: [Int] { get }
}
/// Floating point types need to be passed differently on x86_64
@@ -49,7 +49,7 @@ public protocol CVarArgType {
public // SPI(CoreGraphics)
protocol _CVarArgPassedAsDouble : CVarArgType {}
/// Some types require alignment greater than Word on some architectures.
/// Some types require alignment greater than Int on some architectures.
public // SPI(CoreGraphics)
protocol _CVarArgAlignedType : CVarArgType {
/// Return the required alignment in bytes of
@@ -100,9 +100,9 @@ public func getVaList(args: [CVarArgType]) -> CVaListPointer {
return builder.va_list()
}
public func _encodeBitsAsWords<T : CVarArgType>(x: T) -> [Word] {
let result = [Word](
count: (sizeof(T.self) + sizeof(Word.self) - 1) / sizeof(Word.self),
public func _encodeBitsAsWords<T : CVarArgType>(x: T) -> [Int] {
let result = [Int](
count: (sizeof(T.self) + sizeof(Int.self) - 1) / sizeof(Int.self),
repeatedValue: 0)
var tmp = x
_memcpy(dest: UnsafeMutablePointer(result._baseAddressIfContiguous),
@@ -119,7 +119,7 @@ public func _encodeBitsAsWords<T : CVarArgType>(x: T) -> [Word] {
extension Int : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -127,7 +127,7 @@ extension Int : CVarArgType {
extension Int64 : CVarArgType, _CVarArgAlignedType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
@@ -142,7 +142,7 @@ extension Int64 : CVarArgType, _CVarArgAlignedType {
extension Int32 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -150,7 +150,7 @@ extension Int32 : CVarArgType {
extension Int16 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(CInt(self))
}
}
@@ -158,7 +158,7 @@ extension Int16 : CVarArgType {
extension Int8 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(CInt(self))
}
}
@@ -167,7 +167,7 @@ extension Int8 : CVarArgType {
extension UInt : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -175,7 +175,7 @@ extension UInt : CVarArgType {
extension UInt64 : CVarArgType, _CVarArgAlignedType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
@@ -190,7 +190,7 @@ extension UInt64 : CVarArgType, _CVarArgAlignedType {
extension UInt32 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -198,7 +198,7 @@ extension UInt32 : CVarArgType {
extension UInt16 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(CUnsignedInt(self))
}
}
@@ -206,7 +206,7 @@ extension UInt16 : CVarArgType {
extension UInt8 : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(CUnsignedInt(self))
}
}
@@ -214,7 +214,7 @@ extension UInt8 : CVarArgType {
extension COpaquePointer : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -222,7 +222,7 @@ extension COpaquePointer : CVarArgType {
extension UnsafePointer : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -230,7 +230,7 @@ extension UnsafePointer : CVarArgType {
extension UnsafeMutablePointer : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -238,7 +238,7 @@ extension UnsafeMutablePointer : CVarArgType {
extension AutoreleasingUnsafeMutablePointer : CVarArgType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
}
@@ -246,7 +246,7 @@ extension AutoreleasingUnsafeMutablePointer : CVarArgType {
extension Float : _CVarArgPassedAsDouble, _CVarArgAlignedType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(Double(self))
}
@@ -261,7 +261,7 @@ extension Float : _CVarArgPassedAsDouble, _CVarArgAlignedType {
extension Double : _CVarArgPassedAsDouble, _CVarArgAlignedType {
/// Transform `self` into a series of machine words that can be
/// appropriately interpreted by C varargs.
public var _cVarArgEncoding: [Word] {
public var _cVarArgEncoding: [Int] {
return _encodeBitsAsWords(self)
}
@@ -282,16 +282,16 @@ final public class VaListBuilder {
func append(arg: CVarArgType) {
// Write alignment padding if necessary.
// This is needed on architectures where the ABI alignment of some
// supported vararg type is greater than the alignment of Word.
// supported vararg type is greater than the alignment of Int.
// FIXME: this implementation is not portable because
// alignof differs from the ABI alignment on some architectures
#if os(watchOS) && arch(arm) // FIXME: rdar://21203036 should be arch(armv7k)
if let arg = arg as? _CVarArgAlignedType {
let alignmentInWords = arg._cVarArgAlignment / sizeof(Word)
let alignmentInWords = arg._cVarArgAlignment / sizeof(Int)
let misalignmentInWords = count % alignmentInWords
if misalignmentInWords != 0 {
let paddingInWords = alignmentInWords - misalignmentInWords
appendWords([Word](count: paddingInWords, repeatedValue: -1))
appendWords([Int](count: paddingInWords, repeatedValue: -1))
}
}
#endif
@@ -308,7 +308,7 @@ final public class VaListBuilder {
// but possibly more aligned than that.
// FIXME: this should be packaged into a better storage type
func appendWords(words: [Word]) {
func appendWords(words: [Int]) {
let newCount = count + words.count
if newCount > allocated {
let oldAllocated = allocated
@@ -331,21 +331,21 @@ final public class VaListBuilder {
}
}
func rawSizeAndAlignment(wordCount: Int)
-> (Builtin.Word, Builtin.Word) {
return ((wordCount * strideof(Word.self))._builtinWordValue,
func rawSizeAndAlignment(wordCount: Int) -> (Builtin.Word, Builtin.Word) {
return ((wordCount * strideof(Int.self))._builtinWordValue,
requiredAlignmentInBytes._builtinWordValue)
}
func allocStorage(wordCount wordCount: Int)
-> UnsafeMutablePointer<Word> {
func allocStorage(wordCount wordCount: Int) -> UnsafeMutablePointer<Int> {
let (rawSize, rawAlignment) = rawSizeAndAlignment(wordCount)
let rawStorage = Builtin.allocRaw(rawSize, rawAlignment)
return UnsafeMutablePointer<Word>(rawStorage)
return UnsafeMutablePointer<Int>(rawStorage)
}
func deallocStorage(wordCount wordCount: Int,
storage: UnsafeMutablePointer<Word>) {
func deallocStorage(
wordCount wordCount: Int,
storage: UnsafeMutablePointer<Int>
) {
let (rawSize, rawAlignment) = rawSizeAndAlignment(wordCount)
Builtin.deallocRaw(storage._rawValue, rawSize, rawAlignment)
}
@@ -360,7 +360,7 @@ final public class VaListBuilder {
let requiredAlignmentInBytes = alignof(Double.self)
var count = 0
var allocated = 0
var storage: UnsafeMutablePointer<Word> = nil
var storage: UnsafeMutablePointer<Int> = nil
}
#else
@@ -371,9 +371,9 @@ final public class VaListBuilder {
struct Header {
var gp_offset = CUnsignedInt(0)
var fp_offset = CUnsignedInt(_x86_64CountGPRegisters * strideof(Word.self))
var overflow_arg_area: UnsafeMutablePointer<Word> = nil
var reg_save_area: UnsafeMutablePointer<Word> = nil
var fp_offset = CUnsignedInt(_x86_64CountGPRegisters * strideof(Int.self))
var overflow_arg_area: UnsafeMutablePointer<Int> = nil
var reg_save_area: UnsafeMutablePointer<Int> = nil
}
init() {
@@ -418,7 +418,7 @@ final public class VaListBuilder {
final // Property must be final since it is used by Builtin.addressof.
var header = Header()
var storage: [Word]
var storage: [Int]
}
#endif