Commit Graph

880 Commits

Author SHA1 Message Date
Andreas Kling
1ef5d609d9 AK+LibC: Add TODO() as an alternative to ASSERT_NOT_REACHED()
I've been using this in the new HTML parser and it makes it much easier
to understand the state of unfinished code branches.

TODO() is for places where it's okay to end up but we need to implement
something there.

ASSERT_NOT_REACHED() is for places where it's not okay to end up, and
something has gone wrong.
2020-05-30 11:31:49 +02:00
Andreas Kling
643464c455 AK: Make {String,FlyString}::is_one_of() const
Also, make the zero-argument variant private since it's not meant to be
called by clients directly.
2020-05-30 11:31:49 +02:00
Marcin Gasperowicz
9a4ee9aa1a Lagom: Adjust AK, LibCore and LibTLS to build on MacOS 2020-05-30 00:36:13 +02:00
Paul Redmond
4d4e578edf Ports: Fix CMake-based ports
The SDL port failed to build because the CMake toolchain filed pointed
to the old root. Now the toolchain file assumes that the Root is in
Build/Root.

Additionally, the AK/ and Kernel/ headers need to be installed in the
root too.
2020-05-29 20:21:10 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
AnotherTest
f9bf2c7e78 AK: Add StringView::split_view() taking a StringView
Since the task of splitting a string via another is pretty common, we
might as well have this overload of split_view() as well.
2020-05-28 11:01:08 +02:00
Andreas Kling
9a113b0229 AK: Add a simple randomness API
This can be used in code that builds on non-Serenity platforms.
2020-05-27 12:25:46 +02:00
Andreas Kling
16accb71a3 AK: Mark some popular String member functions ALWAYS_INLINE
I don't wanna see String::length() in a profile, jeez. :^)
2020-05-26 22:49:06 +02:00
Sergey Bugaev
602c3fdb3a AK: Rename FileSystemPath -> LexicalPath
And move canonicalized_path() to a static method on LexicalPath.

This is to make it clear that FileSystemPath/canonicalized_path() only
perform *lexical* canonicalization.
2020-05-26 14:35:10 +02:00
Brian Gianforcaro
27360f1f20 Build: Fix cmake test runner, so it knows when tests fail
The CMake runner looks at the return code if you don't set
the pattern. Since the AK test suite setup doesn't use return
codes, we were missing test failures.
2020-05-26 13:38:20 +02:00
Brian Gianforcaro
71deafe476 AK: Temporarily disable failing relative_paths tests in FileSystemPath suite
It appears this got broken in a3e4dfdf98.
I filed a tracking bug https://github.com/SerenityOS/serenity/issues/2388
2020-05-26 13:38:20 +02:00
Brian Gianforcaro
e5045b62b8 AK: Expand string tests to include ends_with case insensitivity 2020-05-26 13:17:19 +02:00
Brian Gianforcaro
129462cca7 AK: Unify FlyString/StringView::ends_with implementation on StringUtils::ends_with
This creates a unified implementation of ends_with with case sensitivity
across String/StringView/FlyString.
2020-05-26 13:17:19 +02:00
Brian Gianforcaro
332f96e7ca AK: Add case insensitive String::ends_with support
FileSystemPath::has_extension was jumping through hoops and allocating
memory to do a case insensitive comparison needlessly. Extend the
existing String::ends_with method to allow the caller to specify the
case sensitivity required.
2020-05-26 13:17:19 +02:00
Brian Gianforcaro
8e4b858b3f AK: Move String::ends_with implementation to StringUtils
Centralizing so it can be used by other string implementations
2020-05-26 13:17:19 +02:00
Andreas Kling
5e77517e6e AK: Add String::is_one_of(...)
This allows you to compare a string against an arbitrary number of
other strings with a single call.
2020-05-25 19:51:23 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
Andreas Kling
8fe4512f8e AK: Fix inconsistent signature for dbgputstr() 2020-05-23 15:25:43 +02:00
Andreas Kling
4177953530 AK: Simplify Types.h a little bit 2020-05-23 15:25:43 +02:00
Andreas Kling
e90ecdda48 AK: Add MakeSigned<T> helper template 2020-05-23 15:25:43 +02:00
Andreas Kling
6cefb96e98 AK: Allow NumericLimits.h to compile in a kernel context
We explicitly disallow floating point numbers during kernel compilation
so we have to #ifdef out those parts here.
2020-05-23 15:25:43 +02:00
FalseHonesty
b1e4f70173 AK: Fix URL::complete_url behaviour for when a fragment is passed
Previously, passing a fragment string ("#section3") to the complete_url
method would result in a URL that looked like
"file:///home/anon/www/#section3" which was obviously incorrect. Now the
result looks like "file:///home/anon/www/afrag.html#section3".
2020-05-23 11:53:25 +02:00
Sergey Bugaev
a3e4dfdf98 AK: Fix .. handling in FileSystemPath
We shouldn't just drop leading ..-s for relative paths. At the same time,
we should handle paths like

    ../foo/../../bar

correctly: the first .. after the foo cancels out the foo, but the second
one should get treated as a leading one and not get dropped.

Note that since this path resolution is purely lexical, it's never going to be
completely correct with respect to symlinks and other filesystem magic. Better
don't use it when dealing with files.
2020-05-22 23:55:35 +02:00
Andreas Kling
a1db1e6664 AK: Make JsonValue and JsonObjectSerializer speak int/long/long long
While width-oriented integer types are nicer from the programmer's
perspective, we have to accept that C++ thinks in int/long/long long.
2020-05-22 13:57:23 +02:00
Hüseyin ASLITÜRK
738235574f AK: StringUtils, add "convert_to_uint_from_hex" method
New method to convert hex string unsigned integer.
2020-05-21 01:19:42 +02:00
Andreas Kling
b55b26a2bc Revert "AK: Add InitializerList, an implementation of std::initializer_list"
This reverts commit 0a2cab0928.
2020-05-20 16:24:26 +02:00
Andreas Kling
bded472ec4 Revert "AK+LibC: Move non-placement new/delete into LibC"
This reverts commit 2c82347393.
2020-05-20 16:24:26 +02:00
Andreas Kling
67cc7d09a2 Revert "AK: Add AtomicRef, for atomically accesing a reference to a varaible"
This reverts commit aff594f1e7.
2020-05-20 16:24:26 +02:00
Andreas Kling
8876bfc3ac Revert "AK: Don't demangle in serenity :("
This reverts commit 4361a50225.
2020-05-20 16:24:26 +02:00
Andreas Kling
e10183a6c5 AK: Include Platform.h in RefCounted.h so we have ALWAYS_INLINE
Otherwise Lagom doesn't build on my host machine.
2020-05-20 14:13:39 +02:00
Sergey Bugaev
d2b500fbcb AK+Kernel: Help the compiler inline a bunch of trivial methods
If these methods get inlined, the compiler is able to statically eliminate most
of the assertions. Alas, it doesn't realize this, and believes inlining them to
be too expensive. So give it a strong hint that it's not the case.

This *decreases* the kernel binary size.
2020-05-20 14:11:13 +02:00
Andrew Kaster
4361a50225 AK: Don't demangle in serenity :(
In order to remove libstdc++ completely, we need to give up on their
implementation of abi::__cxa_demangle. The demangler logic will actually
have to be quite complex, and included in both the kernel and userspace.

A definite fixme for the future, to parse the mangled names into real
deal names.
2020-05-20 08:37:50 +02:00
Andrew Kaster
aff594f1e7 AK: Add AtomicRef, for atomically accesing a reference to a varaible
This is distintly different from Atomic<T*>, because we want to
atomically access a variable that the atomic object itself does not own.
2020-05-20 08:37:50 +02:00
Andrew Kaster
2c82347393 AK+LibC: Move non-placement new/delete into LibC
This allows operator new and operator delete to be available to anyone
that links -lc (everyone) rather than just people that include
kmalloc.h (almost no one).
2020-05-20 08:37:50 +02:00
Andrew Kaster
0a2cab0928 AK: Add InitializerList, an implementation of std::initializer_list
Use the AK version of std::initializer_list in AK::Vector, but only
when in serenity. When building AK for a non-serenity target, the header
<initializer_list> should be always available.
2020-05-20 08:37:50 +02:00
Sergey Bugaev
000a9cad34 AK: Fix Checked::multiplication_would_overflow() signature
The two-argument version doesn't need an extra template parameter.
2020-05-20 08:31:31 +02:00
Andreas Kling
7207276697 AK: Make Utf32View::substring_view() with 0 length not crash
Just make it hand out a zero-length Utf32View :^)
2020-05-18 16:48:54 +02:00
AnotherTest
a4e0b585fe AK: Add a way to get the number of valid bytes in a Utf8View 2020-05-18 11:31:43 +02:00
Andreas Kling
86242f9c18 AK: Add StringBuilder::append(Utf32View)
This encodes the incoming UTF-32 sequence as UTF-8.
2020-05-17 22:35:25 +02:00
Andreas Kling
00b5614ce2 AK: Add a very basic Utf32View class
This allows you to wrap a { const u32* codepoints, size_t length } in a
simple object.
2020-05-17 22:35:25 +02:00
Conrad Pankoff
b5b08fba92 AK: Make sure URL retains trailing slash if present in complete_url 2020-05-17 16:35:42 +02:00
Andreas Kling
6cde7e4d20 AK: Add Utf8View::length_in_codepoints() 2020-05-17 13:05:39 +02:00
Conrad Pankoff
4214680e76 AK: Set default port in URL to 1965 for gemini protocol 2020-05-17 12:41:38 +02:00
Linus Groh
b193670967 AK: Handle "protocol relative URLs" in URL::complete_url() 2020-05-16 21:47:16 +02:00
Linus Groh
ad3871b64e AK: Fix URL's operator<<() and use it 2020-05-16 21:47:16 +02:00
Andreas Kling
21d5f4ada1 Kernel: Absorb LibBareMetal back into the kernel
This was supposed to be the foundation for some kind of pre-kernel
environment, but nobody is working on it right now, so let's move
everything back into the kernel and remove all the confusion.
2020-05-16 12:00:04 +02:00
Dominik Madarasz
4e27c58be7 Build: FreeBSD support 2020-05-16 11:01:14 +02:00
Andreas Kling
76bcd284f9 AK: Remove experimental clang -Wconsumed stuff
This stopped working quite some time ago due to Clang losing track of
typestates for some reason and everything becoming "unknown".

Since we're primarily using GCC anyway, it doesn't seem worth it to try
and maintain this non-working experiment for a secondary compiler.

Also it doesn't look like the Clang team is actively maintaining this
flag anyway. So good-bye, -Wconsumed. :/
2020-05-16 10:55:54 +02:00
Andreas Kling
d8aa2a6997 AK: StringBuilder with 0 initial capacity shouldn't build null String
With 0 initial capacity, we don't allocate an underlying ByteBuffer
for the StringBuilder, which would then lead to a null String() being
returned from to_string().

This patch makes sure we always build a valid String.
2020-05-15 13:50:42 +02:00
Andreas Kling
f4c60740bd AK: Make FileSystemPath::extension() return what's after the last '.' 2020-05-14 20:41:17 +02:00