summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2023-02-15AK: Add StringBuilder::to_fly_string()Sam Atkins
2023-02-15AK: Let FlyStrings be assigned from StringsSam Atkins
2023-02-15AK+Tests+LibWeb: Make `URL::complete_url()` take a StringViewSam Atkins
All it does is pass this to `URLParser::parse()` which takes a StringView, so we might as well take one here too.
2023-02-13Shell: Start implementing a POSIX-compliant parserAli Mohammad Pur
The parser is still very much a work-in-progress, but it can currently parse most of the basic bits, the only *completely* unimplemented things in the parser are: - heredocs (io_here) - alias expansion - arithmetic expansion There are a whole suite of bugs, and syntax highlighting is unreliable at best. For now, this is not attached anywhere, a future commit will enable it for /bin/sh or a `Shell --posix` invocation.
2023-02-13Everywhere: Remove the `AK::` qualifier from Stream usagesTim Schumacher
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-12AK: Add conversion functions for packed DOS time formatOllrogge
This also adjusts the FATFS code to use the new functions and removes the now redundant old conversion functions.
2023-02-12AK: Add function 'shallow_clone()' to HashMapKenneth Myhra
This makes a shallow clone of the HashMap, the items temselves are not cloned in any way.
2023-02-11AK: Move try_make_ref_counted() to NonnullRefPtr.hNico Weber
2023-02-11AK: Move try_make() to NonnullOwnPtr.hNico Weber
2023-02-11AK: Move adopt_nonnull_ref_or_enomem() to NonnullRefPtr.hNico Weber
Rewrite the implementation to not depend on OwnPtr.h. No intended behavior change.
2023-02-11AK: Move adopt_nonnull_own_or_enomem() to NonnullOwnPtr.hNico Weber
Rewrite the implementation to not depend on OwnPtr.h. No intended behavior change.
2023-02-11AK: Always initialize vector capacity to inline_capacityMacDue
This ensures constructors that take a span or an initializer_list don't allocate when there's already enough inline storage. (Previously these constructors always allocated)
2023-02-10AK: Allow Vector<ByteBuffer>::contains_slow to accept (Readonly)BytesLuke Wilde
This is done by providing Traits<ByteBuffer>::equals functions for (Readonly)Bytes, as the base GenericTraits<T>::equals is unable to convert the ByteBuffer to (Readonly)Bytes to then use Span::operator== This allows us to check if a Vector<ByteBuffer> contains a (Readonly)Bytes without having to making a copy of it into a ByteBuffer first. The initial use of this is in LibWeb with CORS-preflight, where we check the split contents of the Access-Control headers with Fetch::Infrastructure::Request::method() and static StringViews such as "*"sv.bytes().
2023-02-10AK: Provide `is_errno` for Kernel ErrorsTim Schumacher
It wouldn't make much sense on its own (as the Kernel only has errno Errors), but it's an easy fix for not having to ifdef away every single usage of `is_errno` in code that is shared between Userland and Kernel.
2023-02-10AK: Allow explicitly copying Errors in the KernelTim Schumacher
2023-02-10AK: Fix a linting issue in `Error.h`Tim Schumacher
I'm not sure why, but `clang-format` gets unhappy if we touch the adjacent line.
2023-02-10AK: Disallow returning of string literals for errors in kernel codeLiav A
This code should not be used in the kernel - we should always propagate proper errno codes in case we need to return those to userland so it could decode it in a reasonable way.
2023-02-10AK: Add a new method to propagate errno while printing errors in KernelLiav A
This new method is meant to be used in both userspace and kernel code. The idea is to allow printing of a verbose message and then returning an errno code which is the proper mechanism for kernel code because we should almost always assume that such error will be propagated back to userspace in some way, so the userspace code could reasonably decode it. For userspace code however, this new method is meant to be a simple wrapper for Error::from_string_view, because for most invocations, it's much more useful to have a verbose & literal error than a errno code, so we simply ignore that errno code completely in such context.
2023-02-10AK: Disallow implicitly copying Error and ErrorOr instancesTimothy Flynn
In the rare cases that a copy is actually needed, the Error::copy factory will suffice.
2023-02-10AK+Everywhere: Do not implicitly copy variables in TRY macrosTimothy Flynn
For example, consider cases where we want to propagate errors only in specific instances: auto result = read_data(); // something like ErrorOr<ByteBuffer> if (result.is_error() && result.error().code() != EINTR) continue; auto bytes = TRY(result); The TRY invocation will currently copy the byte buffer when the expression (in this case, just a local variable) is stored into _temporary_result. This patch binds the expression to a reference to prevent such copies. In less trival invocations (such as TRY(some_function()), this will incur only temporary lifetime extensions, i.e. no functional change.
2023-02-10Everywhere: Remove needless copies of Error / ErrorOr instancesTimothy Flynn
Either take the underlying objects with release_* methods or move() the instances around.
2023-02-10AK: Add an explicit Error factory to copy an existing errorTimothy Flynn
As of now, there is a default copy constructor on Error. A future commit will make this non-public to prevent implicit copies, so to prepare for that, this adds a factory for the few cases where a copy is really needed.
2023-02-08AK: Remove the deprecated Stream implementation :^)Tim Schumacher
2023-02-08Everywhere: Use ReadonlySpan<T> instead of Span<T const>MacDue
2023-02-08AK: Add ReadonlySpan<T> as an alias for Span<T const>MacDue
This is a little clearer than Span<T const> where it looks like it's the T not the underlying array that's const.
2023-02-08AK: Remove the fallible constructor from `FixedMemoryStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `LittleEndianOutputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallbile constructor from `BigEndianOutputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `LittleEndianInputBitStream`Tim Schumacher
2023-02-08AK: Remove the fallible constructor from `BigEndianInputBitStream`Tim Schumacher
2023-02-06Kernel: Protect Process::m_name with a spinlockSam Atkins
This also lets us remove the `get_process_name` and `set_process_name` syscalls from the big lock. :^)
2023-02-05AK: Always define ak_assertion_failed, even when NDEBUG is falseAndrew Kaster
Just because we may compile serenity with or without NDEBUG doesn't mean that consuming projects or Ports will share the setting. Always define the custom assertion function so that we don't have to keep the same debug settings between all projects.
2023-02-05AK: Allow propagating errors from StringView::for_each_split_view()MacDue
2023-02-05AK: Make WeakPtr<T>::value() return NonnullRefPtr<T>Andreas Kling
This API is only used by Jakt to implement weak reference unwrapping. By making it return a NonnullRefPtr, it can be assigned to anything that accepts a NonnullRefPtr, unlike the previous T* return type (since that can also be null).
2023-02-04AK: Check the return type in `IsCallableWithArguments`Lucas CHOLLET
Template argument are checked to ensure that the `Out` type is equal or convertible to the type returned by the invokee. Compilation now fails on: `Function<void()> f = []() -> int { return 0; };` But this is allowed: `Function<ErrorOr<int>()> f = []() -> int { return 0; };`
2023-02-04AK: Move the definition of `IsCallableWithArguments` to `Function.h`Lucas CHOLLET
It will allow us to use definitions from both `StdLibExtraDetails.h` and `Concepts.h` at the same time.
2023-02-04AK: Add the `ConvertibleTo` conceptLucas CHOLLET
2023-02-04AK: Make LEB128 decoding work with `read_value`Tim Schumacher
2023-02-04AK: Port `LEB128` to the new `AK::Stream`Tim Schumacher
2023-02-04AK: Don't restore the stream offset when failing to read an LEB128Tim Schumacher
Pretty much no other read function does this, and getting rid of the typename template parameter for the stream makes the transition to the new AK::Stream a bit easier.
2023-02-04AK: Make `SeekableStream::truncate()` take a `size_t`Tim Schumacher
Similar to the return values earlier, a signed value doesn't really make sense here. Relying on the much more standard `size_t` makes it easier to use Stream in all contexts.
2023-02-04AK: Use constexpr instead of consteval on OpenBSDnipos
2023-02-03AK: Add thresholds to `quickselect_inline` and `Statistics::Median`Staubfinger
I did a bit of Profiling and made the quickselect and median algorithms use the best of option for the respective input size.
2023-02-03AK: Use `AK:quickselect_inline` to compute `AK::Statistics::median`Staubfinger
Quick select is an algorithm that is able to find the median of a Vector without fully sorting it. This replaces the old very naive implementation for `AK::Statistics::median()` with `AK::quickselect_inline`
2023-02-03AK: Implement the quick select algorithm as AK::quickselect_inplaceStaubfinger
This adds the quick select algorithm that finds the kth smallest element for any collection. Whilst doing so it also partially sorts the collection. I have also included the option to use different pivoting functions including median of medians which makes the quick select have a truely linear time complexity at the costs of enormous overhead, so this that only really useful for really large datasets. The same was chosen to reflect the fact that it modifies the collection in place during the selection process.
2023-02-03AK: Remove JsonObject::get_deprecated() and ::get_ptr() :^)Sam Atkins
2023-02-02AK: Define HashMap::take to find and remove a value from the mapTimothy Flynn
2023-02-02AK: Ensure string types are actually considered hash-compatibleTimothy Flynn
The AnyString concept is currently broken because it checks whether a StringView is constructible from a type T. The StringView constructors, however, only accept constant rvalue references - i.e. `T const&`. This also adds a test to ensure this continues to work.
2023-02-02AK: Return a constant reference from HashMap's constant get() overrideTimothy Flynn
We cannot return a mutable reference from a constant function.