summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2022-09-20AK: Fix bad parsing of some file:/// URLs with base URLAndreas Kling
We were dropping the base URL path components in the resulting URL due to mistakenly determining the input URL to start with a Windows drive letter. Fix this, add a spec link, and a test.
2022-09-20AK: Do not require an allocated String for fuzzy matchingTimothy Flynn
A StringView is sufficient here. This also removes the declaration of fuzzy_match_recursive from the header, as it's only needed from within the implementation file.
2022-09-18AK: Move heavyweight fuzzy matching to own compilation unitBen Wiederhake
2022-09-16AK: Define both `::nullptr_t` and `std::nullptr_t`Tim Schumacher
LLVM 15 switched around what it's basing its `nullptr_t` definitions on, it's now defining `std::nullptr_t` using `::nullptr_t` instead of the other way around. Work around any errors that result from that by just defining it both in the global namespace as well as in `std` ourselves.
2022-09-15StringBuilder: Add try_append_repeated() and append_repeated()Lucas CHOLLET
This two methods add the character as many times as specified by the second parameter.
2022-09-09AK: Warn when trying to set `@foo@` as a SourceGenerator keySam Atkins
I was very confused why I was getting "no key named `foo`" errors, so hopefully this will save someone that confusion in the future. :^) (It'll probably be me again...)
2022-09-08AK: Allow creating NonnullPtrVectors from an initializer listSam Atkins
This was present in Vector already. Clang-format fixed some const positions automatically too. Also removed a now-ambiguous and unnecessary constructor from Shell.
2022-09-03AK: Make Weakable non-atomicAndreas Kling
Let's not punish single-threaded workloads with the performance cost of atomic weakables. The kernel keeps using LockWeakable.
2022-09-02AK: Allow exponents in JSON double valuesdavidot
This is required for ECMA-404 compliance, but probably not for serenity itself.
2022-08-30AK: Add find_first_split_view() helper for StringView containerLiav A
Similar to the find_last_split_view() helper, but in this helper we search for the first split view instead of the last one.
2022-08-27AK: Add `FloatingPoint.h`Jelle Raaijmakers
This is a set of functions that allow you to convert between arbitrary IEEE 754 floating point types, as long as they can be represented within 64 bits. Conversion methods between floats and doubles are provided, as well as a generic `float_to_float()`. Example usage: #include <AK/FloatingPoint.h> double val = 1.234; auto weird_f16 = convert_from_native_double<FloatingPointBits<0, 6, 10>>(val); Signed and unsigned floats are supported, and both NaN and +/-Inf are handled correctly. Values that do not fit in the target floating point type are clamped.
2022-08-27AK: Make empty FixedArray smallerAndreas Kling
Move the FixedArray's size field into the heap-allocated storage. This makes zero-sized FixedArrays take up 8 bytes instead of 16.
2022-08-20Kernel: Make self-contained locking smart pointers their own classesAndreas Kling
Until now, our kernel has reimplemented a number of AK classes to provide automatic internal locking: - RefPtr - NonnullRefPtr - WeakPtr - Weakable This patch renames the Kernel classes so that they can coexist with the original AK classes: - RefPtr => LockRefPtr - NonnullRefPtr => NonnullLockRefPtr - WeakPtr => LockWeakPtr - Weakable => LockWeakable The goal here is to eventually get rid of the Lock* classes in favor of using external locking.
2022-08-20AK+Kernel: Add AK::AtomicRefCounted and use everywhere in the kernelAndreas Kling
Instead of having two separate implementations of AK::RefCounted, one for userspace and one for kernelspace, there is now RefCounted and AtomicRefCounted.
2022-08-19AK: Add Singleton special-case constructor for SpinlockProtectedkleines Filmröllchen
This will allow Singletons of that class to still be created when SpinlockProtected can't be constructed without a lock rank argument anymore.
2022-08-15AK: Allow bit_cast to be used in constant evaluated contextdavidot
2022-08-05AK: Add human_readable_digital_time() helperthankyouverycool
Converts seconds into a readable digital format. For example: 30 seconds = "00:30" 90 seconds = "01:30" 86401 seconds = "24:00:01" And so on.
2022-08-05AK: Suppress -Wunqualified-std-cast-call in the CLion IDEAndreas Kling
2022-08-01AK: Prefix CACHE_ALIGNED & SYSTEM_CACHE_ALIGNMENT_SIZEBrian Gianforcaro
2022-07-31AK: Fix usage of undefined variablesFiliph Sandström
The commit that introduced BuiltinWrappers (548529a) accidentally used `val` instead of `value` in the non `__GNUC__` and `__clang__` versions of the functions.
2022-07-26AK: VERIFY() the index is in bounds in StringView::operator[]MacDue
That this did not already happen took me by surprise, as for most other similar containers/types in AK (e.g. Span) the index will be checked. This check not happening could easily let off-by-one indexing errors slip through the cracks.
2022-07-22Everywhere: Prefix 'TYPEDEF_DISTINCT_ORDERED_ID' with 'AK_'Linus Groh
2022-07-22Everywhere: Prefix 'TYPEDEF_DISTINCT_NUMERIC_GENERAL' with 'AK_'Linus Groh
2022-07-22AK: Add FixedArray::fill_withkleines Filmröllchen
This is a memset-like utility method.
2022-07-22AK: Remove FixedArray::must_create_but_fixme_should_propagate_errorskleines Filmröllchen
Nobody was using this anymore.
2022-07-21Kernel+LibPartition: Move GUIDPartitionTable into LibPartitionSamuel Bowman
2022-07-21Kernel+LibPartition: Move MBRPartitionTable into LibPartitionSamuel Bowman
2022-07-19AK+LibGfx+LibJS: Pass -1 as the file descriptor to anonymous mmapDaniel Bertalan
Serenity/Linux/macOS ignore the file descriptor when an anonymous mapping is requested. However, BSDs require the fd to be -1.
2022-07-19AK: Port StackInfo to FreeBSDDaniel Bertalan
This can almost be identical to the Linux version, except that the `pthread_attr_t` object is populated using a call to `pthread_attr_get_np` instead of `pthread_getattr_np`. FreeBSD also needs `pthread_atttr_t` to be initialized using `pthread_attr_init` instead of zero-initialization, but it's the technically correct thing to do on Linux as well.
2022-07-19AK: Do not negate Pthread error codes for `strerror()`Daniel Bertalan
On all systems I've checked, pthread functions return the positive error code directly.
2022-07-19AK: Add support for building on Android with API version >= 30Andrew Kaster
2022-07-15AK: Add a helper to get the last split-groupHendiadyoin1
2022-07-14AK: Use the correct data types in bitap_bitwise()Ali Mohammad Pur
Otherwise the bit twiddling goes all wrong and breaks some boundary cases. Fixes `StringView::contains(31-chars)`.
2022-07-14AK: Add Traits<ByteBuffer>::hash()Linus Groh
2022-07-12AK: Remove StringView(char const*) :^)sin-ack
This constructor relied on running strlen implicitly on its argument, thereby potentially causing out-of-bound reads (some of which were caught a few days ago). The removal of this constructor ensures that the caller must explicitly pass the size of the string by either: 1) Using operator""sv on literal strings; or 2) Calling strlen explicitly, making it clear that the size of the view is being calculated at runtime.
2022-07-12AK+Userland+Tests: Remove URL(char const*) constructorsin-ack
The StringView(char const*) constructor is being removed, and there was only a few users of this left, which are also cleaned up in this commit.
2022-07-12AK: Remove String <-> char const* comparison operatorssin-ack
During the removal of StringView(char const*), all users of these functions were removed, and they are of dubious value (relying on implicit StringView conversion).
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-12Everywhere: Split Error::from_string_literal and Error::from_string_viewsin-ack
Error::from_string_literal now takes direct char const*s, while Error::from_string_view does what Error::from_string_literal used to do: taking StringViews. This change will remove the need to insert `sv` after error strings when returning string literal errors once StringView(char const*) is removed. No functional changes.
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
2022-07-12AK: Add string literal helpers to AK::SourceGeneratorsin-ack
Since all uses of SourceGenerator are with literal strings, there is no need to burden generators with the sv suffix.
2022-07-12AK: Explicitly calculate length of char* when printingsin-ack
This moves out the calculation of the char* out to the formatter. Additionally, we now print (null) when a null pointer is passed.
2022-07-12AK: Make CheckedFormatString pass the char array size to StringViewsin-ack
This makes the assumption that we never pass a stack-allocated char array to CheckedFormatString arguments (dbgln, outln, warnln). This assumption seems to hold true for the current state of Serenity code, at least. :^)
2022-07-10AK: Treat empty string as invalid JSONLuke Wilde
Previously we would treat the empty string as `null`. This caused JavaScript like this to fail: ```js var object = {}; try { object = JSON.parse(""); } catch {} var array = object.array || []; ``` Since `JSON.parse("")` returned null instead of throwing, it would set `object` to null and then try and use it instead of using the default backup value.
2022-07-10LibGfx: Implement PNG filtering on writeKarol Kosek
Is it another great upgrade to our PNG encoder like in 9aafaec259? Well, not really - it's not a 2x or 55x improvement like you saw there, but still it saves something: - a screenshot of a blank Serenity desktop dropped from about 45 KiB to 40 KiB. - re-encoding NASA photo of the Earth to PNG again saves about 25% (16.5 MiB -> 12.3 MiB), compared to not using filters. [1]: https://commons.wikimedia.org/wiki/File:The_Blue_Marble_(remastered).jpg
2022-07-09AK: Always check shift amount in LEB128 read functionskleines Filmröllchen
Even shifting 0 by more than the value size is UB.
2022-07-09AK: Make VERIFY() work in MinSizeRel buildsAndreas Kling
2022-07-09AK: Add equality operators to compare RefPtr to NonNullRefPtrAllan Regush
2022-07-09AK: Add comparison operators to NonnullRefPtrAllan Regush