summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-03-11AK: Add basic const iteration to IntrusiveListAndreas Kling
2021-03-09AK: Add Formatter for RefPtrAndreas Kling
2021-03-09AK: Include Assertions.h in StdLibExtras.hMițca Dumitru
2021-03-08AK: Add AK_ENUM_BITWISE_OPERATORS(..) to enable type-safe enum bitwise ↵Brian Gianforcaro
operations This change introduces `AK_ENUM_BITWISE_OPERATORS(..)` which when enabled for an enum, will automatically declare all the necessary bitwise operators for that enum. This allows bit masks enums to be used as first class, type safe, citizens.
2021-03-08AK: Take advantage of constexpr in Time and add time conversion methodsTom
By making the Time constructor constexpr we can optimize creating a Time instance from hardcoded values. Also add more functions to convert between Time and various time units.
2021-03-08AK: Initialize the AK::Time membersTom
Since we tell the compiler to provide a default constructor we need to initialize the member variables.
2021-03-08AK: JsonObject::value_or() fallback value should be a const referenceAndreas Kling
2021-03-07AK+Tests: Also test Checked<> with unsignedBen Wiederhake
As expected, Checked<unsigned> works as intended. However, we didn't have a test for that, so I added one. See also 90c070cb1d90d77ba461017e609b9f8ee6326de1.
2021-03-07AK: Add optional fragment parameter to create_with_file_protocol()speles
Now that we use fragment for specifying starting selection in FileManager we would benefit from providing it as argument instead of setting it each time separately.
2021-03-05AK: Implement IsEnum<T> and UnderlyingType<T> type traitsBrian Gianforcaro
I needed these meta-programming type traits while working on something else. Add basic support for these two type traits as well as some tests.
2021-03-05AK: Add a full memory barrier function based on atomic operationsLiav A
We use atomic_signal_fence and atomic_thread_fence together to prevent reordering of memory accesses by the CPU and the compiler. The usage of these functions was suggested by @tomuta so we can be sure that important memory accesses happen in the expected order :)
2021-03-04AK: Simplify Bitmap and implement in terms of BitmapViewAndreas Kling
Add Bitmap::view() and forward most of the calls to BitmapView since the code was identical. Bitmap is now primarily concerned with its dynamically allocated backing store and BitmapView deals with the rest.
2021-03-04AK: Add BitmapView class (like StringView but for bitmaps)Andreas Kling
AK::Bitmap is an awkwardly modal class which can either own or wrap the underlying data. To get ourselves out of this unpleasant situation, this patch adds BitmapView to replace the wrapped mode. A BitmapView is simply a { data pointer, bit count } tuple internally and provides all the convenient functionality of a bitmap class.
2021-03-04HackStudio/LanguageServers: Move some components out of CppAnotherTest
This makes them available for use by other language servers. Also as a bonus, update the Shell language server to discover some symbols and add go-to-definition functionality :^)
2021-03-04Everywhere: Remove unnecessary `clang-format off`sWilliam McPherson
Mostly due to the fact that clang-format allows aligned comments via AlignTrailingComments. We could also use raw string literals in inline asm, which clang-format deals with properly (and would be nicer in a lot of places).
2021-03-04AK: Add Bitmap::is_null()Andreas Kling
This class has a null state but there was no API to check for it.
2021-03-03AK+Kernel: Remove NO_DISCARD macro hackLinus Groh
This was added as clang-format would mess up the formatting when using [[nodiscard]] on a class, which is no longer the case.
2021-03-03AK+LibM: Rename EXPECT_CLOSE to EXPECT_APPROXIMATEBen Wiederhake
2021-03-03AK+LibM: Make EXPECT_CLOSE more useful during debuggingBen Wiederhake
2021-03-03AK: Fix OOO mistake in StackInfo.cppihsinme
"!=" has higher priority than "=".
2021-03-02AK: Make Time more usableBen Wiederhake
2021-03-02Kernel: Prevent using copy_from_user() for timespec/timevalBen Wiederhake
These structs can be inconsistent, for example if the amount of microseconds is negative or larger than 1'000'000. Therefore, they should not be copied as-is. Use copy_time_from_user instead.
2021-03-02AK: Implement C++ 'Time' type for easier time-calculationsBen Wiederhake
This adds a bunch of code in the hope that other, wrong code can be deleted. Related to #5315.
2021-03-02AK: Remove unused templateBen Wiederhake
2021-03-02AK+Tests: Test Checked for main functionalityBen Wiederhake
2021-03-01AK/Lagom: Modify TestSuite to return how many tests failed from mainAndrew Kaster
This allows us to remove the FAIL_REGEX logic from the CTest invocation of AK and LibRegex tests, as they will return a non-zero exit code on failure :^). Also means that running a failing TestSuite-enabled test with the run-test-and-shutdown script will actually print that the test failed.
2021-02-28Meta: Build AK and LibRegex tests in Lagom and for SerenityAndrew Kaster
These tests were never built for the serenity target. Move their Lagom build steps to the Lagom CMakeLists.txt, and add serenity build steps for them. Also, fix the build errors when building them with the serenity cross-compiler :^)
2021-02-28LibWeb: Add actual document loading for the CSS (at)import ruleSviatoslav Peleshko
2021-02-27AK: Use Array iterator instead of indexing outside Array boundsAndreas Kling
2021-02-27AK: Always do bounds checking in Array::operator[]Andreas Kling
2021-02-26Everywhere: Remove a bunch of redundant 'AK::' namespace prefixesLinus Groh
This is basically just for consistency, it's quite strange to see multiple AK container types next to each other, some with and some without the namespace prefix - we're 'using AK::Foo;' a lot and should leverage that. :^)
2021-02-24AK: Don't compare past '\0' in StringView::operator==(const char*)Andreas Kling
We kept scanning the needle string even after hitting a null terminator and that's clearly not right. Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31338 https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31351
2021-02-24AK: Add support for AK::StringView literals with operator""svBrian Gianforcaro
A new operator, operator""sv was added as of C++17 to support string_view literals. This allows string_views to be constructed from string literals and with no runtime cost to find the string length. See: https://en.cppreference.com/w/cpp/string/basic_string_view/operator%22%22sv This change implements that functionality in AK::StringView. We do have to suppress some warnings about implementing reserved operators as we are essentially implementing STL functions in AK as we have no STL :).
2021-02-24AK: Rename {DBGLN_NO => ENABLE}_COMPILETIME_FORMAT_CHECKLinus Groh
This is no longer limited to dbgln(). Also invert it to match all the other ENABLE_FOO options.
2021-02-24AK: Make dbgln_if() avoid evaluating the arguments when disabledAnotherTest
Naturally, this makes the `enabled` flag on dbgln() obsolete.
2021-02-23Everywhere: Remove unused RELEASE_ASSERT macroAndreas Kling
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-23AK: Slap Optional with the ALWAYS_INLINE stickAndreas Kling
I saw some Optional constructors when profiling the dynamic loader and that seemed silly since we can inline them at no/little cost.
2021-02-23AK: Optimize StringView::operator==(const char*) a little bitAndreas Kling
Don't compute the strlen() of the string we're comparing against first. This can save a lot of time if we're comparing against something that already fails to match in the first few characters.
2021-02-23AK+Kernel+Userland: Enable some more compiletime format string checksAnotherTest
This enables format string checks for three more functions: - String::formatted() - Builder::appendff() - KBufferBuilder::appendff()
2021-02-23AK+Userland: Extend the compiletime format string check to other functionsAnotherTest
Thanks to @trflynn89 for the neat implicit consteval ctor trick! This allows us to basically slap `CheckedFormatString` on any formatting function, and have its format argument checked at compiletime. Note that there is a validator bug where it doesn't parse inner replaced fields like `{:~>{}}` correctly (what should be 'left align with next argument as size' is parsed as `{:~>{` following a literal closing brace), so the compiletime checks are disabled on these temporarily by forcing them to be StringViews. This commit also removes the now unused `AK::StringLiteral` type (which was introduced for use with NTTP strings).
2021-02-23AK: Untangle TestSuite assertions a bitAnotherTest
2021-02-21AK: Add String{,Utils}::to_snakecase()Linus Groh
This is an improved version of WrapperGenerator's snake_name(), which seems like the kind of thing that could be useful elsewhere but would end up getting duplicated - so let's add this to AK::String instead, like to_{lowercase,uppercase}().
2021-02-21AK: Alter ByteBuffer to utilise memcmp.Ivan Hansgaard Hansen
__builtin_memcmp is already heavily utilised in AK.
2021-02-21AK: Do bounds checking (assertions) in Span::operator[]Andreas Kling
2021-02-21AK: Add an implementation of Array<T, Size>::fill(...)Brian Gianforcaro
2021-02-21AK: Add Span<T> constructor for arraysBrian Gianforcaro
The array constructor allows arrays to be easily treated as generic span of data.
2021-02-21AK: Add safe memset() wrapper to ByteBufferBrian Gianforcaro
In the interest memory safety and of removing as many of foot guns as possible (like raw memset's which are notorious for typo's), a zeroing method seems like a useful utility to have on a buffer class.
2021-02-20LibLine: Avoid refreshing the entire line when inserting at the endAnotherTest
This patchset allows the editor to avoid redrawing the entire line when the changes cause no unrecoverable style updates, and are at the end of the line (this applies to most normal typing situations). Cases that this does not resolve: - When the cursor is not at the end of the buffer - When a display refresh changes the styles on the already-drawn parts of the line - When the prompt has not yet been drawn, or has somehow changed Fixes #5296.
2021-02-20AK: Make Nonnull*PtrVector use size_t for indexesAndreas Kling
This was weird. It turns out these class were using int indexes and sizes despite being derived from Vector which uses size_t. Make the universe right again by using size_t here as well.