Commit Graph

88 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
Guillaume Lessard
a77b8cea70 [stdlib] alter inconsistent declarations
`private` declarations should never be allowed to carry the `@_alwaysEmitIntoClient` attribute. This has been allowed by mistake for a while, but newer compilers should make this an error.
2024-08-01 16:26:34 -07:00
Guillaume Lessard
da5b41a0f8 [stdlib] properly rename validatingUTF8 to validatingCString
https://github.com/apple/swift/issues/68433 was fixed
in commit d19f082665.
2024-02-03 16:19:04 -08:00
Guillaume Lessard
e10899eff7 [stdlib] tweak deprecation message 2024-02-01 15:34:18 -08:00
Guillaume Lessard
11485e5026 [doc] fix note visibility for docc-generated pages 2024-02-01 15:34:18 -08:00
Guillaume Lessard
a74b5b7b3c [stdlib] make parameter label the same as in peer functions
These functions were the odd ones out in not using `encoding` for this parameter label. Harmonizing this term will also make the documentation more consistent.
2024-02-01 15:34:18 -08:00
Guillaume Lessard
048a948f12 [stdlib] document some deprecated initializers 2024-02-01 15:34:18 -08:00
Guillaume Lessard
e3ede3ad3a [stdlib] improve phrasing in some doc-comments 2024-02-01 15:34:18 -08:00
Guillaume Lessard
ae9892d46b [stdlib] remove useless annotations 2024-02-01 15:34:18 -08:00
Guillaume Lessard
047092a0a5 [stdlib] mark deprecated in swift 6, point to better API 2024-02-01 15:34:18 -08:00
Guillaume Lessard
4c00395b66 [stdlib] fix preconditionFailure message 2024-02-01 15:34:18 -08:00
Jonathan Grynspan
3da7483c5f Fix the deprecation of String.init(validatingUTF8: [CChar]).
This PR changes the deprecation annotation of `String.init(validatingUTF8: [CChar])` to match that of `String.init(validatingUTF8: UnsafePointer<CChar>)`. Both have been given new, undeprecated, renamed replacements (`validatingCString:`).

Resolves rdar://121674502.
2024-01-26 13:40:27 -05:00
Guillaume Lessard
b67b2cb2c5 link to issue regarding initializer renaming 2024-01-03 14:38:05 -08:00
Guillaume Lessard
561890f3ce [se-0405] tie deprecation to swift 6 language mode 2023-09-13 09:47:34 -07:00
Guillaume Lessard
1f0f30219c [se-0405] rename String.init?(validatingUTF8:) 2023-09-11 14:17:05 -07:00
Guillaume Lessard
152353157c [stdlib] less assumingMemoryBound, rebind instead 2022-04-06 16:18:02 -06:00
Guillaume Lessard
8379b2422a [stdlib] remove most uses of _asCChar and _asUInt8 2022-04-06 15:21:00 -06:00
Guillaume Lessard
b13377726f [stdlib] improve the new deprecation messages 2022-04-05 14:43:03 -06:00
Guillaume Lessard
cfdb44ee7e [test] check deprecation warnings for undesirable overloads 2022-04-04 20:26:40 -06:00
Guillaume Lessard
ec7a725833 [stdlib] overload String-from-C-string initializers in the case of inout conversion 2022-04-04 17:53:54 -06:00
Guillaume Lessard
f49ea0d7d5 [stdlib] String overloads for String-from-C-string inits 2022-04-04 17:44:31 -06:00
Guillaume Lessard
22121d585d [stdlib] overload for arrays passed to String(decodeCString:as:) 2022-04-04 17:44:31 -06:00
Guillaume Lessard
a6474f657b [stdlib] overload for arrays passed to String.init?(validatingUTF8:) 2022-04-01 12:10:16 -06:00
Guillaume Lessard
5dffce5017 [stdlib] overload for arrays passed to String.init(cString:) 2022-04-01 12:10:16 -06:00
Guillaume Lessard
516cdcfe0f [stdlib] harmonize parameter labels with StringProtocol 2022-04-01 12:10:16 -06:00
Valeriy Van
d30661dace Fixes example snippets in CString.swift (#31407)
* Fixes example snippets in CString.swift

* Fixes example snippet in CString.swift
2020-04-29 16:43:27 -07:00
Alex Martini
64c32f3331 Add missing ) and code voice.
rdar://problem/46680213
2019-08-28 10:36:34 -07:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Michael Ilseman
948655e850 [String] Cleanups, comments, documentation
After rebasing on master and incorporating more 32-bit support,
perform a bunch of cleanup, documentation updates, comments, move code
back to String declaration, etc.
2018-11-04 10:42:42 -08:00
Michael Ilseman
4ab45dfe20 [String] Drop in initial UTF-8 String prototype
This is a giant squashing of a lot of individual changes prototyping a
switch of String in Swift 5 to be natively encoded as UTF-8. It
includes what's necessary for a functional prototype, dropping some
history, but still leaves plenty of history available for future
commits.

My apologies to anyone trying to do code archeology between this
commit and the one prior. This was the lesser of evils.
2018-11-04 10:42:40 -08:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Michael Ilseman
fd1c861415 [string] ASCII/UTF-8 fast paths for String.init(decoding:as:)
Add some fast paths to String.init(decoding:as:) for inputs of
contiguously stored UTF-8 code units. Dramatically speeds up creation
when the String happens to be ASCII and we can form more small
strings.
2018-06-15 14:41:26 -07:00
Michael Ilseman
b62241aba4 [string] Cleanup and remove init-from-CString inlinability 2018-05-13 07:38:55 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Michael Ilseman
6d1866f846 [StringGuts] Clean-up in preparation for merge.
Clean up a lot of the scattered utility functions, FIXMEs, etc in
preparation for the merge to master.
2018-01-21 12:38:49 -08:00
Karoy Lorentey
5cf9fd7414 Remove _StringBuffer 🎉🎉🎉 2018-01-21 12:35:15 -08:00
Greg Parker
da14cd79a6 [runtime] Clean up symbol exports in libc functions. (#13202) 2017-12-01 17:49:11 -08:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Maxim Moiseev
ee5fb33656 [stdlib] Remove the Grand Renaming artifacts of Swift 3 era 2017-08-28 15:54:11 -07:00
Nate Cook
b7af9bfe83 [stdlib] Remove SeeAlso tags 2017-06-13 11:23:51 -05:00
Dave Abrahams
41c244a065 [stdlib] Unicode[Encoding|Parser] => Unicode.[Encoding|Parser] 2017-05-11 17:21:39 -07:00
Dave Abrahams
c5d6880053 [stdlib] Add ASCII UnicodeEncoding, drop uses of legacy codecs
Preparation for new C-string interop.
2017-05-07 20:43:44 -07:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Andrew Trick
7b2f91aad8 The _decodeCString helper does not need to be public. (#3726) 2016-07-24 10:24:10 -07:00
Andrew Trick
c7aa8284c9 Add basic CString <-> UTF8 API variants.
As proposed by SE-0107: UnsafeRawPointer:
https://github.com/apple/swift-evolution/blob/master/proposals/0107-unsaferawpointer.md#cstring-conversion
Adds String.init(cString: UnsafePointer<UInt8>)
Adds String.nulTerminatedUTF8CString: ContiguousArray<CChar>

This is necessary for eliminating UnsafePointer conversion.  Such
conversion is extremely common for interoperability between Swift
strings and C strings to bridge the difference between CChar and
UTF8.CodeUnit. The standard library does not provide any convenient
utilities for converting between the differently typed
buffers. These APIs will handle the simplest cases involving C
interoperability. More convenience can be added later.
2016-07-22 23:41:13 -07:00
Maxim Moiseev
38f7ec2a32 [stdlib] Fix the String.decodeCString for UTF16 and UTF32 (#2681)
[stdlib] Fix the `String.decodeCString` for UTF16 and UTF32

Resolves [SR-1578](https://bugs.swift.org/browse/SR-1578]
Essentially the problem was that `strlen` is not the right way of
obtaining a length of anything but null-terminated UTF-8 sequence of
characters. Other encodings require alternative mechanisms.
2016-05-25 15:51:10 -07:00