mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
At the same time, simplify CMakeLists magic for libraries that want to include Swift code in the library. The Lib-less name of the library is now always the module name for the library with any Swift additions, extensions, etc. All vfs overlays now live in a common location to make finding them easier from CMake functions. A new pattern is needed for the Lib-less modules to re-export their Cxx counterparts.
26 lines
673 B
Swift
26 lines
673 B
Swift
/*
|
|
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
@_exported import AKCxx
|
|
import Foundation
|
|
|
|
public extension Foundation.Data {
|
|
init(_ string: AK.StringView) {
|
|
let bytes = string.bytes()
|
|
self.init(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes.data()), count: bytes.size(), deallocator: .none)
|
|
}
|
|
}
|
|
|
|
public extension Swift.String {
|
|
init?(_ string: AK.String) {
|
|
self.init(data: Foundation.Data(string.__bytes_as_string_viewUnsafe()), encoding: .utf8)
|
|
}
|
|
|
|
init?(_ string: AK.StringView) {
|
|
self.init(data: Foundation.Data(string), encoding: .utf8)
|
|
}
|
|
}
|