Commit graph

3449 commits

Author SHA1 Message Date
Timothy Flynn 07a27b2ec0 AK: Replace the boolean parameter of StringView::lines with a named enum 2024-03-08 14:43:33 -05:00
Matthew Olsson a511f1ef85 AK: Add HashMap::ensure_capacity 2024-03-06 07:45:56 +01:00
Filiph Siitam Sandström fd694e8672 AK+Lagom: Make it possible to build for iOS
This commit makes it possible to build AK and most of Lagom for iOS,
based on the work for the Ladybird build demoed on discord:
https://discord.com/channels/830522505605283862/830525031720943627/1211987732646068314
2024-03-03 13:13:42 -07:00
Hendiadyoin1 79fd8eb28d AK/HashMap: Use structured bindings when iterating over itself 2024-03-01 14:05:53 -07:00
Nico Weber f8b8d1b3be AK: Add is_ascii_uppercase_hex_digit() 2024-03-01 14:17:42 +01:00
Timothy Flynn d878975f95 AK+LibJS: Remove OFFSET_OF and its users
With the LibJS JIT removed, let's not expose pointers to internal
members.
2024-02-29 09:00:00 +01:00
Andrew Kaster 21ac431fac AK: Allow reading from EOF buffered streams better in read_line()
If the BufferedStream is able to fill its entire circular buffer in
populate_read_buffer() and is later asked to read a line or read until
a delimiter, it could erroneously return EMSGSIZE if the caller's buffer
was smaller than the internal buffer. In this case, all we really care
about is whether the caller's buffer is big enough for however much data
we're going to copy into it. Which needs to take into account the
candidate.
2024-02-26 13:16:27 -07:00
Dan Klishch ba24e86fdd AK: Introduce IntrusiveBinaryHeap and reimplement BinaryHeap using it
The main difference between them is that IntrusiveBinaryHeap can
optionally maintain an index inside every stored node that allows
arbitrary nodes to be deleted.
2024-02-25 17:24:36 -07:00
Hendiadyoin1 38cb5444d9 AK: Make StringView::for_each_split_view() aware of IterationDecision 2024-02-24 16:43:44 -07:00
Dan Klishch 8ac0e3f0e5 AK+LibJS: Remove null state from DeprecatedFlyString :^) 2024-02-24 15:06:52 -07:00
Dan Klishch 061f902f95 AK+Userland: Introduce ByteString::create_and_overwrite
And replace two users of raw StringImpl with it.
2024-02-24 15:06:52 -07:00
Ali Mohammad Pur bc301b6f40 AK+LibXML+JSSpecCompiler: Move LineTrackingLexer to AK
This is a simple extension of GenericLexer, and is used in more than
just LibXML, so let's move it into AK.
The move also resolves a FIXME, which is removed in this commit.
2024-02-16 15:26:43 +01:00
Lucas CHOLLET cbfea68ed8 AK: Add BigEndianInputBitStream::bits_until_next_byte_boundary() 2024-02-12 14:08:56 +01:00
Nico Weber d84b69ace9 AK: Add to_array()
This is useful if you want an array with an explicit type but still
want its size to be inferred.
2024-02-11 18:53:00 +01:00
Nico Weber 10216e1743 AK: Remove a stray static
No behavior change.
2024-02-11 18:53:00 +01:00
Nico Weber 4409b33145 AK: Make IndexSequence use size_t
This makes it possible to use MakeIndexSequqnce in functions like:

    template<typename T, size_t N>
    constexpr auto foo(T (&a)[N])

This means AK/StdLibExtraDetails.h must now include AK/Types.h
for size_t, which means AK/Types.h can no longer include
AK/StdLibExtras.h (which arguably it shouldn't do anyways),
which requires rejiggering some things.

(IMHO Types.h shouldn't use AK::Details metaprogramming at all.
FlatPtr doesn't necessarily have to use Conditional<> and ssize_t could
maybe be in its own header or something. But since it's tangential to
this PR, going with the tried and true "lift things that cause the
cycle up to the top" approach.)
2024-02-11 18:53:00 +01:00
Tim Ledbetter 4a7236cabf Everywhere: Prefer _string when constructing strings from literals 2024-02-08 11:01:10 -05:00
Dan Klishch 88af15d513 AK: Store JsonValue's value in AK::Variant 2024-02-08 08:04:05 -07:00
Andrew Kaster bc9c710904 LibWeb: Hide WebDriver::match_route debug behind its own flag
When enabling WEBDRIVER_DEBUG globally, this function's debug spam
overpowers the rest of the useful logs.
2024-02-08 15:53:46 +01:00
Dan Klishch 677bcea771 ntpquery: Use AK::convert_between_host_and_network_endian
Instead of polluting global namespace with definitions from
libkern/OSByteOrder.h and machine/endian.h on MacOS, just use AK
functions for conversions.
2024-02-06 04:37:47 -07:00
vincent-rg a9df60ff1c AK: Update OptionParser::m_arg_index by substracting skipped args
On argument swapping to put positional ones toward the end,
m_arg_index was pointing at "last arg  index" + "skipped args" +
"consumed args" and thus was pointing ahead of the skipped ones.

m_arg_index now points after the current parsed option arguments.
2024-02-06 00:08:30 +01:00
Dan Klishch 3e43d15440 Everywhere: Prefer VERIFY over assert() 2024-02-05 07:03:53 -05:00
Nico Weber 41f57a5477 AK: Remove the SIMD version of rsqrt() too, for good measure
No strong reason to remove this one, other than that it's also unused.
2024-01-30 10:02:33 +01:00
Nico Weber a1f70b39fa AK: Remove rsqrt()
At least on arm64, this isn't very preciese:
https://github.com/SerenityOS/serenity/issues/22739#issuecomment-1912909835

It is also now unused.
2024-01-30 10:02:33 +01:00
Shannon Booth c6319d68c3 AK: Introduce EquivalentFunctionType
This allows you to get the type from a function from some given
callable 'T'.

Co-Authored-By: Ali Mohammad Pur <mpfard@serenityos.org>
2024-01-27 21:40:25 -05:00
Ali Mohammad Pur 0e61d039c9 AK: Use IsSame<FlatPtr, T> instead of __LP64__ to guess FlatPtr's type
Instead of playing the guessing game, simply use whatever type FlatPtr
itself resolves to.
2024-01-28 04:30:33 +03:30
Sam Atkins 388856dc7e AK+Userland: Return String from human_readable_size() functions 2024-01-25 09:07:32 +01:00
Sam Atkins 7e8cfb60eb AK+Userland: Return String from human_readable_[digital_]time() 2024-01-25 09:07:32 +01:00
Dan Klishch 870a947040 AK: Remove StringInternals.h
Since we do not expose memory layout anymore in StringBase, there is no
need to keep StringData public.
2024-01-21 16:16:15 -07:00
Dan Klishch 611adf1591 AK: Make the state of StringBase private
Now it actually only exposes methods to allocate uninitialized storage
and to create substring with a shared superstring. All the details of
the memory layout are fully encapsulated.
2024-01-21 16:16:15 -07:00
Dan Klishch fa52f68142 AK: Store data in FlyString as StringBase
Unfortunately, it is not clear to me how to split this commit into
several atomic ones.
2024-01-21 16:16:15 -07:00
Dan Klishch e7700e16ee AK: Forward substring creation with shared superstring to StringBase 2024-01-21 16:16:15 -07:00
Dan Klishch 5d6cd65e29 AK: Simplify String::repeated by leveraging StringBase helpers 2024-01-21 16:16:15 -07:00
Dan Klishch 7dbe357e9f AK: Simplify String::from_stream by leveraging StringBase helpers 2024-01-21 16:16:15 -07:00
Dan Klishch 7506736869 AK: Stop using ShortString in String::from_code_point
Refactor it to use StringBase::replace_with_new_short_string instead.
2024-01-21 16:16:15 -07:00
Dan Klishch dcd1fda9c8 AK: Introduce StringBase::replace_with_new_{short_,}string 2024-01-21 16:16:15 -07:00
Dan Klishch d6290c4684 AK: Move String::hash() and String::String() to StringBase 2024-01-21 16:16:15 -07:00
Dan Klishch 1b09a1851e AK: Move String::~String() and String::destroy_string() to StringBase 2024-01-21 16:16:15 -07:00
Dan Klishch 54d149bc25 AK: Move String::bytes() and String::operator==(String) to StringBase
The idea is to eventually get rid of protected state in StringBase. To
do this, we first need to remove all references to m_data and
m_short_string from String.
2024-01-21 16:16:15 -07:00
Dan Klishch 4364a28d3d AK: Move data fields from AK::String to a newly created AK::StringBase
This starts separating memory management of string data and string
utilities like `String::formatted`. This would also allow to reuse the
same storage in `DeprecatedString` in the future.
2024-01-21 16:16:15 -07:00
Dan Klishch 6e2f627cb3 AK: Move StringData from String.cpp to a newly created StringInternals.h
This is done to allow using it in files other than AK/String.cpp.
2024-01-21 16:16:15 -07:00
Dan Klishch 855ea192be AK: Add AK_MAKE_DEFAULT_COPYABLE 2024-01-21 16:16:15 -07:00
Dan Klishch 7f8d69ee2f AK: Remove explicit String::operator!= in favor of defaulted one 2024-01-21 16:16:15 -07:00
Dan Klishch b5f1a48a7c AK+Everywhere: Remove JsonValue APIs with implicit default values 2024-01-21 15:47:53 -07:00
Dan Klishch c49819cced AK+GMLCompiler+LibWeb: Remove JsonValue::is_double
This concludes a series of patches which remove the ability to observe
which arithmetic type is used to store number in JsonValue.
2024-01-21 15:47:53 -07:00
Dan Klishch faef802229 AK+GMLCompiler: Remove JsonValue::as_double()
Replace its single (non-test) usage with newly created as_number(),
which does not leak information about internal integer storage type.
2024-01-21 15:47:53 -07:00
Dan Klishch 5230d2af91 AK+WebContent: Remove JsonValue::as_{i,u}{32,64}() 2024-01-21 15:47:53 -07:00
Ali Mohammad Pur 4f6c9f410c AK+LibCore: Add BufferedSocket::can_read_up_to_delimiter()
This method (unlike can_read_line) ensures that the delimiter is present
in the buffer, and doesn't return true after eof when the delimiter is
absent.
2024-01-21 21:13:58 +01:00
Ali Mohammad Pur 4d1d88aa16 AK: Make the :hex-dump format specifier print all characters
Previously the final line would be skipped if it was not a multiple of
|width|, this makes the character view show up for that line.
2024-01-21 21:13:58 +01:00
Tim Ledbetter 65827826fe AK: Add CharacterTypes::is_ascii_base36_digit()
This can be used to validate the string passed to
`parse_ascii_base36_digit()`.
2024-01-13 19:01:35 -07:00