Commit graph

3670 commits

Author SHA1 Message Date
Pavel Shliak
8a07131229 LibGfx: Clean up #include directives
We actually include what we use where we use it.
This change aims to improve the speed of incremental builds.
2024-11-20 21:13:23 +01:00
stasoid
a423493dd8 AK: Add LexicalPath::is_root() 2024-11-19 22:07:01 -07:00
stasoid
ddd15e96b6 AK: Define pid_t on Windows 2024-11-19 14:40:03 -07:00
stasoid
69f5f40617 AK: Add static bool LexicalPath::is_absolute_path(StringView path); 2024-11-19 14:35:52 -07:00
Andrew Kaster
32cf4d1e29 AK: Add missing swift/bridging empty defines for non-Swift compilers 2024-11-19 14:32:11 -07:00
Andrew Kaster
458167935c AK: Add an extension to construct an AK.String from a Swift.String 2024-11-19 14:32:11 -07:00
Andrew Kaster
a95f761cb4 AK: Include missing StdLibExtras from NeverDestroyed 2024-11-19 14:32:11 -07:00
Timothy Flynn
be09893fa7 AK+LibJS: Don't use Temporal for console.time() and console.timeLog()
We don't need nanosecond precision here anyways, as we only display
millisecond resolution.

This uses our simple duration formatter from AK, which is updated to
accept a Duration here. This method did not have any users after the
move from Serenity.
2024-11-18 17:46:41 -05:00
Sam Atkins
3f10a5701d AK: Add Utf8View::for_each_split_view() method
Returns one Utf8View at a time, using a callback function to identify
code points to split on.
2024-11-15 23:18:29 +01:00
Sam Atkins
ec5101a1d3 AK: Ensure empty StringViews all compare as equal
Before this change, a StringView with a character-data pointer would
never compare as equal to one with a null pointer, even if they were
both length 0. This could happen for example if one is
default-initialized, and the other is created as a substring.
2024-11-15 23:18:29 +01:00
Andrew Kaster
e0adbf3ebb AK: Add a Swift helper for StringView::ends_with 2024-11-15 10:51:45 -07:00
Jonne Ransijn
d842d04be4 AK: Remove DeprecatedStringCodePointIterator
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
The functionality in this class is no longer used, we can just use
`Utf8View` instead.
2024-11-14 23:06:42 +01:00
rmg-x
c1ec2ddb63 AK: Add 16-bit float type 2024-11-10 14:48:20 -07:00
Andreas Kling
11458f0d91 AK: Use getrlimit() to find the correct main thread stack size on macOS
This is what JavaScriptCore does as well.
2024-11-10 19:12:59 +01:00
stasoid
31bf40b659 AK: Make LexicalPath::relative_path() fallible 2024-11-09 12:42:27 -07:00
stasoid
f026d495cd AK: Port LexicalPath to Windows
Supported:
* Normal absolute and relative paths: C:\Windows\Fonts, AK\LexicalPath.h
* Forward slashes and multiple separators: C:/Windows///\\\notepad.exe

Not supported:
* Paths starting with two backslashes: \\?\C:\Windows, \\server\share
* Unusual relative paths like C:, C:a\b, \, \a\b

More on Windows path formats: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
2024-11-09 12:42:27 -07:00
stasoid
9ebed7d8d5 AK: Add StringBuilder::append_repeated(StringView, size_t)
By analogy with append_repeated(char, size_t)
2024-11-09 12:42:27 -07:00
Jonne Ransijn
1d8e62926f AK: Remove clang-tidy warnings for VERIFY(a || b) lines
Lines like these were getting a warning to simplify the expanded
boolean expression from `!(a || b)` to `(a && b)`, but since the
`!(...)` is part of the macro, that is never going to happen.
2024-11-09 17:55:03 +01:00
Timothy Flynn
0447d05d52 Meta: Support fully static distribution release builds
This adds the vcpkg triplets and CMake preset to perform release
builds for distribution. These builds are fully static, and currently
intended to be used for the `js` ESVU release.

In the future, linking everything statically into the final binary is
probably not what we will do for released Ladybird builds. Instead, we
may have a "libladybird.so", which is then linked into the binary. But
this should be fine for `js` for now.
2024-11-08 11:29:18 -07:00
Andrew Kaster
dfd928a8f8 CMake: Install simdutf runtime components as required
Using install(IMPORTED_RUNTIME_ARTIFACTS), we can re-export the
shared library and frameworks we imported from outside the build
tree into our install treer. This is required for simdutf as it
is a dependency of the AK library, and we need liblagom-ak.so to
be loadable when doing fuzzer and cross-compile builds for the
Lagom tools.
2024-11-06 10:38:57 -07:00
Jonne Ransijn
e50b9f5478 AK: Add NonnullRawPtr<T> abstraction
It is a non-null `T*` with reference semantics.
Or a `T&` whose address can be copied and re-assigned.
Or a `NonnullRefPtr` whose memory is not managed.

It can be useful when you want to store a reference in a
data structure that needs to be copyable or assignable.
2024-11-06 09:43:15 +00:00
Gingeh
57ba720fb1 AK: Avoid returning null StringViews instead of empty views
This was error-prone and most users were just checking the length anyway
2024-11-05 14:01:45 +00:00
Gingeh
c67ecf37f7 LibWeb: Implement linear easing according to latest spec 2024-11-05 10:41:29 +00:00
Timothy Flynn
cfcb29bdfd AK+LibUnicode: Add a method to trim non-ASCII whitespace from a String
Required by WebDriver.
2024-11-03 20:42:46 -05:00
Timothy Flynn
c3dfef3861 AK: Allow creating a JsonArray with an initial size 2024-11-03 17:51:58 +01:00
Jonne Ransijn
755b83c01a LibJS: Implement tc39/proposal-atomics-microwait (Atomics.pause)
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run
Implements the https://github.com/tc39/proposal-atomics-microwait
proposal which has recently hit Stage 3.

This commit passes all relevant tests in `test262`.
2024-11-03 08:05:58 -05:00
Grubre
a8a81342bb LibUnicode: Implement to_fullwidth() in String
The implementation uses the transliterator class from icu.
2024-11-01 07:48:17 -04:00
Jelle Raaijmakers
c7773d0312 Meta: Update my email address everywhere 2024-11-01 12:14:53 +01:00
Jonne Ransijn
2457118024 AK: Add template specializations for Optional<{,Fly}String>
Slice the size of `Optional<{,Fly}String>` in half by introducing
`UINTPTR_MAX` as an invalid bit pattern for these values.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
fcdf3014f1 AK: Move "conditional xtor" pattern into a macro
`Optional` and `Variant` both use essentially the same pattern of only
declaring a copy constructor/move constructor/destructor and copy/move
assignment operator if all of their template parameters have one.

Let's move these into a macro to avoid code duplication and to give a
name to the thing we are trying to accomplish.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
a70ed6a2ad AK: Add OptionalBase class to reduce code duplication
Using CRTP and `static_cast`s because "deducing this" is
still not fully supported yet.
2024-10-31 23:26:22 +01:00
Jonne Ransijn
04920d06f0 AK: Use simdutf when appending UTF-16 to StringBuilder
Adds a fast path for valid UTF-16 using `simdutf`, and fall back to
the slow path for unmatched surrogates.
2024-10-30 10:28:24 +01:00
Jonne Ransijn
22a66bb1c2 AK: Pass (Deprecated)FlyString::is_one_of arguments by reference
This avoid unnecessairy reference counting.
2024-10-27 12:03:04 -04:00
Jonne Ransijn
7f3269fb02 AK: Add ASCII fast path for Utf8View::contains
This also makes `Utf8View::trim` significantly faster, since most
strings start and end with ASCII.
2024-10-27 16:13:36 +01:00
Jonne Ransijn
e636f3976d AK: Fix ambiguity in AK::Optional specialization
The specialization for the destructor of `AK::Optional` is ambiguous
when `T` is neither TriviallyDestructible nor Destructible.
The fix adds an additional check for `Destructible` when generating the
destructor of `AK::Optional`, since it calls the destructor of `T`, and
therefore already required `T` to be `Destructible` anyway.
2024-10-27 13:26:30 +01:00
Jonne Ransijn
e76064e67f AK: Allow Optional<T&> to be constructed from Optional<T>&
Attempting this resulted in an error because the `m_pointer` field does
not exist on `Optional<T>`. Creating a shared `ptr()` function and
adding the necessairy overloads solves this issue.
2024-10-27 13:26:30 +01:00
Andreas Kling
b6e28ff807 AK: Add ASCII fast path in StringBuilder::append(Utf16View)
And let's at least try to pre-allocate an appropriate amount of
buffer space in the builder instead of appending and growing one
code point at a time.
2024-10-25 15:10:12 +02:00
Jelle Raaijmakers
0de403fede AK+LibJS: Add [[nodiscard]] to operator* in common types
The order of precedence with the `*` operator sometimes makes it a bit
harder to detect whether or not the result is actually used. Let's fail
compilation if anyone tries to discard the result.
2024-10-25 09:15:28 +02:00
Ali Mohammad Pur
08ec58f347 AK: Add OrderedHashMap::take_first()
This is just a convenience shortcut for *take(begin()->key).
2024-10-24 20:55:08 +02:00
Timothy Flynn
0703ba118b AK: Add a comparison operator for Utf32View 2024-10-20 08:50:01 +02:00
Timothy Flynn
cf9693169c AK: Allow constructing Utf32 from a span of u32 2024-10-20 08:50:01 +02:00
Cameron Youell
94601e1ffd LibCore: Add Windows version of DirIterator
Co-authored-by: stasoid <stasoid@yahoo.com>
2024-10-19 18:14:48 -06:00
stasoid
9d15b3bbb7 AK: Fix lld-link : error : undefined symbol: __udivti3 on Windows 2024-10-16 12:15:31 -06:00
Cameron Youell
958ffad706 AK: Provide more complete definitions for AK_OS_WINDOWS
MSG_NOSIGNAL is a no-op for Windows, so we can define it to 0.

At the same *time*, none of the CLOCK_* macros are defined on
Windows, as clock_gettime does not exist. Put AK_OS_WINDOWS in the
same category of the BSDs for the COARSE versions of those macros.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
Cameron Youell
e1710939ce AK: Implement now_time_from_clock for Windows
Monotonic uses QueryPerformanceCounter, while realtime uses
GetSystemTimeAsFileTime. These should approximate clock_gettime
fairly accurately. The QPC implementation only grabs microseconds,
but if we have actual use cases for nanos, we can bump that up.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2024-10-16 12:15:31 -06:00
Andreas Kling
073bcfd386 AK+LibWeb: Add {Fly,}String::to_ascii_{upper,lower}_case()
These don't have to worry about the input not being valid UTF-8 and
so can be infallible (and can even return self if no changes needed.)

We use this instead of Infra::to_ascii_{upper,lower}_case in LibWeb.
2024-10-14 20:47:35 +02:00
Andreas Kling
dd419b5a8d AK: Make String::number() infallible
This API will always succeed in creating a String representing the
provided number in base-10.
2024-10-14 20:47:35 +02:00
Andreas Kling
797902229c AK: Make the main Utf8View workhorse methods inline
The call overhead of these functions was actually showing up quite
hot in profiles on macOS.
2024-10-14 09:51:13 +02:00
Andrew Kaster
90bb8ed33e AK: Use process name on Windows for dbgln() 2024-10-10 21:48:41 -06:00
Ali Mohammad Pur
02b50d463b AK: Cache all the line positions in LineTrackingLexer
Also updates a LibWeb text test that used to report the wrong line
number.
2024-10-10 23:53:48 +01:00