2024-07-15 17:24:18 +00:00
|
|
|
set(SOURCES
|
2022-10-13 20:00:59 +00:00
|
|
|
Assertions.cpp
|
2024-07-17 17:09:07 +00:00
|
|
|
Base64.cpp
|
2022-12-08 21:44:46 +00:00
|
|
|
CircularBuffer.cpp
|
2023-03-10 15:37:52 +00:00
|
|
|
ConstrainedStream.cpp
|
2023-03-16 09:23:24 +00:00
|
|
|
CountingStream.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
DOSPackedTime.cpp
|
2023-01-09 00:23:00 +00:00
|
|
|
DeprecatedFlyString.cpp
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString.cpp
|
2023-02-05 10:27:38 +00:00
|
|
|
Error.cpp
|
2022-10-13 00:18:56 +00:00
|
|
|
FloatingPointStringConversions.cpp
|
2023-01-11 13:26:49 +00:00
|
|
|
FlyString.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Format.cpp
|
|
|
|
GenericLexer.cpp
|
|
|
|
Hex.cpp
|
2023-01-04 17:38:01 +00:00
|
|
|
JsonObject.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
JsonParser.cpp
|
|
|
|
JsonValue.cpp
|
|
|
|
LexicalPath.cpp
|
2023-01-25 19:19:05 +00:00
|
|
|
MemoryStream.cpp
|
2022-12-10 08:52:46 +00:00
|
|
|
NumberFormat.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
OptionParser.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Random.cpp
|
2023-09-20 22:14:35 +00:00
|
|
|
SipHash.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
StackInfo.cpp
|
2023-01-22 04:09:11 +00:00
|
|
|
Stream.cpp
|
AK: Introduce the new String, replacement for DeprecatedString
DeprecatedString (formerly String) has been with us since the start,
and it has served us well. However, it has a number of shortcomings
that I'd like to address.
Some of these issues are hard if not impossible to solve incrementally
inside of DeprecatedString, so instead of doing that, let's build a new
String class and then incrementally move over to it instead.
Problems in DeprecatedString:
- It assumes string allocation never fails. This makes it impossible
to use in allocation-sensitive contexts, and is the reason we had to
ban DeprecatedString from the kernel entirely.
- The awkward null state. DeprecatedString can be null. It's different
from the empty state, although null strings are considered empty.
All code is immediately nicer when using Optional<DeprecatedString>
but DeprecatedString came before Optional, which is how we ended up
like this.
- The encoding of the underlying data is ambiguous. For the most part,
we use it as if it's always UTF-8, but there have been cases where
we pass around strings in other encodings (e.g ISO8859-1)
- operator[] and length() are used to iterate over DeprecatedString one
byte at a time. This is done all over the codebase, and will *not*
give the right results unless the string is all ASCII.
How we solve these issues in the new String:
- Functions that may allocate now return ErrorOr<String> so that ENOMEM
errors can be passed to the caller.
- String has no null state. Use Optional<String> when needed.
- String is always UTF-8. This is validated when constructing a String.
We may need to add a bypass for this in the future, for cases where
you have a known-good string, but for now: validate all the things!
- There is no operator[] or length(). You can get the underlying data
with bytes(), but for iterating over code points, you should be using
an UTF-8 iterator.
Furthermore, it has two nifty new features:
- String implements a small string optimization (SSO) for strings that
can fit entirely within a pointer. This means up to 3 bytes on 32-bit
platforms, and 7 bytes on 64-bit platforms. Such small strings will
not be heap-allocated.
- String can create substrings without making a deep copy of the
substring. Instead, the superstring gets +1 refcount from the
substring, and it acts like a view into the superstring. To make
substrings like this, use the substring_with_shared_superstring() API.
One caveat:
- String does not guarantee that the underlying data is null-terminated
like DeprecatedString does today. While this was nifty in a handful of
places where we were calling C functions, it did stand in the way of
shared-superstring substrings.
2022-12-01 12:27:43 +00:00
|
|
|
String.cpp
|
2023-10-28 19:17:06 +00:00
|
|
|
StringBase.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
StringBuilder.cpp
|
2022-10-25 18:00:49 +00:00
|
|
|
StringFloatingPointConversions.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
StringImpl.cpp
|
|
|
|
StringUtils.cpp
|
|
|
|
StringView.cpp
|
|
|
|
Time.cpp
|
|
|
|
Utf16View.cpp
|
2023-02-20 13:08:40 +00:00
|
|
|
Utf32View.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Utf8View.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
kmalloc.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
)
|
|
|
|
|
2024-07-15 17:24:18 +00:00
|
|
|
serenity_lib(AK ak)
|
2022-10-13 20:00:59 +00:00
|
|
|
|
2020-05-26 18:20:24 +00:00
|
|
|
serenity_install_headers(AK)
|
2020-08-15 12:11:10 +00:00
|
|
|
serenity_install_sources(AK)
|
2024-07-15 17:24:18 +00:00
|
|
|
|
|
|
|
find_package(Backtrace)
|
|
|
|
configure_file(Backtrace.h.in Backtrace.h @ONLY)
|
|
|
|
|
|
|
|
if (Backtrace_FOUND)
|
|
|
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.30)
|
|
|
|
target_link_libraries(AK PRIVATE Backtrace::Backtrace)
|
|
|
|
else()
|
|
|
|
target_include_directories(AK PRIVATE ${Backtrace_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(AK PRIVATE ${Backtrace_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(WARNING "Backtrace not found, stack traces will be unavailable")
|
|
|
|
endif()
|
2024-07-15 19:25:08 +00:00
|
|
|
|
2024-07-17 17:09:07 +00:00
|
|
|
find_package(simdutf REQUIRED)
|
2024-08-17 18:51:34 +00:00
|
|
|
swizzle_target_properties_for_swift(simdutf::simdutf)
|
2024-07-17 17:09:07 +00:00
|
|
|
target_link_libraries(AK PRIVATE simdutf::simdutf)
|
2024-08-06 02:46:12 +00:00
|
|
|
|
2024-11-05 20:59:35 +00:00
|
|
|
# FIXME: Make this generic for all imported shared library dependencies and apply globally
|
2024-11-08 13:11:50 +00:00
|
|
|
if (BUILD_SHARED_LIBS AND NOT CMAKE_SKIP_INSTALL_RULES AND NOT "${VCPKG_INSTALLED_DIR}" STREQUAL "")
|
2024-11-05 20:59:35 +00:00
|
|
|
install(IMPORTED_RUNTIME_ARTIFACTS simdutf::simdutf
|
|
|
|
LIBRARY COMPONENT Lagom_Runtime NAMELINK_COMPONENT Lagom_Development
|
|
|
|
FRAMEWORK COMPONENT Lagom_Runtime
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2024-08-07 06:33:55 +00:00
|
|
|
if (ENABLE_SWIFT)
|
2024-08-27 01:04:05 +00:00
|
|
|
generate_clang_module_map(AK
|
2024-08-07 06:33:55 +00:00
|
|
|
GENERATED_FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Backtrace.h"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/Debug.h"
|
|
|
|
)
|
2024-08-23 18:22:26 +00:00
|
|
|
target_sources(AK PRIVATE AK+Swift.swift)
|
2024-08-27 01:04:05 +00:00
|
|
|
add_swift_target_properties(AK)
|
2024-08-07 06:33:55 +00:00
|
|
|
endif()
|
2024-10-12 16:48:48 +00:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
# FIXME: Windows on ARM
|
|
|
|
target_link_libraries(AK PRIVATE clang_rt.builtins-x86_64.lib)
|
|
|
|
endif()
|