summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2020-08-27Meta: Force semi-colon after MAKE_AK_NONXXXABLE()Ben Wiederhake
Before, we had about these occurrence counts: COPY: 13 without, 33 with MOVE: 12 without, 28 with Clearly, 'with' was the preferred way. However, this introduced double-semicolons all over the place, and caused some warnings to trigger. This patch *forces* the usage of a semi-colon when calling the macro, by removing the semi-colon within the macro. (And thus also gets rid of the double-semicolon.)
2020-08-27Tests: Document 'missing' testsBen Wiederhake
It's up for grabs. Anyone wants to write them? :)
2020-08-26AK: Add InputBitStream class.asynts
2020-08-26AK: Add CircularDuplexStream class.asynts
2020-08-26AK: Fix the signature of binary_search.asynts
2020-08-26AK: Add stream operators for Optional.asynts
2020-08-26AK+LibC+LibCore: Have fewer implementations of day_of_weekNico Weber
The implementation in LibC did a timestamp->day-of-week conversion which looks like a valuable thing to have. But we only need it in time_to_tm, where we already computed year/month/day -- so let's consolidate on the day_of_week function in DateTime (which is getting extracted to AK).
2020-08-26AK+LibC+LibCore: Add a days_in_year functionNico Weber
2020-08-26AK+LibC+LibCore: Have fewer implementations of days_in_monthNico Weber
2020-08-26AK+LibCore+Kernel: Have fewer implementations of day_of_yearNico Weber
The JS tests pointed out that the implementation in DateTime had an off-by-one in the month when doing the leap year check, so this change fixes that bug.
2020-08-26AK+LibC+Kernel: Have fewer implementations of year_to_days_in_epochNico Weber
I believe the implementation in RTC.cpp had an off-by-one in the year passed to is_leap_year(). If that's true, then this fixes that too.
2020-08-26AK+LibC+LibCore+Kernel: Have fewer implementations of is_leap_yearNico Weber
2020-08-26AK: Demonstrate and fix CheckedBen Wiederhake
Specifically: - post-increment actually implemented pre-increment - helper-templates that provided operator{+,-,*,/}() couldn't possibly work, because the interface of add (etc) were incompatible (not taking a Checked<>, and returning void)
2020-08-25AK: Add Endian.h header to replace NetworkOrdered.h.asynts
2020-08-25AK: TestSuite: Define assert macros with do { } while(0). (#3292)Paul Scharnofske
Consider the following scenario: if(condition) FOO(); else bar(); Suppose FOO is defined as follows: #define FOO() { bar(); baz(); } Then it expands to the following: if(condition) // Syntax error, we are not allowed to put a semicolon at the end. { bar(); baz(); }; else bar(); If we define FOO as follows: #define FOO() do { bar(); baz(); } while(false) Then it expands to the following: if(condition) do { bar(); baz(); } while(false); else bar(); Which is correct.
2020-08-25Kernel: Switch singletons to use new Singleton classTom
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
2020-08-24AK: Add URL::create_with_data() to create data URLsAnotherTest
2020-08-24AK: Document that String{,Impl} contains NUL-terminatorBen Wiederhake
2020-08-24AK: Remove redundant declaration in String.cppBen Wiederhake
It already includes AK/Memory.h, which includes Kernel/StdLib.h, which. declares strstr().
2020-08-23AK: Fix human_readable_size corner casesBen Wiederhake
In particular: consistent rounding and extreme values. Before, rounding was something like 'away from 0.999...', which led to surprising corner cases in which the value was rounded up. Now, rounding is always 'down'. This even works for 0xffffffff, and also for 0xffffffffffffffffULL on 64-bit.
2020-08-23AK: Add tests for human_readable_size()Ben Wiederhake
2020-08-23AK: Print RHS and LHS in EXPECT_EQ if we canBen Wiederhake
This makes error messages more useful during debugging. Old: START Running test compare_views FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed New: START Running test compare_views FAIL: ../AK/Tests/TestStringView.cpp:59: EXPECT_EQ(view1, "foobar") failed: LHS="foo", RHS="foobar"
2020-08-23AK: Add operator== to AK::OptionalPeter Elliott
The semantics: - two Optionals are equal if they are both None - two Optionals are equal if they are both Some, and their values are operator==
2020-08-23Meta: Fix wrong 'using namespace X' usagesBen Wiederhake
Apart from causing All AK:: and Crypto:: symbols being suddenly visible even though they might not be supposed to be, the style guide also says this is wrong: https://github.com/SerenityOS/serenity/blob/master/Documentation/CodingStyle.md#using-statements
2020-08-22AK: Prefer snprintf over sprintfBen Wiederhake
2020-08-22AK+Kernel: Support snprintfBen Wiederhake
In contrast to sprintf, which might overflow the given buffer. I feel bad about the code duplication, but that is a pre-existing issue.
2020-08-22AK: TestSuite: Terminate when ASSERT_NOT_REACHED is called.asynts
Previously, it would just print something with 'FAIL' to stderr which would be picked up by CTest. However, some code assumes that ASSERT_NOT_REACHED() doesn't return, for example: bool foo(int value) { switch(value) { case 0: return true; case 1: return false; default: ASSERT_NOT_REACHED(); } // warning: control reaches end of non-void function }
2020-08-22AK: Prevent confusing silent misuse of Userspace<T>Ben Wiederhake
2020-08-22AK: Fix description of DistinctNumeric around operator boolBen Wiederhake
2020-08-22AK: Prevent confusing silent misuse of ByteBufferBen Wiederhake
Thankfully, this hasn't happened in any other code yet, but it happened while I was trying something out. Using '==' on two ByteBuffers to check whether they're equal seemed straight-forward, so I ran into the trap.
2020-08-22AK: Demonstrate surprising ByteBuffer behaviorBen Wiederhake
This seems to be because ByteBuffer implements 'operator bool', and C++ considers bool to be an integer type. Thus, when trying to find a way to evaluate '==', it attempts integer promotion, which in turn finds 'operator bool'. This explains why all non-empty buffers seem to be equal, but different from the empty one. Also, why comparison seems to be implemented.
2020-08-22Revert "Kernel: Move Singleton class to AK"Andreas Kling
This reverts commit f0906250a181c831508a45434b9f645ff98f33e4.
2020-08-22Revert "AK: Get rid of make_singleton function"Andreas Kling
This reverts commit 5a98e329d157a2db8379e0c97c6bdc1328027843.
2020-08-22AK: Make some tweaks in TestSuite.h.asynts
2020-08-22AK: Remove <chrono> requirement from TestSuite.h.asynts
2020-08-22AK: Remove exceptions from TestSuite.h.asynts
Serenity is build with -fno-exceptions, this is an effort to make TestSuite.h useable in the userland.
2020-08-22AK: Move include <AK/TestSuite.h> to the top.asynts
clang-format automatically sorts include statements that are in a 'block'. Adding a whitespace prevents this. It is crutial that <AK/TestSuite.h> is included first because it redefines some macros.
2020-08-22AK: Remove test case that doesn't test anything.asynts
Currently, there is no way to check that an assert fails. This test passes regardless of the assert. (AK/HashTable.h:93)
2020-08-22AK: Get rid of make_singleton functionTom
Just default the InitFunction template argument.
2020-08-22Kernel: Move Singleton class to AKTom
2020-08-21LibWeb: Use GenericLexer in WrapperGeneratorNico Weber
2020-08-21AK: Add Stream::offset_of(ReadonlyBytes)AnotherTest
2020-08-21AK+LibC+Kernel: Move the implementation of memmem to AKAnotherTest
2020-08-20LibCompress: Turn the DEFLATE implementation into a stream.asynts
Previously, the implementation would produce one Vector<u8> which would contain the whole decompressed data. That can be a lot and even exhaust memory. With these changes it is still necessary to store the whole input data in one piece (I am working on this next,) but the output can be read block by block. (That's not optimal either because blocks can be arbitrarily large, but it's good for now.)
2020-08-20AK: Add DuplexMemoryStream class.asynts
This class is similar to BufferStream because it is possible to both read and write to it. However, it differs in the following ways: - DuplexMemoryStream keeps a history of 64KiB and discards the rest, BufferStream always keeps everything around. - DuplexMemoryStream tracks reading and writing seperately, the following is valid: DuplexMemoryStream stream; stream << 42; int value; stream >> value; For BufferStream it would read: BufferStream stream; stream << 42; int value; stream.seek(0); stream >> value; In the future I would like to replace all usages of BufferStream with InputMemoryStream, OutputMemoryStream (doesn't exist yet) and DuplexMemoryStream. For now I just add DuplexMemoryStream though.
2020-08-20AK: Remove unnecessary FIXME comments from Stream.h.asynts
2020-08-20AK: Rename error() to has_error() for streams.asynts
2020-08-20AK: Remove fatal() from InputStream.asynts
Fatal errors can not be handeled and lead to an assertion error when the stream is destroyed. It makes no sense to delay the assertion failure, instead of setting m_fatal, an assertion should be done directly.
2020-08-20AK: Rename TestMemoryStream.cpp to TestStream.cpp.asynts
2020-08-20AK: Add StringView(ReadonlyBytes) constructor.asynts