Make internal stdlib functions public, which are called from the stdlib tests.

And make sure that all those public identifiers are preceeded with underscores.

I marked these public-modifiers with "// @testable" to document why they are public.
If some day we have a @testable attribute it should be used instead of those public-modifiers.

Again, this is needed for enabling dead internal function elimination in the stdlib.



Swift SVN r22657
This commit is contained in:
Erik Eckstein
2014-10-10 09:45:10 +00:00
parent 3d8008117f
commit d0697f2ac1
19 changed files with 88 additions and 41 deletions

View File

@@ -18,7 +18,8 @@
// UnsafeMutablePointer // UnsafeMutablePointer
@transparent @transparent
internal func _isDebugAssertConfiguration() -> Bool { public // @testable
func _isDebugAssertConfiguration() -> Bool {
// The values for the assert_configuration call are: // The values for the assert_configuration call are:
// 0: Debug // 0: Debug
// 1: Release // 1: Release
@@ -36,7 +37,8 @@ internal func _isReleaseAssertConfiguration() -> Bool {
} }
@transparent @transparent
internal func _isFastAssertConfiguration() -> Bool { public // @testable
func _isFastAssertConfiguration() -> Bool {
// The values for the assert_configuration call are: // The values for the assert_configuration call are:
// 0: Debug // 0: Debug
// 1: Release // 1: Release
@@ -45,6 +47,7 @@ internal func _isFastAssertConfiguration() -> Bool {
} }
@transparent @transparent
public // @testable
func _isStdlibInternalChecksEnabled() -> Bool { func _isStdlibInternalChecksEnabled() -> Bool {
#if INTERNAL_CHECKS_ENABLED #if INTERNAL_CHECKS_ENABLED
return true return true

View File

@@ -64,7 +64,7 @@ def TypedUnaryIntrinsicFunctions():
% for T, CT, bits, ufunc in TypedUnaryIntrinsicFunctions(): % for T, CT, bits, ufunc in TypedUnaryIntrinsicFunctions():
@transparent @transparent
public func _${ufunc}(x: ${T}) -> ${T} { public func _${ufunc}(x: ${T}) -> ${T} {
return ${T}(Builtin.int_${ufunc}_FPIEEE${bits}(x.value)) return ${T}(_bits: Builtin.int_${ufunc}_FPIEEE${bits}(x.value))
} }
% end % end

View File

@@ -234,7 +234,8 @@ extension COpaquePointer {
public struct CVaListPointer { public struct CVaListPointer {
var value: UnsafeMutablePointer<Void> var value: UnsafeMutablePointer<Void>
init(fromUnsafeMutablePointer from: UnsafeMutablePointer<Void>) { public // @testable
init(_fromUnsafeMutablePointer from: UnsafeMutablePointer<Void>) {
value = from value = from
} }
} }

View File

@@ -10,10 +10,15 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Unfortunately it is required to make some types in this file public
// (@testable) just because _lazyConcatenate is called from the
// stdlib unit tests.
/// The `GeneratorType` used by `_ConcatenateSequenceView`, /// The `GeneratorType` used by `_ConcatenateSequenceView`,
/// `_ForwardConcatenateView`, and `_BidirectionalConcatenateView`. /// `_ForwardConcatenateView`, and `_BidirectionalConcatenateView`.
/// Generates a sequence of the elements of the elements of its /// Generates a sequence of the elements of the elements of its
/// argument. /// argument.
public // @testable
struct _ConcatenateSequenceGenerator< struct _ConcatenateSequenceGenerator<
Outer: GeneratorType where Outer.Element : SequenceType Outer: GeneratorType where Outer.Element : SequenceType
>: GeneratorType, SequenceType { >: GeneratorType, SequenceType {
@@ -29,6 +34,7 @@ struct _ConcatenateSequenceGenerator<
/// Requires: `next()` has not been applied to a copy of `self` /// Requires: `next()` has not been applied to a copy of `self`
/// since the copy was made, and no preceding call to `self.next()` /// since the copy was made, and no preceding call to `self.next()`
/// has returned `nil`. /// has returned `nil`.
public // @testable
mutating func next() -> Outer.Element.Generator.Element? { mutating func next() -> Outer.Element.Generator.Element? {
do { do {
if _fastPath(_inner != nil) { if _fastPath(_inner != nil) {
@@ -48,6 +54,7 @@ struct _ConcatenateSequenceGenerator<
/// `_ConcatenateSequenceGenerator` is also a `SequenceType`, so it /// `_ConcatenateSequenceGenerator` is also a `SequenceType`, so it
/// `generate`\ 's a copy of itself /// `generate`\ 's a copy of itself
public // @testable
func generate() -> _ConcatenateSequenceGenerator { func generate() -> _ConcatenateSequenceGenerator {
return self return self
} }
@@ -110,6 +117,7 @@ func _concatenate<
/// A wrapper for a `${IndexProtocol}` for a collection of /// A wrapper for a `${IndexProtocol}` for a collection of
/// collections, that can be used to index the inner elements. /// collections, that can be used to index the inner elements.
public // @testable
struct ${Index}< struct ${Index}<
C: CollectionType C: CollectionType
where C.Index : ${IndexProtocol}, where C.Index : ${IndexProtocol},
@@ -148,6 +156,7 @@ struct ${Index}<
/// Returns the next consecutive value after `self`. /// Returns the next consecutive value after `self`.
/// ///
/// Requires: the next value is representable. /// Requires: the next value is representable.
public // @testable
func successor() -> ${Index} { func successor() -> ${Index} {
return ${Index}.adjustForward(_data, _outer, _inner!.successor()) return ${Index}.adjustForward(_data, _outer, _inner!.successor())
} }
@@ -156,6 +165,7 @@ struct ${Index}<
/// Returns the previous consecutive value before `self`. /// Returns the previous consecutive value before `self`.
/// ///
/// Requires: the previous value is representable. /// Requires: the previous value is representable.
public // @testable
func predecessor() -> ${Index} { func predecessor() -> ${Index} {
var outer = _outer var outer = _outer
@@ -169,12 +179,14 @@ struct ${Index}<
% end % end
} }
public // @testable
func == <I> (lhs: ${Index}<I>, rhs: ${Index}<I>) -> Bool { func == <I> (lhs: ${Index}<I>, rhs: ${Index}<I>) -> Bool {
return lhs._outer == rhs._outer && lhs._inner == rhs._inner return lhs._outer == rhs._outer && lhs._inner == rhs._inner
} }
/// The lazy `CollectionType` returned by `lazyConcatenate(c)` where `c` is a /// The lazy `CollectionType` returned by `lazyConcatenate(c)` where `c` is a
/// `CollectionType` having an `Index` conforming to `${IndexProtocol}` /// `CollectionType` having an `Index` conforming to `${IndexProtocol}`
public // @testable
struct ${View}< struct ${View}<
C: CollectionType C: CollectionType
where C.Index: ${IndexProtocol}, where C.Index: ${IndexProtocol},
@@ -194,6 +206,7 @@ struct ${View}<
/// Return a *generator* over the elements of this *sequence*. /// Return a *generator* over the elements of this *sequence*.
/// ///
/// Complexity: O(1) /// Complexity: O(1)
public // @testable
func generate() -> _ConcatenateSequenceGenerator<C.Generator> { func generate() -> _ConcatenateSequenceGenerator<C.Generator> {
return _ConcatenateSequenceGenerator(_base.generate()) return _ConcatenateSequenceGenerator(_base.generate())
} }
@@ -201,6 +214,7 @@ struct ${View}<
/// The position of the first element in a non-empty collection. /// The position of the first element in a non-empty collection.
/// ///
/// Identical to `endIndex` in an empty collection. /// Identical to `endIndex` in an empty collection.
public // @testable
var startIndex: Index { var startIndex: Index {
return ${Index}.adjustForward(_base, _base.startIndex, nil) return ${Index}.adjustForward(_base, _base.startIndex, nil)
} }
@@ -210,6 +224,7 @@ struct ${View}<
/// `endIndex` is not a valid argument to `subscript`, and is always /// `endIndex` is not a valid argument to `subscript`, and is always
/// reachable from `startIndex` by zero or more applications of /// reachable from `startIndex` by zero or more applications of
/// `successor()`. /// `successor()`.
public // @testable
var endIndex: Index { var endIndex: Index {
return ${Index}(_base, _base.endIndex, nil) return ${Index}(_base, _base.endIndex, nil)
} }
@@ -218,6 +233,7 @@ struct ${View}<
/// ///
/// Requires: `position` is a valid position in `self` and /// Requires: `position` is a valid position in `self` and
/// `position != endIndex`. /// `position != endIndex`.
public // @testable
subscript(position: Index) -> C.Generator.Element.Generator.Element { subscript(position: Index) -> C.Generator.Element.Generator.Element {
return _base[position._outer][position._inner!] return _base[position._outer][position._inner!]
} }
@@ -227,6 +243,7 @@ struct ${View}<
/// Return a collection that is a concatenation of the elements of /// Return a collection that is a concatenation of the elements of
/// `source`\ 's elements /// `source`\ 's elements
public // @testable
func _lazyConcatenate< func _lazyConcatenate<
C: CollectionType C: CollectionType
where C.Index: ${IndexProtocol}, where C.Index: ${IndexProtocol},

View File

@@ -133,7 +133,8 @@ public struct ${Self} {
} }
@transparent @transparent
init(_ v: Builtin.FPIEEE${bits}) { public // @testable
init(_bits v: Builtin.FPIEEE${bits}) {
value = v value = v
} }
@@ -156,7 +157,7 @@ extension ${Self} : FloatingPointType {
public typealias _BitsType = UInt${bits} public typealias _BitsType = UInt${bits}
public static func _fromBitPattern(bits: _BitsType) -> ${Self} { public static func _fromBitPattern(bits: _BitsType) -> ${Self} {
return ${Self}(Builtin.bitcast_Int${bits}_FPIEEE${bits}(bits.value)) return ${Self}(_bits: Builtin.bitcast_Int${bits}_FPIEEE${bits}(bits.value))
} }
public func _toBitPattern() -> _BitsType { public func _toBitPattern() -> _BitsType {
@@ -308,12 +309,12 @@ extension ${Self} /* : FloatingPointType */ {
extension ${Self} : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible { extension ${Self} : _BuiltinIntegerLiteralConvertible, IntegerLiteralConvertible {
public public
init(_builtinIntegerLiteral value: Builtin.Int${builtinIntLiteralBits}){ init(_builtinIntegerLiteral value: Builtin.Int${builtinIntLiteralBits}){
self = ${Self}(Builtin.itofp_with_overflow_Int${builtinIntLiteralBits}_FPIEEE${bits}(value)) self = ${Self}(_bits: Builtin.itofp_with_overflow_Int${builtinIntLiteralBits}_FPIEEE${bits}(value))
} }
/// Create an instance initialized to `value`. /// Create an instance initialized to `value`.
public init(integerLiteral value: Int64) { public init(integerLiteral value: Int64) {
self = ${Self}(Builtin.uitofp_Int64_FPIEEE${bits}(value.value)) self = ${Self}(_bits: Builtin.uitofp_Int64_FPIEEE${bits}(value.value))
} }
} }
@@ -325,9 +326,9 @@ extension ${Self} : _BuiltinFloatLiteralConvertible {
public public
init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) { init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) {
% if bits == builtinFloatLiteralBits: % if bits == builtinFloatLiteralBits:
self = ${Self}(value) self = ${Self}(_bits: value)
% elif bits < builtinFloatLiteralBits: % elif bits < builtinFloatLiteralBits:
self = ${Self}(Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value)) self = ${Self}(_bits: Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
% else: % else:
// FIXME: This is actually losing precision <rdar://problem/14073102>. // FIXME: This is actually losing precision <rdar://problem/14073102>.
self = ${Self}(Builtin.fpext_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value)) self = ${Self}(Builtin.fpext_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
@@ -402,7 +403,7 @@ extension ${Self} : AbsoluteValuable {
/// Returns the absolute value of `x` /// Returns the absolute value of `x`
@transparent @transparent
public static func abs(x: ${Self}) -> ${Self} { public static func abs(x: ${Self}) -> ${Self} {
return ${Self}(Builtin.int_fabs_FPIEEE${bits}(x.value)) return ${Self}(_bits: Builtin.int_fabs_FPIEEE${bits}(x.value))
} }
} }
@@ -413,7 +414,7 @@ public prefix func +(x: ${Self}) -> ${Self} {
@transparent @transparent
public prefix func -(x: ${Self}) -> ${Self} { public prefix func -(x: ${Self}) -> ${Self} {
return ${Self}(Builtin.fneg_FPIEEE${bits}(x.value)) return ${Self}(_bits: Builtin.fneg_FPIEEE${bits}(x.value))
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@@ -500,7 +501,7 @@ extension ${Self} : Strideable {
% for op, name in ('+','fadd'), ('-','fsub'),('*','fmul'), ('/','fdiv'): % for op, name in ('+','fadd'), ('-','fsub'),('*','fmul'), ('/','fdiv'):
@transparent @transparent
public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} { public func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
return ${Self}(Builtin.${name}_FPIEEE${bits}(lhs.value, rhs.value)) return ${Self}(_bits: Builtin.${name}_FPIEEE${bits}(lhs.value, rhs.value))
} }
% end % end

View File

@@ -54,11 +54,9 @@ struct _HashingDetail {
// their inputs and just exhibit avalance effect. // their inputs and just exhibit avalance effect.
// //
// TODO: This function is only public because it is used in the
// stdlib/HashingAvalanche.swift validation test. Check if there is another
// way to let the test access the function.
@transparent @transparent
public func _mixUInt32(value: UInt32) -> UInt32 { public // @testable
func _mixUInt32(value: UInt32) -> UInt32 {
// Zero-extend to 64 bits, hash, select 32 bits from the hash. // Zero-extend to 64 bits, hash, select 32 bits from the hash.
// //
// NOTE: this differs from LLVM's implementation, which selects the lower // NOTE: this differs from LLVM's implementation, which selects the lower
@@ -70,15 +68,14 @@ public func _mixUInt32(value: UInt32) -> UInt32 {
} }
@transparent @transparent
public // @testable
func _mixInt32(value: Int32) -> Int32 { func _mixInt32(value: Int32) -> Int32 {
return Int32(bitPattern: _mixUInt32(UInt32(bitPattern: value))) return Int32(bitPattern: _mixUInt32(UInt32(bitPattern: value)))
} }
// TODO: This function is only public because it is used in the
// stdlib/HashingAvalanche.swift validation test. Check if there is another
// way to let the test access the function.
@transparent @transparent
public func _mixUInt64(value: UInt64) -> UInt64 { public // @testable
func _mixUInt64(value: UInt64) -> UInt64 {
// Similar to hash_4to8_bytes but using a seed instead of length. // Similar to hash_4to8_bytes but using a seed instead of length.
let seed: UInt64 = _HashingDetail.getExecutionSeed() let seed: UInt64 = _HashingDetail.getExecutionSeed()
let low: UInt64 = value & 0xffff_ffff let low: UInt64 = value & 0xffff_ffff
@@ -87,11 +84,13 @@ public func _mixUInt64(value: UInt64) -> UInt64 {
} }
@transparent @transparent
public // @testable
func _mixInt64(value: Int64) -> Int64 { func _mixInt64(value: Int64) -> Int64 {
return Int64(bitPattern: _mixUInt64(UInt64(bitPattern: value))) return Int64(bitPattern: _mixUInt64(UInt64(bitPattern: value)))
} }
@transparent @transparent
public // @testable
func _mixUInt(value: UInt) -> UInt { func _mixUInt(value: UInt) -> UInt {
#if arch(i386) || arch(arm) #if arch(i386) || arch(arm)
return UInt(_mixUInt32(UInt32(value))) return UInt(_mixUInt32(UInt32(value)))
@@ -101,6 +100,7 @@ func _mixUInt(value: UInt) -> UInt {
} }
@transparent @transparent
public // @testable
func _mixInt(value: Int) -> Int { func _mixInt(value: Int) -> Int {
#if arch(i386) || arch(arm) #if arch(i386) || arch(arm)
return Int(_mixInt32(Int32(value))) return Int(_mixInt32(Int32(value)))
@@ -126,6 +126,7 @@ func _mixInt(value: Int) -> Int {
/// hash value does not change anything fundamentally: collisions are still /// hash value does not change anything fundamentally: collisions are still
/// possible, and it does not prevent malicious users from constructing data /// possible, and it does not prevent malicious users from constructing data
/// sets that will exhibit pathological collisions. /// sets that will exhibit pathological collisions.
public // @testable
func _squeezeHashValue(hashValue: Int, resultRange: Range<Int>) -> Int { func _squeezeHashValue(hashValue: Int, resultRange: Range<Int>) -> Int {
// Length of a Range<Int> does not fit into an Int, but fits into an UInt. // Length of a Range<Int> does not fit into an Int, but fits into an UInt.
// An efficient way to compute the length is to rely on two's complement // An efficient way to compute the length is to rely on two's complement
@@ -147,6 +148,7 @@ func _squeezeHashValue(hashValue: Int, resultRange: Range<Int>) -> Int {
UInt(bitPattern: resultRange.startIndex) &+ unsignedResult) UInt(bitPattern: resultRange.startIndex) &+ unsignedResult)
} }
public // @testable
func _squeezeHashValue(hashValue: Int, resultRange: Range<UInt>) -> UInt { func _squeezeHashValue(hashValue: Int, resultRange: Range<UInt>) -> UInt {
let mixedHashValue = UInt(bitPattern: _mixInt(hashValue)) let mixedHashValue = UInt(bitPattern: _mixInt(hashValue))
let resultCardinality: UInt = resultRange.endIndex - resultRange.startIndex let resultCardinality: UInt = resultRange.endIndex - resultRange.startIndex

View File

@@ -15,12 +15,14 @@
// FIXME: Once we have an FFI interface, make these have proper function bodies // FIXME: Once we have an FFI interface, make these have proper function bodies
@transparent @transparent
public // @testable
func _countLeadingZeros(value: Int64) -> Int64 { func _countLeadingZeros(value: Int64) -> Int64 {
return Int64(Builtin.int_ctlz_Int64(value.value, false.value)) return Int64(Builtin.int_ctlz_Int64(value.value, false.value))
} }
/// Returns if `x` is a power of 2. /// Returns if `x` is a power of 2.
@transparent @transparent
public // @testable
func _isPowerOf2(x: UInt) -> Bool { func _isPowerOf2(x: UInt) -> Bool {
if x == 0 { if x == 0 {
return false return false
@@ -32,6 +34,7 @@ func _isPowerOf2(x: UInt) -> Bool {
/// Returns if `x` is a power of 2. /// Returns if `x` is a power of 2.
@transparent @transparent
public // @testable
func _isPowerOf2(x: Int) -> Bool { func _isPowerOf2(x: Int) -> Bool {
if x <= 0 { if x <= 0 {
return false return false
@@ -142,6 +145,7 @@ public func _stdlib_demangleName(mangledName: String) -> String {
/// ///
/// TODO: Implement version working on Int instead of Int64. /// TODO: Implement version working on Int instead of Int64.
@transparent @transparent
public // @testable
func _floorLog2(x: Int64) -> Int { func _floorLog2(x: Int64) -> Int {
_sanityCheck(x > 0, "_floorLog2 operates only on non-negative integers") _sanityCheck(x > 0, "_floorLog2 operates only on non-negative integers")
// Note: use unchecked subtraction because we this expression can not // Note: use unchecked subtraction because we this expression can not

View File

@@ -231,7 +231,7 @@ public func ... <Pos : ForwardIndexType where Pos: Comparable> (
} }
// FIXME: This doesn't work yet: <rdar://problem/17668465> // FIXME: This doesn't work yet: <rdar://problem/17668465>
func ~= <I : ForwardIndexType where I: Comparable> ( public func ~= <I : ForwardIndexType where I: Comparable> (
pattern: Range<I>, value: I pattern: Range<I>, value: I
) -> Bool { ) -> Bool {
// convert to an interval and check that. // convert to an interval and check that.

View File

@@ -56,6 +56,7 @@ func _stdlib_atomicCompareExchangeStrongPtrImpl(
/// compare-and-exchange instruction will operate on the writeback buffer, and /// compare-and-exchange instruction will operate on the writeback buffer, and
/// you will get a *race* while doing writeback into shared memory. /// you will get a *race* while doing writeback into shared memory.
@transparent @transparent
public // @testable
func _stdlib_atomicCompareExchangeStrongPtr<T>( func _stdlib_atomicCompareExchangeStrongPtr<T>(
#object: UnsafeMutablePointer<UnsafeMutablePointer<T>>, #object: UnsafeMutablePointer<UnsafeMutablePointer<T>>,
#expected: UnsafeMutablePointer<UnsafeMutablePointer<T>>, #expected: UnsafeMutablePointer<UnsafeMutablePointer<T>>,
@@ -67,6 +68,7 @@ func _stdlib_atomicCompareExchangeStrongPtr<T>(
} }
@transparent @transparent
public // @testable
func _stdlib_atomicInitializeARCRef( func _stdlib_atomicInitializeARCRef(
#object: UnsafeMutablePointer<AnyObject?>, #object: UnsafeMutablePointer<AnyObject?>,
#desired: AnyObject) -> Bool { #desired: AnyObject) -> Bool {
@@ -195,6 +197,7 @@ func _swift_stdlib_atomicLoadPtrImpl(
) -> COpaquePointer ) -> COpaquePointer
@transparent @transparent
public // @testable
func _stdlib_atomicLoadARCRef( func _stdlib_atomicLoadARCRef(
#object: UnsafeMutablePointer<AnyObject?> #object: UnsafeMutablePointer<AnyObject?>
) -> AnyObject? { ) -> AnyObject? {
@@ -353,6 +356,7 @@ func _uint64ToStringImpl(
bufferLength: UWord, value: UInt64, radix: Int64, uppercase: Bool bufferLength: UWord, value: UInt64, radix: Int64, uppercase: Bool
) -> UWord ) -> UWord
public // @testable
func _uint64ToString( func _uint64ToString(
value: UInt64, radix: Int64 = 10, uppercase: Bool = false value: UInt64, radix: Int64 = 10, uppercase: Bool = false
) -> String { ) -> String {

View File

@@ -28,7 +28,7 @@ var _fastEnumerationStorageMutationsTarget: CUnsignedLong = 0
/// A dummy pointer to be used as `mutationsPtr` in fast enumeration /// A dummy pointer to be used as `mutationsPtr` in fast enumeration
/// implementations. /// implementations.
internal public // @testable
var _fastEnumerationStorageMutationsPtr: UnsafeMutablePointer<CUnsignedLong> { var _fastEnumerationStorageMutationsPtr: UnsafeMutablePointer<CUnsignedLong> {
return UnsafeMutablePointer( return UnsafeMutablePointer(
Builtin.addressof(&_fastEnumerationStorageMutationsTarget)) Builtin.addressof(&_fastEnumerationStorageMutationsTarget))

View File

@@ -134,13 +134,13 @@ public final class _NSContiguousString : _NSSwiftString {
_precondition(aRange.location + aRange.length <= Int(_core.count)) _precondition(aRange.location + aRange.length <= Int(_core.count))
if _core.elementWidth == 2 { if _core.elementWidth == 2 {
UTF16.copy( UTF16._copy(
_core.startUTF16 + aRange.location, _core.startUTF16 + aRange.location,
destination: UnsafeMutablePointer<UInt16>(buffer), destination: UnsafeMutablePointer<UInt16>(buffer),
count: aRange.length) count: aRange.length)
} }
else { else {
UTF16.copy( UTF16._copy(
_core.startASCII + aRange.location, _core.startASCII + aRange.location,
destination: UnsafeMutablePointer<UInt16>(buffer), destination: UnsafeMutablePointer<UInt16>(buffer),
count: aRange.length) count: aRange.length)

View File

@@ -814,16 +814,19 @@ internal func _transcodeSomeUTF16AsUTF8<
/// Instances of conforming types are used in internal `String` /// Instances of conforming types are used in internal `String`
/// representation. /// representation.
internal protocol _StringElementType { public // @testable
protocol _StringElementType {
class func _toUTF16CodeUnit(_: Self) -> UTF16.CodeUnit class func _toUTF16CodeUnit(_: Self) -> UTF16.CodeUnit
class func _fromUTF16CodeUnit(utf16: UTF16.CodeUnit) -> Self class func _fromUTF16CodeUnit(utf16: UTF16.CodeUnit) -> Self
} }
extension UTF16.CodeUnit : _StringElementType { extension UTF16.CodeUnit : _StringElementType {
internal static func _toUTF16CodeUnit(x: UTF16.CodeUnit) -> UTF16.CodeUnit { public // @testable
static func _toUTF16CodeUnit(x: UTF16.CodeUnit) -> UTF16.CodeUnit {
return x return x
} }
internal static func _fromUTF16CodeUnit( public // @testable
static func _fromUTF16CodeUnit(
utf16: UTF16.CodeUnit utf16: UTF16.CodeUnit
) -> UTF16.CodeUnit { ) -> UTF16.CodeUnit {
return utf16 return utf16
@@ -831,11 +834,13 @@ extension UTF16.CodeUnit : _StringElementType {
} }
extension UTF8.CodeUnit : _StringElementType { extension UTF8.CodeUnit : _StringElementType {
internal static func _toUTF16CodeUnit(x: UTF8.CodeUnit) -> UTF16.CodeUnit { public // @testable
static func _toUTF16CodeUnit(x: UTF8.CodeUnit) -> UTF16.CodeUnit {
_sanityCheck(x <= 0x7f, "should only be doing this with ASCII") _sanityCheck(x <= 0x7f, "should only be doing this with ASCII")
return UTF16.CodeUnit(x) return UTF16.CodeUnit(x)
} }
internal static func _fromUTF16CodeUnit( public // @testable
static func _fromUTF16CodeUnit(
utf16: UTF16.CodeUnit utf16: UTF16.CodeUnit
) -> UTF8.CodeUnit { ) -> UTF8.CodeUnit {
_sanityCheck(utf16 <= 0x7f, "should only be doing this with ASCII") _sanityCheck(utf16 <= 0x7f, "should only be doing this with ASCII")
@@ -872,7 +877,8 @@ extension UTF16 {
) + 0xDC00 ) + 0xDC00
} }
internal static func copy<T : _StringElementType, U : _StringElementType>( public // @testable
static func _copy<T : _StringElementType, U : _StringElementType>(
source: UnsafeMutablePointer<T>, source: UnsafeMutablePointer<T>,
destination: UnsafeMutablePointer<U>, count: Int destination: UnsafeMutablePointer<U>, count: Int
) { ) {

View File

@@ -192,6 +192,7 @@ public struct UnicodeScalar :
} }
// FIXME: Unicode makes this interesting. // FIXME: Unicode makes this interesting.
public // @testable
func _isSpace() -> Bool { func _isSpace() -> Bool {
// FIXME: The constraint-based type checker goes painfully exponential // FIXME: The constraint-based type checker goes painfully exponential
// when we turn this into one large expression. Break it up for now, // when we turn this into one large expression. Break it up for now,

View File

@@ -44,7 +44,8 @@ SuppDataBytesOffset = 12817
import SwiftShims import SwiftShims
internal enum _GraphemeClusterBreakPropertyValue : Int, Printable { public // @testable
enum _GraphemeClusterBreakPropertyValue : Int, Printable {
case Other = 0 case Other = 0
case CR = 1 case CR = 1
case LF = 2 case LF = 2
@@ -60,6 +61,7 @@ internal enum _GraphemeClusterBreakPropertyValue : Int, Printable {
case LVT = 12 case LVT = 12
/// A textual representation of `self`. /// A textual representation of `self`.
public // @testable
var description: String { var description: String {
switch self { switch self {
case Other: case Other:
@@ -109,7 +111,8 @@ struct _GraphemeClusterBreakPropertyRawValue {
} }
} }
internal struct _UnicodeGraphemeClusterBreakPropertyTrie { public // @testable
struct _UnicodeGraphemeClusterBreakPropertyTrie {
static func _checkParameters() { static func _checkParameters() {
let metadata = _swift_stdlib_GraphemeClusterBreakPropertyTrieMetadata let metadata = _swift_stdlib_GraphemeClusterBreakPropertyTrieMetadata
@@ -166,6 +169,7 @@ internal struct _UnicodeGraphemeClusterBreakPropertyTrie {
} }
% end % end
public // @testable
init() { init() {
_UnicodeGraphemeClusterBreakPropertyTrie._checkParameters() _UnicodeGraphemeClusterBreakPropertyTrie._checkParameters()
_trieData = _swift_stdlib_GraphemeClusterBreakPropertyTrie _trieData = _swift_stdlib_GraphemeClusterBreakPropertyTrie
@@ -225,6 +229,7 @@ internal struct _UnicodeGraphemeClusterBreakPropertyTrie {
} }
} }
public // @testable
func getPropertyValue( func getPropertyValue(
codePoint: UInt32 codePoint: UInt32
) -> _GraphemeClusterBreakPropertyValue { ) -> _GraphemeClusterBreakPropertyValue {

View File

@@ -263,7 +263,7 @@ final public class VaListBuilder {
header.overflow_arg_area header.overflow_arg_area
= storage._baseAddressIfContiguous + _x86_64RegisterSaveWords = storage._baseAddressIfContiguous + _x86_64RegisterSaveWords
return CVaListPointer( return CVaListPointer(
fromUnsafeMutablePointer: UnsafeMutablePointer<Void>( _fromUnsafeMutablePointer: UnsafeMutablePointer<Void>(
Builtin.addressof(&self.header))) Builtin.addressof(&self.header)))
} }

View File

@@ -154,7 +154,10 @@ func test() {
let n2 = a0~>_copyToNativeArrayBuffer() let n2 = a0~>_copyToNativeArrayBuffer()
// CHECK-NEXT: true // CHECK-NEXT: true
println(n1 === n2)
// TODO: The following check is currently disabled because the === function
// is not public. But this test() function is not called anyway.
// println(n1 === n2)
} }
// CHECK-NEXT: trackedCount = 0 // CHECK-NEXT: trackedCount = 0

View File

@@ -42,7 +42,7 @@ extension Float80 {
Builtin.zextOrBitCast_Int64_Int80((64 as Int64).value)) Builtin.zextOrBitCast_Int64_Int80((64 as Int64).value))
result = Builtin.or_Int80( result = Builtin.or_Int80(
result, Builtin.zextOrBitCast_Int64_Int80(bits.significand.value)) result, Builtin.zextOrBitCast_Int64_Int80(bits.significand.value))
return Float80(Builtin.bitcast_Int80_FPIEEE80(result)) return Float80(_bits: Builtin.bitcast_Int80_FPIEEE80(result))
} }
} }

View File

@@ -474,7 +474,7 @@ func test_PointerPrinting() {
printedIs(COpaquePointer(), expectedNull) printedIs(COpaquePointer(), expectedNull)
printedIs(CFunctionPointer<() -> ()>(), expectedNull) printedIs(CFunctionPointer<() -> ()>(), expectedNull)
printedIs(CVaListPointer(fromUnsafeMutablePointer: nullUP), expectedNull) printedIs(CVaListPointer(_fromUnsafeMutablePointer: nullUP), expectedNull)
printedIs(AutoreleasingUnsafeMutablePointer<Int>(), expectedNull) printedIs(AutoreleasingUnsafeMutablePointer<Int>(), expectedNull)
println("test_PointerPrinting done") println("test_PointerPrinting done")

View File

@@ -27,16 +27,16 @@ UnicodeInternals.test("copy") {
(u8)->() in (u8)->() in
let p8 = u8.baseAddress let p8 = u8.baseAddress
UTF16.copy(p8, destination: p16, count: 3) UTF16._copy(p8, destination: p16, count: 3)
expectEqual([ 0, 1, 2, 9, 10, 11 ], Array(u16)) expectEqual([ 0, 1, 2, 9, 10, 11 ], Array(u16))
UTF16.copy(p16 + 3, destination: p8, count: 3) UTF16._copy(p16 + 3, destination: p8, count: 3)
expectEqual([ 9, 10, 11, 3, 4, 5 ], Array(u8)) expectEqual([ 9, 10, 11, 3, 4, 5 ], Array(u8))
UTF16.copy(p16, destination: p16 + 3, count: 3) UTF16._copy(p16, destination: p16 + 3, count: 3)
expectEqual([ 0, 1, 2, 0, 1, 2 ], Array(u16)) expectEqual([ 0, 1, 2, 0, 1, 2 ], Array(u16))
UTF16.copy(p8, destination: p8 + 3, count: 3) UTF16._copy(p8, destination: p8 + 3, count: 3)
expectEqual([ 9, 10, 11, 9, 10, 11 ], Array(u8)) expectEqual([ 9, 10, 11, 9, 10, 11 ], Array(u8))
} }
} }