mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 18:46:03 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
80
Libraries/LibJS/Runtime/PrimitiveString.h
Normal file
80
Libraries/LibJS/Runtime/PrimitiveString.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Utf16String.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
class PrimitiveString final : public Cell {
|
||||
JS_CELL(PrimitiveString, Cell);
|
||||
JS_DECLARE_ALLOCATOR(PrimitiveString);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, Utf16String);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, String);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, FlyString const&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, ByteString);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, DeprecatedFlyString const&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, PrimitiveString&, PrimitiveString&);
|
||||
[[nodiscard]] static NonnullGCPtr<PrimitiveString> create(VM&, StringView);
|
||||
|
||||
virtual ~PrimitiveString();
|
||||
|
||||
PrimitiveString(PrimitiveString const&) = delete;
|
||||
PrimitiveString& operator=(PrimitiveString const&) = delete;
|
||||
|
||||
bool is_empty() const;
|
||||
|
||||
[[nodiscard]] String utf8_string() const;
|
||||
[[nodiscard]] StringView utf8_string_view() const;
|
||||
bool has_utf8_string() const { return m_utf8_string.has_value(); }
|
||||
|
||||
[[nodiscard]] ByteString byte_string() const;
|
||||
bool has_byte_string() const { return m_byte_string.has_value(); }
|
||||
|
||||
[[nodiscard]] Utf16String utf16_string() const;
|
||||
[[nodiscard]] Utf16View utf16_string_view() const;
|
||||
bool has_utf16_string() const { return m_utf16_string.has_value(); }
|
||||
|
||||
ThrowCompletionOr<Optional<Value>> get(VM&, PropertyKey const&) const;
|
||||
|
||||
private:
|
||||
explicit PrimitiveString(PrimitiveString&, PrimitiveString&);
|
||||
explicit PrimitiveString(String);
|
||||
explicit PrimitiveString(ByteString);
|
||||
explicit PrimitiveString(Utf16String);
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
enum class EncodingPreference {
|
||||
UTF8,
|
||||
UTF16,
|
||||
};
|
||||
void resolve_rope_if_needed(EncodingPreference) const;
|
||||
|
||||
mutable bool m_is_rope { false };
|
||||
|
||||
mutable GCPtr<PrimitiveString> m_lhs;
|
||||
mutable GCPtr<PrimitiveString> m_rhs;
|
||||
|
||||
mutable Optional<String> m_utf8_string;
|
||||
mutable Optional<ByteString> m_byte_string;
|
||||
mutable Optional<Utf16String> m_utf16_string;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue