mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Exclude GenericLexer String APIs from the Kernel
These APIs are only used by userland, and String is OOM-infallible, so let's just ifdef it out of the Kernel.
This commit is contained in:
parent
410183a7b0
commit
b22cb40565
Notes:
sideshowbarker
2024-07-17 18:40:21 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/b22cb40565 Pull-request: https://github.com/SerenityOS/serenity/pull/12564 Reviewed-by: https://github.com/MaxWipfli
2 changed files with 15 additions and 2 deletions
|
@ -7,9 +7,12 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf16View.h>
|
||||
|
||||
#ifndef KERNEL
|
||||
# include <AK/String.h>
|
||||
# include <AK/Utf16View.h>
|
||||
#endif
|
||||
|
||||
namespace AK {
|
||||
// Consume a number of characters
|
||||
|
@ -125,6 +128,7 @@ StringView GenericLexer::consume_quoted_string(char escape_char)
|
|||
return m_input.substring_view(start, length);
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
String GenericLexer::consume_and_unescape_string(char escape_char)
|
||||
{
|
||||
auto view = consume_quoted_string(escape_char);
|
||||
|
@ -206,5 +210,6 @@ auto GenericLexer::decode_single_or_paired_surrogate(bool combine_surrogate_pair
|
|||
retreat(6);
|
||||
return *high_surrogate;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -83,10 +83,12 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
bool consume_specific(const String& next)
|
||||
{
|
||||
return consume_specific(StringView { next });
|
||||
}
|
||||
#endif
|
||||
|
||||
constexpr bool consume_specific(const char* next)
|
||||
{
|
||||
|
@ -115,14 +117,18 @@ public:
|
|||
StringView consume_until(const char*);
|
||||
StringView consume_until(StringView);
|
||||
StringView consume_quoted_string(char escape_char = 0);
|
||||
#ifndef KERNEL
|
||||
String consume_and_unescape_string(char escape_char = '\\');
|
||||
#endif
|
||||
|
||||
enum class UnicodeEscapeError {
|
||||
MalformedUnicodeEscape,
|
||||
UnicodeEscapeOverflow,
|
||||
};
|
||||
|
||||
#ifndef KERNEL
|
||||
Result<u32, UnicodeEscapeError> consume_escaped_code_point(bool combine_surrogate_pairs = true);
|
||||
#endif
|
||||
|
||||
constexpr void ignore(size_t count = 1)
|
||||
{
|
||||
|
@ -212,8 +218,10 @@ protected:
|
|||
size_t m_index { 0 };
|
||||
|
||||
private:
|
||||
#ifndef KERNEL
|
||||
Result<u32, UnicodeEscapeError> decode_code_point();
|
||||
Result<u32, UnicodeEscapeError> decode_single_or_paired_surrogate(bool combine_surrogate_pairs);
|
||||
#endif
|
||||
};
|
||||
|
||||
constexpr auto is_any_of(StringView values)
|
||||
|
|
Loading…
Reference in a new issue