Skip to content

Commit e97b1c8

Browse files
authored
Revert "[cxx-interop] Add conversions between std::u16string and Swift.String"
1 parent 4573dd6 commit e97b1c8

File tree

2 files changed

+0
-59
lines changed

2 files changed

+0
-59
lines changed

stdlib/public/Cxx/std/String.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// MARK: Initializing C++ string from a Swift String
14-
1513
extension std.string {
1614
public init(_ string: String) {
1715
self.init()
@@ -21,31 +19,12 @@ extension std.string {
2119
}
2220
}
2321

24-
extension std.u16string {
25-
public init(_ string: String) {
26-
self.init()
27-
for char in string.utf16 {
28-
self.push_back(char)
29-
}
30-
}
31-
}
32-
33-
// MARK: Initializing C++ string from a Swift String literal
34-
3522
extension std.string: ExpressibleByStringLiteral {
3623
public init(stringLiteral value: String) {
3724
self.init(value)
3825
}
3926
}
4027

41-
extension std.u16string: ExpressibleByStringLiteral {
42-
public init(stringLiteral value: String) {
43-
self.init(value)
44-
}
45-
}
46-
47-
// MARK: Initializing Swift String from a C++ string
48-
4928
extension String {
5029
public init(cxxString: std.string) {
5130
let buffer = UnsafeBufferPointer<CChar>(
@@ -56,12 +35,4 @@ extension String {
5635
}
5736
withExtendedLifetime(cxxString) {}
5837
}
59-
60-
public init(cxxU16String: std.u16string) {
61-
let buffer = UnsafeBufferPointer<UInt16>(
62-
start: cxxU16String.__dataUnsafe(),
63-
count: cxxU16String.size())
64-
self = String(decoding: buffer, as: UTF16.self)
65-
withExtendedLifetime(cxxU16String) {}
66-
}
6738
}

test/Interop/Cxx/stdlib/overlay/std-string-overlay.swift

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,6 @@ StdStringOverlayTestSuite.test("std::string <=> Swift.String") {
3737
expectEqual(swift6, "xyz\0abc")
3838
}
3939

40-
StdStringOverlayTestSuite.test("std::u16string <=> Swift.String") {
41-
let cxx1 = std.u16string()
42-
let swift1 = String(cxxU16String: cxx1)
43-
expectEqual(swift1, "")
44-
45-
let cxx2 = std.u16string("something123")
46-
expectEqual(cxx2.size(), 12)
47-
let swift2 = String(cxxU16String: cxx2)
48-
expectEqual(swift2, "something123")
49-
50-
let cxx3: std.u16string = "literal"
51-
expectEqual(cxx3.size(), 7)
52-
53-
let cxx4: std.u16string = "тест"
54-
expectEqual(cxx4.size(), 4)
55-
let swift4 = String(cxxU16String: cxx4)
56-
expectEqual(swift4, "тест")
57-
58-
// Emojis are represented by more than one CWideChar.
59-
let cxx5: std.u16string = "emoji_🤖"
60-
expectEqual(cxx5.size(), 8)
61-
let swift5 = String(cxxU16String: cxx5)
62-
expectEqual(swift5, "emoji_🤖")
63-
64-
let cxx6 = std.u16string("xyz\0abc")
65-
expectEqual(cxx6.size(), 7)
66-
let swift6 = String(cxxU16String: cxx6)
67-
expectEqual(swift6, "xyz\0abc")
68-
}
69-
7040
extension std.string.const_iterator: UnsafeCxxInputIterator {
7141
// This func should not be required.
7242
public static func ==(lhs: std.string.const_iterator,

0 commit comments

Comments
 (0)