summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2021-06-13AK: Add FlyString::from_fly_impl()Andreas Kling
This allows you to create a FlyString directly from a known-fly StringImpl instance.
2021-06-13Userland: Allow building SerenityOS with -funsigned-charGunnar Beutner
Some of the code assumed that chars were always signed while that is not the case on ARM hosts. Also, some of the code tried to use EOF (-1) in a way similar to what fgetc() does, however instead of storing the characters in an int variable a char was used. While this seemed to work it also meant that character 0xFF would be incorrectly seen as an end-of-file. Careful reading of fgetc() reveals that fgetc() stores character data in an int where valid characters are in the range of 0-255 and the EOF value is explicitly outside of that range (usually -1).
2021-06-12AK: Add ByteBuffer::append(ReadonlyBytes)Matthew Olsson
2021-06-12AK: Make Ptr32 more transparentHediadyoin1
This adds a transparent dereference operator, aswell as a constant arrow operator Also increaces the verbosity of the code
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
2021-06-11AK+LibX86: Generalize u128/256 to AK::UFixedBigIntHendiadyoin1
Doing these as custom classes might be faster, especially when writing them in SSE, but this would cause a lot of Code duplication and due to the nature of constexprs and the intelligence of the compiler they might be using SSE/MMX either way
2021-06-11AK: Make NonnullRefPtrVector constructible from Vector<NonnullRefPtr>Ali Mohammad Pur
2021-06-09AK: Make Vector::take_last() ALWAYS_INLINEAli Mohammad Pur
This function doesn't do a whole lot, but is called quite a bit.
2021-06-09AK: Make a bunch of Variant methods ALWAYS_INLINEAli Mohammad Pur
2021-06-09Meta: Disable -Wmaybe-uninitializedAli Mohammad Pur
It's prone to finding "technically uninitialized but can never happen" cases, particularly in Optional<T> and Variant<Ts...>. The general case seems to be that it cannot infer the dependency between Variant's index (or Optional's boolean state) and a particular alternative (or Optional's buffer) being untouched. So it can flag cases like this: ```c++ if (index == StaticIndexForF) new (new_buffer) F(move(*bit_cast<F*>(old_buffer))); ``` The code in that branch can _technically_ make a partially initialized `F`, but that path can never be taken since the buffer holding an object of type `F` and the condition being true are correlated, and so will never be taken _unless_ the buffer holds an object of type `F`. This commit also removed the various 'diagnostic ignored' pragmas used to work around this warning, as they no longer do anything.
2021-06-09AK: Implement IPv4Address::to_string_reversed()Max Wipfli
2021-06-09AK: Allow changing the HashTable behaviour for sets on existing entriesIdan Horowitz
Specifically, replacing the existing entry or just keeping it and canceling the set.
2021-06-08AK: Make Vector capable of holding reference typesAli Mohammad Pur
This commit makes it possible to instantiate `Vector<T&>` and use it to store references to `T` in a vector. All non-pointer observers are made to return the reference, and the pointer observers simply yield the underlying pointer. Note that the 'find_*' methods act on the values and not the pointers that are stored in the vector. This commit also makes errors in various vector methods much more readable by directly using requires-clauses on them. And finally, it should be noted that Vector cannot hold temporaries :^)
2021-06-08AK: Switch to east const in Vector.hAli Mohammad Pur
Let's get this out of the way before touching the file.
2021-06-08AK: Reorder Vector methods to place similar methods next to each otherAli Mohammad Pur
The methods of this class were all over the place, this commit reorders them to place them in a more logical order: - Constructors/Destructor - Observers - Comparisons and const existence checks - Mutators: insert - Mutators: append - Mutators: prepend - Mutators: assignment - Mutators: remove - OOM-safe mutators: insert - OOM-safe mutators: append - OOM-safe mutators: prepend - OOM-safe size management - Size management - Iterators
2021-06-08AK: Rename Vector::{value_type => ValueType}Ali Mohammad Pur
2021-06-08AK: Don't create Utf8View from temporary String in URLParserMax Wipfli
This fixes a bug where a Utf8View was created with data from a temporary string, which was immediately deleted. This lead to a use-after-free issue. This also changes most occurences for StringBuilder::to_string in URLParser to use ::string_view(), as the value is passed as StringView const& most of the time anyways. This fixes oss-fuzz issue 34973.
2021-06-08AK: Utf8CodePointIterator: Don't output full string to debug outputMax Wipfli
When a code point is invalid, the full string was outputted to the debug output. For large strings, this can make the system quite slow. Furthermore, one of the cases incorrectly assumed the data to be null terminated. This patch modifies the debug statements not to print the full string. This fixes oss-fuzz issue 35050.
2021-06-08LibC+AK: Remove our custom macros from <assert.h>Gunnar Beutner
Other software might not expect these to be defined and behave differently if they _are_ defined, e.g. scummvm which checks if the TODO macro is defined and fails to build if it is.
2021-06-08AK: Add children() accessor to TrieMax Wipfli
2021-06-07LibJS: Move bytecode debug spam behind JS_BYTECODE_DEBUG :^)Andreas Kling
2021-06-07AK: Add IntrusiveList::size_slow() to match InlineLinkedListBrian Gianforcaro
The functionality is needed to replace InlineLinkedList with IntrusiveList in the Kernel Process class.
2021-06-06LibVideo: Scaffold LibVideo and implement simplistic Matroska parserFalseHonesty
This commit initializes the LibVideo library and implements parsing basic Matroska container files. Currently, it will only parse audio and video tracks.
2021-06-06Revert "Revert "AK: Always inline FlyString::view()""Linus Groh
This reverts commit f09216ac42bac9108e7f36ed2938c6f278f497e4. This was supposed to be a local test only, didn't mean to push it. :^)
2021-06-06Revert "AK: Always inline FlyString::view()"Linus Groh
This reverts commit 66f15c2e0c34caed8ce56075a366b20c4d1819af.
2021-06-06AK: Add the parse_ascii_base36_digit methodIdan Horowitz
This is similar to parse_ascii_hex_digit but can parse the whole A-Z range (also known as base36).
2021-06-06AK+Everywhere: Disallow constructing Functions from incompatible typesAli Mohammad Pur
Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story.
2021-06-05AK: Always inline FlyString::view()Andreas Kling
2021-06-05AK: Stop using U+0000 as end of file code point in URL parserMax Wipfli
This changes URL parser to use the 0xFFFFFFFF constant instead of 0 to indicate end of file. This fixes a bug where inputs containing null bytes would terminate the parser early, because they were interpreted as end of file.
2021-06-05AK: Make debugging URLParser easierMax Wipfli
This patch adds a state_name method to URLParser to convert a state to a string. With this, the debugging statements now display the state names. Furthermore, this fixes a bug where non-ASCII code points were formatted as characters, which fails an assertion in the formatting system.
2021-06-05AK: Do not trim away non-ASCII bytes when parsing URLMax Wipfli
Because non-ASCII code points have negative byte values, trimming away control characters requires checking for negative bytes values. This also adds a test case with a URL containing non-ASCII code points.
2021-06-05AK: Update URLParser.{cpp,h} to use east constMax Wipfli
2021-06-04AK: Verify that functions aren't modified while they're being invokedGunnar Beutner
A Function object should not be set to a different functor while the original functor is currently executing.
2021-06-04AK: Allow deferring clear() for the Function classGunnar Beutner
Ideally a Function should not be clear()ed while it's running. Unfortunately a number of callers do just that and identifying all of them would require inspecting all call sites for operator() and clear(). Instead this adds support for deferring clear() until after the function has finished executing.
2021-06-04AK: Inline *String::is_one_of<Ts...>()Ali Mohammad Pur
Previously this was generating a crazy number of symbols, and it was also pretty-damn-slow as it was defined recursively, which made the compiler incapable of inlining it (due to the many many layers of recursion before it terminated). This commit replaces the recursion with a pack expansion and marks it always-inline.
2021-06-04AK: Don’t drop lines between \r and \n in StringView::lines() (#7662)R Smith
StringView::lines() supports line-separators β€œ\n”, β€œ\r”, and β€œ\r\n”. The method will drop an entire line if it is surrounded by β€œ\r” and β€œ\n” separators on the left and right sides respectively.
2021-06-03AK: Do not VERIFY on invalid code point bytes in UTF8ViewDexesTTP
The previous behavior was to always VERIFY that the UTF-8 bytes were valid when iterating over the code points of an UTF8View. This change makes it so we instead output the 0xFFFD 'REPLACEMENT CHARACTER' code point when encountering invalid bytes, and keep iterating the view after skipping one byte. Leaving the decision to the consumer would break symmetry with the UTF32View API, which would in turn require heavy refactoring and/or code duplication in generic code such as the one found in Gfx::Painter and the Shell. To make it easier for the consumers to detect the original bytes, we provide a new method on the iterator that returns a Span over the data that has been decoded. This method is immediately used in the TextNode::compute_text_for_rendering method, which previously did this in a ad-hoc waay. This also add tests for the new behavior in TestUtf8.cpp, as well as reinforcements to the existing tests to check if the underlying bytes match up with their expected values.
2021-06-03Everywhere: Replace ctype.h to avoid narrowing conversionsMax Wipfli
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.
2021-06-03AK: Add CharacterTypes.hMax Wipfli
This patch introduces CharacterTypes.h, which aims to be a replacement for most usages of ctype.h. In contrast to that implementation, this header makes use of exclusively constexpr functions and support the full Unicode code point set without any narrowing-conversion issues.
2021-06-03AK: Add reverse iterator support to AK::IntrusiveListBrian Gianforcaro
In order for IntrusiveList to be capable of replacing InlineLinkedList, it needs to support reverse iteration. InlineLinkedList currently supports manual reverse iteration by calling list->last() followed by node->prev().
2021-06-03AK: Remove unused JsonValue <=> IPv4Address conversion codeGunnar Beutner
This removes code that isn't used anywhere.
2021-06-03AK: Allow inlining more string functionsGunnar Beutner
2021-06-03AK: Allow inlining ref-count functionalityGunnar Beutner
Previously we'd incur the costs for a function call via the PLT even for the most trivial ref-count actions like increasing/decreasing the reference count. By moving the code to the header file we allow the compiler to inline this code into the caller's function.
2021-06-02AK+LibWasm+LibJS: Disallow Variant.has() on types that aren't containedAli Mohammad Pur
Checking for this (and get()'ing it) is always invalid, so let's just disallow it. This also finds two bugs where the code is checking for types that can never actually be in the variant (which was actually a refactor artifact).
2021-06-02AK: Make checked division also check for divide by zeroAli Mohammad Pur
2021-06-01AK+Everywhere: Fix compiletime format parsing of replacement fieldsAli Mohammad Pur
2021-06-01AK: Strip leading/trailing C0-control-or-space in URLs correctlyAndreas Kling
We have to stop scanning once we hit a non-strippable character. Add some tests to cover this.
2021-06-01AK: Move identity check from URL::operator==() to equals()Max Wipfli
2021-06-01AK+LibWeb: Remove URL::to_string_encoded()Max Wipfli
This replaces URL::to_string_encoded() with to_string() and removes the former, since they are now equivalent.
2021-06-01AK: Use correct constness in URL class methodsMax Wipfli
This changes the URL class to use the correct constness for getters, setters and other methods. It also changes the entire class to use east const style.