-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SE-0134][stdlib] Rename/remove two properties on String #3816
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,20 +13,20 @@ import SwiftShims | |
@_silgen_name("swift_demangle") | ||
public | ||
func _stdlib_demangleImpl( | ||
mangledName: UnsafePointer<UInt8>?, | ||
mangledName: UnsafePointer<CChar>?, | ||
mangledNameLength: UInt, | ||
outputBuffer: UnsafeMutablePointer<UInt8>?, | ||
outputBuffer: UnsafeMutablePointer<CChar>?, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of my depth with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, your version of the code is more correct than what was there before... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is good. |
||
outputBufferSize: UnsafeMutablePointer<UInt>?, | ||
flags: UInt32 | ||
) -> UnsafeMutablePointer<CChar>? | ||
|
||
func _stdlib_demangleName(_ mangledName: String) -> String { | ||
return mangledName.nulTerminatedUTF8.withUnsafeBufferPointer { | ||
(mangledNameUTF8) in | ||
return mangledName.utf8CString.withUnsafeBufferPointer { | ||
(mangledNameUTF8CStr) in | ||
|
||
let demangledNamePtr = _stdlib_demangleImpl( | ||
mangledName: mangledNameUTF8.baseAddress, | ||
mangledNameLength: UInt(mangledNameUTF8.count - 1), | ||
mangledName: mangledNameUTF8CStr.baseAddress, | ||
mangledNameLength: UInt(mangledNameUTF8CStr.count - 1), | ||
outputBuffer: nil, | ||
outputBufferSize: nil, | ||
flags: 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,9 +127,11 @@ class TestData : TestDataSuper { | |
// String of course has its own way to get data, but this way tests our own data struct | ||
func dataFrom(_ string : String) -> Data { | ||
// Create a Data out of those bytes | ||
return string.nulTerminatedUTF8.withUnsafeBufferPointer { (ptr) in | ||
// Subtract 1 so we don't get the null terminator byte. This matches NSString behavior. | ||
return Data(bytes: ptr.baseAddress!, count: ptr.count - 1) | ||
return string.utf8CString.withUnsafeBufferPointer { (ptr) in | ||
ptr.baseAddress!.withMemoryRebound(to: UInt8.self, capacity: ptr.count) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annoyingly, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that issue is separate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @parkera What is the meaning of this? How can corelibs-foundation and Foundation overlay vend different APIs? I would love to change the Foundation overlay to "bytes: UnsafeRawPointer" so that it's usable without breaking the memory model. That change would be mostly source compatible, but, strictly speaking it is source breaking, thus verboten. |
||
// Subtract 1 so we don't get the null terminator byte. This matches NSString behavior. | ||
return Data(bytes: $0, count: ptr.count - 1) | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to mark nulTerminatedUTF8CString unavailable, just delete it. It wasn't on tree long enough for anyone to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done and done.