Files
swift-mirror/stdlib/core/StaticString.swift
Jordan Rose 748efed913 [Accessibility] Protocol witnesses must be as accessible as the protocol.
...unless the type has less accessibility than the protocol, in which case
they must be as accessible as the type.

This restriction applies even with access control checking disabled, but
shouldn't affect any decls not already marked with access control modifiers.

Swift SVN r19382
2014-06-30 23:38:35 +00:00

69 lines
2.2 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// Implementation Note: Because StaticString is used in the
// implementation of assert() and fatal(), we keep it extremely close
// to the bare metal. In particular, because we use only Builtin
// types, we are guaranteed that no assertions are involved in its
// construction. This feature is crucial for preventing infinite
// recursion even in non-asserting cases.
/// An extremely simple string designed to represent something
/// "statically knowable".
@public struct StaticString
: _BuiltinExtendedGraphemeClusterLiteralConvertible,
ExtendedGraphemeClusterLiteralConvertible,
_BuiltinStringLiteralConvertible, StringLiteralConvertible {
@public var start: Builtin.RawPointer
@public var byteSize: Builtin.Word
@public var isASCII: Builtin.Int1
@public init() {
self = ""
}
init(
start: Builtin.RawPointer, byteSize: Builtin.Word, isASCII: Builtin.Int1
) {
self.start = start
self.byteSize = byteSize
self.isASCII = isASCII
}
@public
static func _convertFromBuiltinExtendedGraphemeClusterLiteral(
start: Builtin.RawPointer,
byteSize: Builtin.Word,
isASCII: Builtin.Int1) -> StaticString {
return _convertFromBuiltinStringLiteral(
start, byteSize: byteSize, isASCII: isASCII)
}
@public static func convertFromExtendedGraphemeClusterLiteral(
value: StaticString) -> StaticString {
return value
}
@public
static func _convertFromBuiltinStringLiteral(
start: Builtin.RawPointer, byteSize: Builtin.Word, isASCII: Builtin.Int1
) -> StaticString {
return StaticString(start: start, byteSize: byteSize, isASCII: isASCII)
}
@public
static func convertFromStringLiteral(value: StaticString) -> StaticString {
return value
}
}