Skip to content

Commit 79d8de9

Browse files
authored
Merge pull request #77240 from kubamracek/embedded-printing-types
[embedded] Make Bool string-interpolatable in Embedded Swift, clarify support in docs
2 parents 1af1af7 + 68e01f2 commit 79d8de9

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

docs/EmbeddedSwift/EmbeddedSwiftStatus.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ This status table describes which of the following standard library features can
3838
| Collection algorithms (sort, reverse) | Yes |
3939
| CustomStringConvertible, CustomDebugStringConvertible | Yes, except those that require reflection (e.g. Array's .description) |
4040
| Dictionary (dynamic heap-allocated container) | Yes |
41+
| Floating-point conversion to string | No |
42+
| Floating-point parsing | No |
4143
| FixedWidthInteger + related protocols | Yes |
4244
| Hashable, Equatable, Comparable protocols | Yes |
4345
| InputStream, OutputStream | No |
46+
| Integer conversion to string | Yes |
4447
| Integer parsing | No |
4548
| KeyPaths | Partial (only compile-time constant key paths to stored properties supported, only usable in MemoryLayout and UnsafePointer APIs) |
4649
| Lazy collections | No |
@@ -55,7 +58,7 @@ This status table describes which of the following standard library features can
5558
| SIMD types | Yes |
5659
| StaticString | Yes |
5760
| String (dynamic) | Yes |
58-
| String Interpolations | Yes |
61+
| String interpolations | Partial (only strings, integers, booleans, and custom types that are CustomStringConvertible can be interpolated) |
5962
| Unicode | Yes |
6063
| Unsafe\[Mutable\]\[Raw\]\[Buffer\]Pointer | Yes |
6164
| VarArgs | No |
@@ -66,7 +69,7 @@ This status table describes which of the following Swift features can be used in
6669

6770
| **Swift Feature** | **Currently Supported In Embedded Swift?** |
6871
|------------------------------------------------------------|-----------------------------------------------------|
69-
| Synchronization module | Yes |
72+
| Synchronization module | Partial (only Atomic types, no Mutex) |
7073
| Swift Concurrency | Partial, experimental (basics of actors and tasks work in single-threaded concurrency mode) |
7174
| C interop | Yes |
7275
| C++ interop | Yes |

stdlib/public/core/Bool.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ extension Bool: _ExpressibleByBuiltinBooleanLiteral, ExpressibleByBooleanLiteral
170170
}
171171
}
172172

173-
@_unavailableInEmbedded
174173
extension Bool: CustomStringConvertible {
175174
/// A textual representation of the Boolean value.
176175
@inlinable

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public struct ${Self} {
9292
}
9393

9494
${Availability(bits)}
95-
@_unavailableInEmbedded
9695
extension ${Self}: CustomStringConvertible {
9796
/// A textual representation of the value.
9897
///
@@ -115,7 +114,6 @@ extension ${Self}: CustomStringConvertible {
115114
}
116115

117116
${Availability(bits)}
118-
@_unavailableInEmbedded
119117
extension ${Self}: CustomDebugStringConvertible {
120118
/// A textual representation of the value, suitable for debugging.
121119
///
@@ -131,7 +129,6 @@ extension ${Self}: CustomDebugStringConvertible {
131129
}
132130

133131
${Availability(bits)}
134-
@_unavailableInEmbedded
135132
extension ${Self}: TextOutputStreamable {
136133
public func write<Target>(to target: inout Target) where Target: TextOutputStream {
137134
var (buffer, length) = _float${bits}ToString(self, debug: true)

stdlib/public/core/StaticString.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ extension StaticString: ExpressibleByStringLiteral {
296296
}
297297
}
298298

299-
@_unavailableInEmbedded
300299
extension StaticString: CustomStringConvertible {
301300

302301
/// A textual representation of the static string.
@@ -305,7 +304,6 @@ extension StaticString: CustomStringConvertible {
305304
}
306305
}
307306

308-
@_unavailableInEmbedded
309307
extension StaticString: CustomDebugStringConvertible {
310308

311309
/// A textual representation of the static string, suitable for debugging.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %target-run-simple-swift(-Osize -swift-version 5 -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo) | %FileCheck %s
2+
3+
// REQUIRES: swift_in_compiler
4+
// REQUIRES: executable_test
5+
// REQUIRES: optimized_stdlib
6+
// REQUIRES: OS=macosx || OS=linux-gnu
7+
8+
@main
9+
struct Main {
10+
static func main() {
11+
print("string: \("string")")
12+
// CHECK: string: string
13+
14+
print("static string: \("string" as StaticString)")
15+
// CHECK: static string: string
16+
17+
print("integers: \(42) \(-42) \(0xffffffff)")
18+
// CHECK: integers: 42 -42 4294967295
19+
20+
print("booleans: \(true) \(false)")
21+
// CHECK: booleans: true false
22+
}
23+
}

0 commit comments

Comments
 (0)