What's New / Storage, System & Virtualization

What's new in Runtime

+3 NewmacOS

Runtime exposes the Swift runtime's support APIs, including name demangling that converts mangled Swift symbol names back to readable form.

The 27 SDK adds 3 APIs and removes none. There is a new DemanglingError enum and two demangle entry points that report failures through it. No deprecations or removals.

New

3
func

demangle

NewmacOS
public func demangle(_ mangledName: String) throws(DemanglingError) -> String

Given a mangled Swift symbol, demangle it into a human readable format.

If the provided string is not a valid mangled swift identifier this function will throw. If mangling succeeds the returned string will contain a demangled human-readable representation of the identifier.

Warning: The demangled output is lossy is not not guaranteed to be stable across Swift versions. Future versions of Swift may choose to print more (or less) information in the demangled format.

Parameters

mangledName
A mangled Swift symbol.

ReturnsA human readable demangled Swift symbol. Throws: When the demangling fails for any reason.

func

demangle

NewmacOS
public func demangle(_ mangledName: borrowing UTF8Span, into output: inout OutputSpan<UTF8.CodeUnit>) throws(DemanglingError)

Given a mangled Swift symbol, demangle it into a human readable format into the prepared output span.

If the provided bytes are not a valid mangled swift name, the output span will be initialized with zero elements. If mangling succeeds the output span will contain the resulting demangled string. A successfully demangled string is _not_ null terminated, and its length is communicated by the initializedCount of the output span.

The demangled output may be _truncated_ if the output span's capacity is insufficient for the demangled output string! You can detect this situation by inspecting the returned DemanglingResult, for the truncated case.

Warning: The demangled output is lossy is not not guaranteed to be stable across Swift versions. Future versions of Swift may choose to print more (or less) information in the demangled format.

Parameters

mangledName
A mangled Swift symbol.
output
A pre-allocated span to demangle the Swift symbol into.

ReturnsThrows: When the demangling failed entirely, and the output span will not have been written to.

enum

DemanglingError

NewmacOS
public enum DemanglingError : Error

Error thrown to indicate failure to demangle a Swift symbol.

Declaration
public enum DemanglingError : Error {

    /// Demangling resulted in truncating the result. The payload value is the
    /// number of bytes necessary for a full demangle.
    case truncated(requiredBufferSize: Int)

    /// The passed Swift mangled symbol was invalid.
    case invalidSymbol
}

No APIs match your filter.

← More in Storage, System & Virtualization