mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:47:45 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
8639d8bc21
commit
d26aabff04
140 changed files with 1202 additions and 723 deletions
|
@ -7,7 +7,7 @@
|
|||
#ifndef _ASSERT_H
|
||||
# define _ASSERT_H
|
||||
|
||||
# define __stringify_helper(x) # x
|
||||
# define __stringify_helper(x) #x
|
||||
# define __stringify(x) __stringify_helper(x)
|
||||
|
||||
# ifndef __cplusplus
|
||||
|
|
|
@ -276,7 +276,7 @@ bool FILE::gets(T* data, size_t size)
|
|||
if (m_buffer.may_use()) {
|
||||
// Let's see if the buffer has something queued for us.
|
||||
size_t queued_size;
|
||||
const T* queued_data = bit_cast<const T*>(m_buffer.begin_dequeue(queued_size));
|
||||
T const* queued_data = bit_cast<T const*>(m_buffer.begin_dequeue(queued_size));
|
||||
queued_size /= sizeof(T);
|
||||
if (queued_size == 0) {
|
||||
// Nothing buffered; we're going to have to read some.
|
||||
|
|
|
@ -8,7 +8,9 @@ extern "C" {
|
|||
|
||||
#define DO_STUB(name) \
|
||||
void name(); \
|
||||
void name() { }
|
||||
void name() \
|
||||
{ \
|
||||
}
|
||||
|
||||
DO_STUB(__register_frame_info);
|
||||
DO_STUB(__deregister_frame_info);
|
||||
|
|
|
@ -68,11 +68,11 @@ Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() co
|
|||
return all_sourced_paths.value();
|
||||
|
||||
struct : public ::Shell::AST::NodeVisitor {
|
||||
void visit(const ::Shell::AST::CastToCommand* node) override
|
||||
void visit(::Shell::AST::CastToCommand const* node) override
|
||||
{
|
||||
auto& inner = node->inner();
|
||||
if (inner->is_list()) {
|
||||
if (auto* list = dynamic_cast<const ::Shell::AST::ListConcatenate*>(inner.ptr())) {
|
||||
if (auto* list = dynamic_cast<::Shell::AST::ListConcatenate const*>(inner.ptr())) {
|
||||
auto& entries = list->list();
|
||||
if (entries.size() == 2 && entries.first()->is_bareword() && static_ptr_cast<::Shell::AST::BarewordLiteral>(entries.first())->text() == "source") {
|
||||
auto& filename = entries[1];
|
||||
|
@ -200,7 +200,7 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
|
|||
{
|
||||
}
|
||||
|
||||
void visit(const ::Shell::AST::VariableDeclarations* node) override
|
||||
void visit(::Shell::AST::VariableDeclarations const* node) override
|
||||
{
|
||||
for (auto& entry : node->variables()) {
|
||||
auto literal = entry.name->leftmost_trivial_literal();
|
||||
|
@ -219,7 +219,7 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
|
|||
::Shell::AST::NodeVisitor::visit(node);
|
||||
}
|
||||
|
||||
void visit(const ::Shell::AST::FunctionDeclaration* node) override
|
||||
void visit(::Shell::AST::FunctionDeclaration const* node) override
|
||||
{
|
||||
dbgln("Found function {}", node->name().name);
|
||||
declarations.append({ node->name().name, { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} });
|
||||
|
|
|
@ -56,12 +56,12 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
const T* data() const
|
||||
T const* data() const
|
||||
{
|
||||
static_assert(IsVoid<T> || IsTrivial<T>);
|
||||
if (!m_impl)
|
||||
return nullptr;
|
||||
return (const T*)m_impl->data();
|
||||
return (T const*)m_impl->data();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -461,7 +461,8 @@ void ArgsParser::add_option(StringView& value, char const* help_string, char con
|
|||
}
|
||||
|
||||
template<typename Integral>
|
||||
void ArgsParser::add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode) requires(IsIntegral<Integral>)
|
||||
void ArgsParser::add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
requires(IsIntegral<Integral>)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Required,
|
||||
|
|
|
@ -90,7 +90,8 @@ public:
|
|||
void add_option(String& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(StringView& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
template<typename Integral>
|
||||
void add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None) requires(IsIntegral<Integral>);
|
||||
void add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None)
|
||||
requires(IsIntegral<Integral>);
|
||||
void add_option(double& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(Optional<double>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(Optional<size_t>& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
|
|
|
@ -67,7 +67,10 @@ enum class TimerShouldFireWhenNotVisible {
|
|||
|
||||
#define C_OBJECT(klass) \
|
||||
public: \
|
||||
virtual StringView class_name() const override { return #klass##sv; } \
|
||||
virtual StringView class_name() const override \
|
||||
{ \
|
||||
return #klass##sv; \
|
||||
} \
|
||||
template<typename Klass = klass, class... Args> \
|
||||
static NonnullRefPtr<klass> construct(Args&&... args) \
|
||||
{ \
|
||||
|
@ -79,9 +82,12 @@ public:
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) Klass(::forward<Args>(args)...)); \
|
||||
}
|
||||
|
||||
#define C_OBJECT_ABSTRACT(klass) \
|
||||
public: \
|
||||
virtual StringView class_name() const override { return #klass##sv; }
|
||||
#define C_OBJECT_ABSTRACT(klass) \
|
||||
public: \
|
||||
virtual StringView class_name() const override \
|
||||
{ \
|
||||
return #klass##sv; \
|
||||
}
|
||||
|
||||
class Object
|
||||
: public RefCounted<Object>
|
||||
|
@ -119,13 +125,16 @@ public:
|
|||
}
|
||||
|
||||
template<typename T, typename Callback>
|
||||
void for_each_child_of_type(Callback callback) requires IsBaseOf<Object, T>;
|
||||
void for_each_child_of_type(Callback callback)
|
||||
requires IsBaseOf<Object, T>;
|
||||
|
||||
template<typename T>
|
||||
T* find_child_of_type_named(String const&) requires IsBaseOf<Object, T>;
|
||||
T* find_child_of_type_named(String const&)
|
||||
requires IsBaseOf<Object, T>;
|
||||
|
||||
template<typename T>
|
||||
T* find_descendant_of_type_named(String const&) requires IsBaseOf<Object, T>;
|
||||
T* find_descendant_of_type_named(String const&)
|
||||
requires IsBaseOf<Object, T>;
|
||||
|
||||
bool is_ancestor_of(Object const&) const;
|
||||
|
||||
|
@ -226,7 +235,8 @@ struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> {
|
|||
|
||||
namespace Core {
|
||||
template<typename T, typename Callback>
|
||||
inline void Object::for_each_child_of_type(Callback callback) requires IsBaseOf<Object, T>
|
||||
inline void Object::for_each_child_of_type(Callback callback)
|
||||
requires IsBaseOf<Object, T>
|
||||
{
|
||||
for_each_child([&](auto& child) {
|
||||
if (is<T>(child))
|
||||
|
@ -236,7 +246,8 @@ inline void Object::for_each_child_of_type(Callback callback) requires IsBaseOf<
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_child_of_type_named(String const& name) requires IsBaseOf<Object, T>
|
||||
T* Object::find_child_of_type_named(String const& name)
|
||||
requires IsBaseOf<Object, T>
|
||||
{
|
||||
T* found_child = nullptr;
|
||||
for_each_child_of_type<T>([&](auto& child) {
|
||||
|
@ -251,7 +262,8 @@ T* Object::find_child_of_type_named(String const& name) requires IsBaseOf<Object
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<Object, T>
|
||||
T* Object::find_descendant_of_type_named(String const& name)
|
||||
requires IsBaseOf<Object, T>
|
||||
{
|
||||
if (is<T>(*this) && this->name() == name) {
|
||||
return static_cast<T*>(this);
|
||||
|
|
|
@ -279,7 +279,8 @@ class PosixSocketHelper {
|
|||
|
||||
public:
|
||||
template<typename T>
|
||||
PosixSocketHelper(Badge<T>) requires(IsBaseOf<Socket, T>)
|
||||
PosixSocketHelper(Badge<T>)
|
||||
requires(IsBaseOf<Socket, T>)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
Optional<size_t> index_of_node_at(Position) const;
|
||||
Optional<Token> token_at(Position) const;
|
||||
Optional<size_t> index_of_token_at(Position) const;
|
||||
RefPtr<const TranslationUnit> root_node() const { return m_root_node; }
|
||||
RefPtr<TranslationUnit const> root_node() const { return m_root_node; }
|
||||
String text_of_node(ASTNode const&) const;
|
||||
StringView text_of_token(Cpp::Token const& token) const;
|
||||
void print_tokens() const;
|
||||
|
|
|
@ -318,7 +318,7 @@ void pretty_print(Decoder& decoder, OutputStream& stream, int indent)
|
|||
break;
|
||||
}
|
||||
case Kind::BitString: {
|
||||
auto value = decoder.read<const BitmapView>();
|
||||
auto value = decoder.read<BitmapView const>();
|
||||
if (value.is_error()) {
|
||||
dbgln("BitString PrettyPrint error: {}", value.error());
|
||||
return;
|
||||
|
|
|
@ -18,7 +18,7 @@ class SignedBigInteger {
|
|||
public:
|
||||
template<typename T>
|
||||
requires(IsSigned<T> && sizeof(T) <= sizeof(i32))
|
||||
SignedBigInteger(T value)
|
||||
SignedBigInteger(T value)
|
||||
: m_sign(value < 0)
|
||||
, m_unsigned_data(abs(static_cast<i32>(value)))
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
// This constructor accepts any unsigned with size up to Word.
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) <= sizeof(Word))
|
||||
UnsignedBigInteger(T value)
|
||||
UnsignedBigInteger(T value)
|
||||
{
|
||||
m_words.append(static_cast<Word>(value));
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
|
||||
virtual size_t IV_length() const = 0;
|
||||
|
||||
const T& cipher() const { return m_cipher; }
|
||||
T const& cipher() const { return m_cipher; }
|
||||
|
||||
ErrorOr<ByteBuffer> create_aligned_buffer(size_t input_size) const
|
||||
{
|
||||
|
|
|
@ -70,7 +70,8 @@ public:
|
|||
return value();
|
||||
}
|
||||
|
||||
operator double() const requires(IsSame<ParameterT, ParameterFixedPoint>)
|
||||
operator double() const
|
||||
requires(IsSame<ParameterT, ParameterFixedPoint>)
|
||||
{
|
||||
return static_cast<double>(value());
|
||||
}
|
||||
|
|
|
@ -166,16 +166,16 @@ T Parser::read_host(T const* field) const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T Parser::read_le(T const* field)
|
||||
const
|
||||
requires(IsIntegral<T> && sizeof(T) > 1)
|
||||
T Parser::read_le(T const* field) const
|
||||
{
|
||||
static_assert(sizeof(T) > 1);
|
||||
return AK::convert_between_host_and_little_endian(read_host(field));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T Parser::read_be(T const* field)
|
||||
const
|
||||
requires(IsIntegral<T> && sizeof(T) > 1)
|
||||
T Parser::read_be(T const* field) const
|
||||
{
|
||||
static_assert(sizeof(T) > 1);
|
||||
return AK::convert_between_host_and_big_endian(read_host(field));
|
||||
|
|
|
@ -438,12 +438,12 @@ private:
|
|||
T read_host(T const*) const;
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T read_le(T const*)
|
||||
const;
|
||||
requires(IsIntegral<T> && sizeof(T) > 1)
|
||||
T read_le(T const*) const;
|
||||
|
||||
template<typename T>
|
||||
requires(IsIntegral<T> && sizeof(T) > 1) T read_be(T const*)
|
||||
const;
|
||||
requires(IsIntegral<T> && sizeof(T) > 1)
|
||||
T read_be(T const*) const;
|
||||
|
||||
Definitions::EDID const& raw_edid() const;
|
||||
ErrorOr<IterationDecision> for_each_display_descriptor(Function<IterationDecision(u8, Definitions::DisplayDescriptor const&)>) const;
|
||||
|
|
|
@ -305,8 +305,7 @@ void GLContext::gl_blend_func(GLenum src_factor, GLenum dst_factor)
|
|||
m_blend_source_factor = src_factor;
|
||||
m_blend_destination_factor = dst_factor;
|
||||
|
||||
auto map_gl_blend_factor_to_device = [](GLenum factor) constexpr
|
||||
{
|
||||
auto map_gl_blend_factor_to_device = [](GLenum factor) constexpr {
|
||||
switch (factor) {
|
||||
case GL_ZERO:
|
||||
return GPU::BlendFactor::Zero;
|
||||
|
|
|
@ -16,21 +16,22 @@ namespace GUI {
|
|||
template<typename T, typename Container = Vector<T>, typename ColumnNameListType = void>
|
||||
class ItemListModel : public Model {
|
||||
public:
|
||||
static constexpr auto IsTwoDimensional = requires(Container data)
|
||||
{
|
||||
requires !IsVoid<ColumnNameListType>;
|
||||
data.at(0).at(0);
|
||||
data.at(0).size();
|
||||
};
|
||||
static constexpr auto IsTwoDimensional = requires(Container data) {
|
||||
requires !IsVoid<ColumnNameListType>;
|
||||
data.at(0).at(0);
|
||||
data.at(0).size();
|
||||
};
|
||||
|
||||
// Substitute 'void' for a dummy u8.
|
||||
using ColumnNamesT = Conditional<IsVoid<ColumnNameListType>, u8, ColumnNameListType>;
|
||||
|
||||
static NonnullRefPtr<ItemListModel> create(Container const& data, ColumnNamesT const& column_names, Optional<size_t> const& row_count = {}) requires(IsTwoDimensional)
|
||||
static NonnullRefPtr<ItemListModel> create(Container const& data, ColumnNamesT const& column_names, Optional<size_t> const& row_count = {})
|
||||
requires(IsTwoDimensional)
|
||||
{
|
||||
return adopt_ref(*new ItemListModel<T, Container, ColumnNameListType>(data, column_names, row_count));
|
||||
}
|
||||
static NonnullRefPtr<ItemListModel> create(Container const& data, Optional<size_t> const& row_count = {}) requires(!IsTwoDimensional)
|
||||
static NonnullRefPtr<ItemListModel> create(Container const& data, Optional<size_t> const& row_count = {})
|
||||
requires(!IsTwoDimensional)
|
||||
{
|
||||
return adopt_ref(*new ItemListModel<T, Container>(data, row_count));
|
||||
}
|
||||
|
@ -119,13 +120,15 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
explicit ItemListModel(Container const& data, Optional<size_t> row_count = {}) requires(!IsTwoDimensional)
|
||||
explicit ItemListModel(Container const& data, Optional<size_t> row_count = {})
|
||||
requires(!IsTwoDimensional)
|
||||
: m_data(data)
|
||||
, m_provided_row_count(move(row_count))
|
||||
{
|
||||
}
|
||||
|
||||
explicit ItemListModel(Container const& data, ColumnNamesT const& column_names, Optional<size_t> row_count = {}) requires(IsTwoDimensional)
|
||||
explicit ItemListModel(Container const& data, ColumnNamesT const& column_names, Optional<size_t> row_count = {})
|
||||
requires(IsTwoDimensional)
|
||||
: m_data(data)
|
||||
, m_column_names(column_names)
|
||||
, m_provided_row_count(move(row_count))
|
||||
|
|
|
@ -45,7 +45,8 @@ public:
|
|||
virtual ~Node() = default;
|
||||
|
||||
template<typename NodeType = Node, typename... Args>
|
||||
NonnullRefPtr<NodeType> add_node(String text, Optional<Icon> icon, Args&&... args) requires(IsBaseOf<Node, NodeType>)
|
||||
NonnullRefPtr<NodeType> add_node(String text, Optional<Icon> icon, Args&&... args)
|
||||
requires(IsBaseOf<Node, NodeType>)
|
||||
{
|
||||
auto node = adopt_ref(*new NodeType(move(text), move(icon), this, forward<Args>(args)...));
|
||||
m_child_nodes.append(*static_cast<Node const*>(node.ptr()));
|
||||
|
@ -72,7 +73,8 @@ public:
|
|||
NonnullRefPtrVector<Node>& nodes() { return m_nodes; }
|
||||
|
||||
template<typename NodeType = Node, typename... Args>
|
||||
NonnullRefPtr<NodeType> add_node(String text, Optional<Icon> icon, Args&&... args) requires(IsBaseOf<Node, NodeType>)
|
||||
NonnullRefPtr<NodeType> add_node(String text, Optional<Icon> icon, Args&&... args)
|
||||
requires(IsBaseOf<Node, NodeType>)
|
||||
{
|
||||
auto node = adopt_ref(*new NodeType(move(text), move(icon), nullptr, forward<Args>(args)...));
|
||||
m_nodes.append(*static_cast<Node const*>(node.ptr()));
|
||||
|
|
|
@ -42,12 +42,14 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
Variant(T&& value) requires(IsConstructible<String, T>)
|
||||
Variant(T&& value)
|
||||
requires(IsConstructible<String, T>)
|
||||
: Variant(String(forward<T>(value)))
|
||||
{
|
||||
}
|
||||
template<typename T>
|
||||
Variant& operator=(T&& v) requires(IsConstructible<String, T>)
|
||||
Variant& operator=(T&& v)
|
||||
requires(IsConstructible<String, T>)
|
||||
{
|
||||
set(String(v));
|
||||
return *this;
|
||||
|
|
|
@ -474,7 +474,7 @@ inline Widget* Widget::parent_widget()
|
|||
inline Widget const* Widget::parent_widget() const
|
||||
{
|
||||
if (parent() && is<Widget>(*parent()))
|
||||
return &verify_cast<const Widget>(*parent());
|
||||
return &verify_cast<Widget const>(*parent());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public:
|
|||
|
||||
template<typename U>
|
||||
requires(!IsSame<T, U>)
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr Line<U> to_type() const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr Line<U> to_type() const
|
||||
{
|
||||
return Line<U>(*this);
|
||||
}
|
||||
|
|
|
@ -212,7 +212,8 @@ public:
|
|||
}
|
||||
|
||||
template<size_t U>
|
||||
[[nodiscard]] constexpr Matrix<U, T> submatrix_from_topleft() const requires(U > 0 && U < N)
|
||||
[[nodiscard]] constexpr Matrix<U, T> submatrix_from_topleft() const
|
||||
requires(U > 0 && U < N)
|
||||
{
|
||||
Matrix<U, T> result;
|
||||
for (size_t i = 0; i < U; ++i) {
|
||||
|
|
|
@ -232,7 +232,7 @@ template<typename T>
|
|||
ALWAYS_INLINE static void unpack_grayscale_without_alpha(PNGLoadingContext& context)
|
||||
{
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* gray_values = reinterpret_cast<const T*>(context.scanlines[y].data.data());
|
||||
auto* gray_values = reinterpret_cast<T const*>(context.scanlines[y].data.data());
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
pixel.r = gray_values[i];
|
||||
|
|
|
@ -230,7 +230,7 @@ public:
|
|||
|
||||
template<typename U>
|
||||
requires(!IsSame<T, U>)
|
||||
[[nodiscard]] Point<U> to_type() const
|
||||
[[nodiscard]] Point<U> to_type() const
|
||||
{
|
||||
return Point<U>(*this);
|
||||
}
|
||||
|
|
|
@ -950,7 +950,7 @@ public:
|
|||
|
||||
template<typename U>
|
||||
requires(!IsSame<T, U>)
|
||||
[[nodiscard]] ALWAYS_INLINE Rect<U> to_type() const
|
||||
[[nodiscard]] ALWAYS_INLINE Rect<U> to_type() const
|
||||
{
|
||||
return Rect<U>(*this);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
|
||||
template<typename U>
|
||||
requires(!IsSame<T, U>)
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr Size<U> to_type() const
|
||||
[[nodiscard]] ALWAYS_INLINE constexpr Size<U> to_type() const
|
||||
{
|
||||
return Size<U>(*this);
|
||||
}
|
||||
|
|
|
@ -35,28 +35,47 @@ requires(N >= 2 && N <= 4) class VectorN final {
|
|||
|
||||
public:
|
||||
[[nodiscard]] constexpr VectorN() = default;
|
||||
[[nodiscard]] constexpr VectorN(T x, T y) requires(N == 2)
|
||||
[[nodiscard]] constexpr VectorN(T x, T y)
|
||||
requires(N == 2)
|
||||
: m_data { x, y }
|
||||
{
|
||||
}
|
||||
[[nodiscard]] constexpr VectorN(T x, T y, T z) requires(N == 3)
|
||||
[[nodiscard]] constexpr VectorN(T x, T y, T z)
|
||||
requires(N == 3)
|
||||
: m_data { x, y, z }
|
||||
{
|
||||
}
|
||||
[[nodiscard]] constexpr VectorN(T x, T y, T z, T w) requires(N == 4)
|
||||
[[nodiscard]] constexpr VectorN(T x, T y, T z, T w)
|
||||
requires(N == 4)
|
||||
: m_data { x, y, z, w }
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T x() const { return m_data[0]; }
|
||||
[[nodiscard]] constexpr T y() const { return m_data[1]; }
|
||||
[[nodiscard]] constexpr T z() const requires(N >= 3) { return m_data[2]; }
|
||||
[[nodiscard]] constexpr T w() const requires(N >= 4) { return m_data[3]; }
|
||||
[[nodiscard]] constexpr T z() const
|
||||
requires(N >= 3)
|
||||
{
|
||||
return m_data[2];
|
||||
}
|
||||
[[nodiscard]] constexpr T w() const
|
||||
requires(N >= 4)
|
||||
{
|
||||
return m_data[3];
|
||||
}
|
||||
|
||||
constexpr void set_x(T value) { m_data[0] = value; }
|
||||
constexpr void set_y(T value) { m_data[1] = value; }
|
||||
constexpr void set_z(T value) requires(N >= 3) { m_data[2] = value; }
|
||||
constexpr void set_w(T value) requires(N >= 4) { m_data[3] = value; }
|
||||
constexpr void set_z(T value)
|
||||
requires(N >= 3)
|
||||
{
|
||||
m_data[2] = value;
|
||||
}
|
||||
constexpr void set_w(T value)
|
||||
requires(N >= 4)
|
||||
{
|
||||
m_data[3] = value;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr T const& operator[](size_t index) const
|
||||
{
|
||||
|
@ -86,7 +105,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
constexpr VectorN& operator*=(const T& t)
|
||||
constexpr VectorN& operator*=(T const& t)
|
||||
{
|
||||
UNROLL_LOOP
|
||||
for (auto i = 0u; i < N; ++i)
|
||||
|
@ -168,7 +187,8 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr VectorN cross(VectorN const& other) const requires(N == 3)
|
||||
[[nodiscard]] constexpr VectorN cross(VectorN const& other) const
|
||||
requires(N == 3)
|
||||
{
|
||||
return VectorN(
|
||||
y() * other.z() - z() * other.y(),
|
||||
|
@ -211,12 +231,14 @@ public:
|
|||
return AK::sqrt<O>(dot(*this));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3)
|
||||
[[nodiscard]] constexpr VectorN<2, T> xy() const
|
||||
requires(N >= 3)
|
||||
{
|
||||
return VectorN<2, T>(x(), y());
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr VectorN<3, T> xyz() const requires(N >= 4)
|
||||
[[nodiscard]] constexpr VectorN<3, T> xyz() const
|
||||
requires(N >= 4)
|
||||
{
|
||||
return VectorN<3, T>(x(), y(), z());
|
||||
}
|
||||
|
|
|
@ -192,19 +192,19 @@ private:
|
|||
};
|
||||
|
||||
template<typename Func, typename... Args>
|
||||
concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args)
|
||||
{
|
||||
{
|
||||
func(args...)
|
||||
}
|
||||
-> SameAs<ThrowCompletionOr<void>>;
|
||||
};
|
||||
concept ThrowCompletionOrVoidFunction = requires(Func func, Args... args) {
|
||||
{
|
||||
func(args...)
|
||||
}
|
||||
-> SameAs<ThrowCompletionOr<void>>;
|
||||
};
|
||||
|
||||
template<typename... Args>
|
||||
class ThrowCompletionOrVoidCallback : public Function<ThrowCompletionOr<void>(Args...)> {
|
||||
public:
|
||||
template<typename CallableType>
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable) requires(VoidFunction<CallableType, Args...>)
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable)
|
||||
requires(VoidFunction<CallableType, Args...>)
|
||||
: Function<ThrowCompletionOr<void>(Args...)>([callable = forward<CallableType>(callable)](Args... args) {
|
||||
callable(args...);
|
||||
return ThrowCompletionOr<void> {};
|
||||
|
@ -213,7 +213,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename CallableType>
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable) requires(ThrowCompletionOrVoidFunction<CallableType, Args...>)
|
||||
ThrowCompletionOrVoidCallback(CallableType&& callable)
|
||||
requires(ThrowCompletionOrVoidFunction<CallableType, Args...>)
|
||||
: Function<ThrowCompletionOr<void>(Args...)>(forward<CallableType>(callable))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ public:
|
|||
LeaveVariableEnvironment,
|
||||
};
|
||||
template<typename OpType>
|
||||
void perform_needed_unwinds(bool is_break_node = false) requires(OpType::IsTerminator)
|
||||
void perform_needed_unwinds(bool is_break_node = false)
|
||||
requires(OpType::IsTerminator)
|
||||
{
|
||||
Optional<BlockBoundaryType> boundary_to_stop_at;
|
||||
if constexpr (IsSame<OpType, Bytecode::Op::Return> || IsSame<OpType, Bytecode::Op::Yield>)
|
||||
|
|
|
@ -104,26 +104,28 @@ private:
|
|||
O(RightShift, right_shift) \
|
||||
O(UnsignedRightShift, unsigned_right_shift)
|
||||
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { } \
|
||||
void replace_references_impl(Register from, Register to) \
|
||||
{ \
|
||||
if (m_lhs_reg == from) \
|
||||
m_lhs_reg = to; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
explicit OpTitleCase(Register lhs_reg) \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
, m_lhs_reg(lhs_reg) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
|
||||
{ \
|
||||
} \
|
||||
void replace_references_impl(Register from, Register to) \
|
||||
{ \
|
||||
if (m_lhs_reg == from) \
|
||||
m_lhs_reg = to; \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
Register m_lhs_reg; \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
||||
|
@ -136,18 +138,22 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
|
|||
O(UnaryMinus, unary_minus) \
|
||||
O(Typeof, typeof_)
|
||||
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) { } \
|
||||
void replace_references_impl(Register, Register) { } \
|
||||
#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
|
||||
class OpTitleCase final : public Instruction { \
|
||||
public: \
|
||||
OpTitleCase() \
|
||||
: Instruction(Type::OpTitleCase) \
|
||||
{ \
|
||||
} \
|
||||
\
|
||||
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; \
|
||||
String to_string_impl(Bytecode::Executable const&) const; \
|
||||
void replace_references_impl(BasicBlock const&, BasicBlock const&) \
|
||||
{ \
|
||||
} \
|
||||
void replace_references_impl(Register, Register) \
|
||||
{ \
|
||||
} \
|
||||
};
|
||||
|
||||
JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
|
||||
|
|
|
@ -29,19 +29,22 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(U& ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(U& ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(&static_cast<T&>(ptr))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(U const& ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(U const& ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(&const_cast<T&>(static_cast<T const&>(ptr)))
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr(NonnullGCPtr<U> ptr) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr(NonnullGCPtr<U> ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
}
|
||||
|
@ -59,14 +62,16 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr& operator=(U const& other) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr& operator=(U const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = &const_cast<T&>(static_cast<T const&>(other));
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
NonnullGCPtr& operator=(NonnullGCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
NonnullGCPtr& operator=(NonnullGCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -117,7 +122,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr(NonnullGCPtr<U> ptr) requires(IsConvertible<U*, T*>)
|
||||
GCPtr(NonnullGCPtr<U> ptr)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
: m_ptr(ptr)
|
||||
{
|
||||
}
|
||||
|
@ -131,7 +137,8 @@ public:
|
|||
GCPtr& operator=(GCPtr const&) = default;
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(GCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(GCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -144,7 +151,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(NonnullGCPtr<U> const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(NonnullGCPtr<U> const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other.ptr()));
|
||||
return *this;
|
||||
|
@ -157,7 +165,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(U const& other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(U const& other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = &const_cast<T&>(static_cast<T const&>(other));
|
||||
return *this;
|
||||
|
@ -170,7 +179,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
GCPtr& operator=(U const* other) requires(IsConvertible<U*, T*>)
|
||||
GCPtr& operator=(U const* other)
|
||||
requires(IsConvertible<U*, T*>)
|
||||
{
|
||||
m_ptr = const_cast<T*>(static_cast<T const*>(other));
|
||||
return *this;
|
||||
|
|
|
@ -36,7 +36,8 @@ struct ExecutingASTNodeChain {
|
|||
class Interpreter : public Weakable<Interpreter> {
|
||||
public:
|
||||
template<typename GlobalObjectType, typename... Args>
|
||||
static NonnullOwnPtr<Interpreter> create(VM& vm, Args&&... args) requires(IsBaseOf<GlobalObject, GlobalObjectType>)
|
||||
static NonnullOwnPtr<Interpreter> create(VM& vm, Args&&... args)
|
||||
requires(IsBaseOf<GlobalObject, GlobalObjectType>)
|
||||
{
|
||||
DeferGC defer_gc(vm.heap());
|
||||
auto interpreter = adopt_own(*new Interpreter(vm));
|
||||
|
|
|
@ -363,7 +363,8 @@ ErrorOr<void> print_async_generator(JS::PrintContext& print_context, JS::AsyncGe
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
ErrorOr<void> print_number(JS::PrintContext& print_context, T number) requires IsArithmetic<T>
|
||||
ErrorOr<void> print_number(JS::PrintContext& print_context, T number)
|
||||
requires IsArithmetic<T>
|
||||
{
|
||||
TRY(js_out(print_context, "\033[35;1m"));
|
||||
TRY(js_out(print_context, "{}", number));
|
||||
|
|
|
@ -168,7 +168,8 @@ Vector<T> merge_lists(Vector<T> const& a, Vector<T> const& b)
|
|||
|
||||
// x modulo y, https://tc39.es/ecma262/#eqn-modulo
|
||||
template<typename T, typename U>
|
||||
auto modulo(T x, U y) requires(IsArithmetic<T>, IsArithmetic<U>)
|
||||
auto modulo(T x, U y)
|
||||
requires(IsArithmetic<T>, IsArithmetic<U>)
|
||||
{
|
||||
// The notation “x modulo y” (y must be finite and non-zero) computes a value k of the same sign as y (or zero) such that abs(k) < abs(y) and x - k = q × y for some integer q.
|
||||
VERIFY(y != 0);
|
||||
|
|
|
@ -148,7 +148,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U = JS::Completion>
|
||||
explicit(!IsConvertible<U&&, JS::Completion>) Optional(U&& value) requires(!IsSame<RemoveCVReference<U>, Optional<JS::Completion>> && IsConstructible<JS::Completion, U&&>)
|
||||
explicit(!IsConvertible<U&&, JS::Completion>) Optional(U&& value)
|
||||
requires(!IsSame<RemoveCVReference<U>, Optional<JS::Completion>> && IsConstructible<JS::Completion, U &&>)
|
||||
: m_value(forward<U>(value))
|
||||
{
|
||||
}
|
||||
|
@ -237,7 +238,8 @@ namespace JS {
|
|||
template<typename ValueType>
|
||||
class [[nodiscard]] ThrowCompletionOr {
|
||||
public:
|
||||
ThrowCompletionOr() requires(IsSame<ValueType, Empty>)
|
||||
ThrowCompletionOr()
|
||||
requires(IsSame<ValueType, Empty>)
|
||||
: m_value(Empty {})
|
||||
{
|
||||
}
|
||||
|
@ -266,7 +268,8 @@ public:
|
|||
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
|
||||
// Disabled for POD types to avoid weird conversion shenanigans.
|
||||
template<typename WrappedValueType>
|
||||
ThrowCompletionOr(WrappedValueType value) requires(!IsPOD<ValueType>)
|
||||
ThrowCompletionOr(WrappedValueType value)
|
||||
requires(!IsPOD<ValueType>)
|
||||
: m_value(move(value))
|
||||
{
|
||||
}
|
||||
|
@ -274,8 +277,16 @@ public:
|
|||
[[nodiscard]] bool is_throw_completion() const { return m_throw_completion.has_value(); }
|
||||
Completion const& throw_completion() const { return *m_throw_completion; }
|
||||
|
||||
[[nodiscard]] bool has_value() const requires(!IsSame<ValueType, Empty>) { return m_value.has_value(); }
|
||||
[[nodiscard]] ValueType const& value() const requires(!IsSame<ValueType, Empty>) { return *m_value; }
|
||||
[[nodiscard]] bool has_value() const
|
||||
requires(!IsSame<ValueType, Empty>)
|
||||
{
|
||||
return m_value.has_value();
|
||||
}
|
||||
[[nodiscard]] ValueType const& value() const
|
||||
requires(!IsSame<ValueType, Empty>)
|
||||
{
|
||||
return *m_value;
|
||||
}
|
||||
|
||||
// These are for compatibility with the TRY() macro in AK.
|
||||
[[nodiscard]] bool is_error() const { return m_throw_completion.has_value(); }
|
||||
|
|
|
@ -65,13 +65,15 @@ public:
|
|||
|
||||
private:
|
||||
friend class Map;
|
||||
IteratorImpl(Map const& map) requires(IsConst)
|
||||
IteratorImpl(Map const& map)
|
||||
requires(IsConst)
|
||||
: m_map(map)
|
||||
{
|
||||
ensure_index();
|
||||
}
|
||||
|
||||
IteratorImpl(Map& map) requires(!IsConst)
|
||||
IteratorImpl(Map& map)
|
||||
requires(!IsConst)
|
||||
: m_map(map)
|
||||
{
|
||||
ensure_index();
|
||||
|
|
|
@ -17,7 +17,10 @@ namespace JS {
|
|||
#define JS_PROTOTYPE_OBJECT(prototype_class, object_class, display_name_) \
|
||||
using Prototype = PrototypeObject<prototype_class, object_class>; \
|
||||
JS_OBJECT(prototype_class, Prototype) \
|
||||
static constexpr StringView display_name() { return #display_name_##sv; }
|
||||
static constexpr StringView display_name() \
|
||||
{ \
|
||||
return #display_name_##sv; \
|
||||
}
|
||||
|
||||
template<typename PrototypeType, typename ObjectType>
|
||||
class PrototypeObject : public Object {
|
||||
|
|
|
@ -601,7 +601,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U = JS::Value>
|
||||
explicit(!IsConvertible<U&&, JS::Value>) Optional(U&& value) requires(!IsSame<RemoveCVReference<U>, Optional<JS::Value>> && IsConstructible<JS::Value, U&&>)
|
||||
explicit(!IsConvertible<U&&, JS::Value>) Optional(U&& value)
|
||||
requires(!IsSame<RemoveCVReference<U>, Optional<JS::Value>> && IsConstructible<JS::Value, U &&>)
|
||||
: m_value(forward<U>(value))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -50,13 +50,15 @@ public:
|
|||
}
|
||||
|
||||
template<typename CallableType>
|
||||
SafeFunction(CallableType&& callable) requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...> && !IsSame<RemoveCVReference<CallableType>, SafeFunction>))
|
||||
SafeFunction(CallableType&& callable)
|
||||
requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...> && !IsSame<RemoveCVReference<CallableType>, SafeFunction>))
|
||||
{
|
||||
init_with_callable(forward<CallableType>(callable), CallableKind::FunctionObject);
|
||||
}
|
||||
|
||||
template<typename FunctionType>
|
||||
SafeFunction(FunctionType f) requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...> && !IsSame<RemoveCVReference<FunctionType>, SafeFunction>))
|
||||
SafeFunction(FunctionType f)
|
||||
requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...> && !IsSame<RemoveCVReference<FunctionType>, SafeFunction>))
|
||||
{
|
||||
init_with_callable(move(f), CallableKind::FunctionPointer);
|
||||
}
|
||||
|
@ -82,7 +84,8 @@ public:
|
|||
explicit operator bool() const { return !!callable_wrapper(); }
|
||||
|
||||
template<typename CallableType>
|
||||
SafeFunction& operator=(CallableType&& callable) requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...>))
|
||||
SafeFunction& operator=(CallableType&& callable)
|
||||
requires((AK::IsFunctionObject<CallableType> && IsCallableWithArguments<CallableType, In...>))
|
||||
{
|
||||
clear();
|
||||
init_with_callable(forward<CallableType>(callable));
|
||||
|
@ -90,7 +93,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename FunctionType>
|
||||
SafeFunction& operator=(FunctionType f) requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...>))
|
||||
SafeFunction& operator=(FunctionType f)
|
||||
requires((AK::IsFunctionPointer<FunctionType> && IsCallableWithArguments<RemovePointer<FunctionType>, In...>))
|
||||
{
|
||||
clear();
|
||||
if (f)
|
||||
|
|
|
@ -285,31 +285,31 @@
|
|||
V("⇒", arrowdblright, 222) \
|
||||
V("⇑", arrowdblup, 221) \
|
||||
V("↓", arrowdown, 175) \
|
||||
V("", arrowhorizex, 190) \
|
||||
V("", arrowhorizex, 190) \
|
||||
V("←", arrowleft, 172) \
|
||||
V("→", arrowright, 174) \
|
||||
V("↑", arrowup, 173) \
|
||||
V("", arrowvertex, 189) \
|
||||
V("", arrowvertex, 189) \
|
||||
V("∗", asteriskmath, 42) \
|
||||
V("|", bar, 124) \
|
||||
V("β", beta, 98) \
|
||||
V("{", braceleft, 123) \
|
||||
V("}", braceright, 125) \
|
||||
V("", bracelefttp, 236) \
|
||||
V("", braceleftmid, 237) \
|
||||
V("", braceleftbt, 238) \
|
||||
V("", bracerighttp, 252) \
|
||||
V("", bracerightmid, 253) \
|
||||
V("", bracerightbt, 254) \
|
||||
V("", braceex, 239) \
|
||||
V("", bracelefttp, 236) \
|
||||
V("", braceleftmid, 237) \
|
||||
V("", braceleftbt, 238) \
|
||||
V("", bracerighttp, 252) \
|
||||
V("", bracerightmid, 253) \
|
||||
V("", bracerightbt, 254) \
|
||||
V("", braceex, 239) \
|
||||
V("[", bracketleft, 91) \
|
||||
V("]", bracketright, 93) \
|
||||
V("", bracketlefttp, 233) \
|
||||
V("", bracketleftex, 234) \
|
||||
V("", bracketleftbt, 235) \
|
||||
V("", bracketrighttp, 249) \
|
||||
V("", bracketrightex, 250) \
|
||||
V("", bracketrightbt, 251) \
|
||||
V("", bracketlefttp, 233) \
|
||||
V("", bracketleftex, 234) \
|
||||
V("", bracketleftbt, 235) \
|
||||
V("", bracketrighttp, 249) \
|
||||
V("", bracketrightex, 250) \
|
||||
V("", bracketrightbt, 251) \
|
||||
V("•", bullet, 183) \
|
||||
V("↵", carriagereturn, 191) \
|
||||
V("χ", chi, 99) \
|
||||
|
@ -319,7 +319,7 @@
|
|||
V(":", colon, 58) \
|
||||
V(",", comma, 44) \
|
||||
V("≅", congruent, 64) \
|
||||
V("", copyrightsans, 227) \
|
||||
V("", copyrightsans, 227) \
|
||||
V("©", copyrightserif, 211) \
|
||||
V("°", degree, 176) \
|
||||
V("δ", delta, 100) \
|
||||
|
@ -348,7 +348,7 @@
|
|||
V("∞", infinity, 165) \
|
||||
V("`", integral, 242) \
|
||||
V("∫", integraltp, 243) \
|
||||
V("", integralex, 244) \
|
||||
V("", integralex, 244) \
|
||||
V("⌡", integralbt, 245) \
|
||||
V("∩", intersection, 199) \
|
||||
V("ι", iota, 105) \
|
||||
|
@ -376,12 +376,12 @@
|
|||
V("1", one, 49) \
|
||||
V("(", parenleft, 40) \
|
||||
V(")", parenright, 41) \
|
||||
V("", parenlefttp, 230) \
|
||||
V("", parenleftex, 231) \
|
||||
V("", parenleftbt, 232) \
|
||||
V("", parenrighttp, 246) \
|
||||
V("", parenrightex, 247) \
|
||||
V("", parenrightbt, 248) \
|
||||
V("", parenlefttp, 230) \
|
||||
V("", parenleftex, 231) \
|
||||
V("", parenleftbt, 232) \
|
||||
V("", parenrighttp, 246) \
|
||||
V("", parenrightex, 247) \
|
||||
V("", parenrightbt, 248) \
|
||||
V("∂", partialdiff, 182) \
|
||||
V("%", percent, 37) \
|
||||
V(".", period, 46) \
|
||||
|
@ -401,7 +401,7 @@
|
|||
V("?", radicalex, 96) /* FIXME: What is this character, ? */ \
|
||||
V("⊆", reflexsubset, 205) \
|
||||
V("⊇", reflexsuperset, 202) \
|
||||
V("", registersans, 226) \
|
||||
V("", registersans, 226) \
|
||||
V("®", registerserif, 210) \
|
||||
V("ρ", rho, 114) \
|
||||
V("″", second, 178) \
|
||||
|
@ -421,7 +421,7 @@
|
|||
V("θ", theta, 113) \
|
||||
V("ϑ", theta1, 74) \
|
||||
V("3", three, 51) \
|
||||
V("", trademarksans, 228) \
|
||||
V("", trademarksans, 228) \
|
||||
V("™", trademarkserif, 212) \
|
||||
V("2", two, 50) \
|
||||
V("_", underscore, 95) \
|
||||
|
|
|
@ -43,7 +43,8 @@ public:
|
|||
ALWAYS_INLINE void set_generation_index(u32 generation_index) { m_generation_index = generation_index; }
|
||||
|
||||
template<IsObject T>
|
||||
bool is() const requires(!IsSame<T, Object>)
|
||||
bool is() const
|
||||
requires(!IsSame<T, Object>)
|
||||
{
|
||||
#define ENUMERATE_TYPE(class_name, snake_name) \
|
||||
if constexpr (IsSame<class_name, T>) { \
|
||||
|
@ -60,7 +61,8 @@ public:
|
|||
#ifdef PDF_DEBUG
|
||||
SourceLocation loc = SourceLocation::current()
|
||||
#endif
|
||||
) const requires(!IsSame<T, Object>)
|
||||
) const
|
||||
requires(!IsSame<T, Object>)
|
||||
{
|
||||
#ifdef PDF_DEBUG
|
||||
if (!is<T>()) {
|
||||
|
@ -76,8 +78,11 @@ public:
|
|||
virtual String to_string(int indent) const = 0;
|
||||
|
||||
protected:
|
||||
#define ENUMERATE_TYPE(_, name) \
|
||||
virtual bool is_##name() const { return false; }
|
||||
#define ENUMERATE_TYPE(_, name) \
|
||||
virtual bool is_##name() const \
|
||||
{ \
|
||||
return false; \
|
||||
}
|
||||
ENUMERATE_OBJECT_TYPES(ENUMERATE_TYPE)
|
||||
#undef ENUMERATE_TYPE
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
namespace PDF {
|
||||
|
||||
template<typename T, typename... Args>
|
||||
static NonnullRefPtr<T> make_object(Args... args) requires(IsBaseOf<Object, T>)
|
||||
static NonnullRefPtr<T> make_object(Args... args)
|
||||
requires(IsBaseOf<Object, T>)
|
||||
{
|
||||
return adopt_ref(*new T(forward<Args>(args)...));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
template<typename T = char>
|
||||
T read()
|
||||
{
|
||||
T value = reinterpret_cast<const T*>(m_bytes.offset(m_offset))[0];
|
||||
T value = reinterpret_cast<T const*>(m_bytes.offset(m_offset))[0];
|
||||
move_by(sizeof(T));
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ public:
|
|||
}
|
||||
|
||||
template<IsObject T>
|
||||
Value(NonnullRefPtr<T> const& refptr) requires(!IsSame<Object, T>)
|
||||
Value(NonnullRefPtr<T> const& refptr)
|
||||
requires(!IsSame<Object, T>)
|
||||
: Variant(nullptr)
|
||||
{
|
||||
set<NonnullRefPtr<Object>>(*refptr);
|
||||
|
|
|
@ -340,7 +340,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
static void transform_bytecode_repetition_min_max(ByteCode& bytecode_to_repeat, T minimum, Optional<T> maximum, size_t min_repetition_mark_id, size_t max_repetition_mark_id, bool greedy = true) requires(IsIntegral<T>)
|
||||
static void transform_bytecode_repetition_min_max(ByteCode& bytecode_to_repeat, T minimum, Optional<T> maximum, size_t min_repetition_mark_id, size_t max_repetition_mark_id, bool greedy = true)
|
||||
requires(IsIntegral<T>)
|
||||
{
|
||||
if (!maximum.has_value()) {
|
||||
if (minimum == 0)
|
||||
|
@ -410,7 +411,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
void insert_bytecode_repetition_n(ByteCode& bytecode_to_repeat, T n, size_t repetition_mark_id) requires(IsIntegral<T>)
|
||||
void insert_bytecode_repetition_n(ByteCode& bytecode_to_repeat, T n, size_t repetition_mark_id)
|
||||
requires(IsIntegral<T>)
|
||||
{
|
||||
// LABEL _LOOP
|
||||
// REGEXP
|
||||
|
|
|
@ -33,7 +33,8 @@ public:
|
|||
ALWAYS_INLINE T* scanline(int y) { return m_buffer->buffer_pointer(0, y, 0); }
|
||||
ALWAYS_INLINE T const* scanline(int y) const { return m_buffer->buffer_pointer(0, y, 0); }
|
||||
|
||||
void blit_flipped_to_bitmap(Gfx::Bitmap& bitmap, Gfx::IntRect const& target) const requires IsSame<T, u32>
|
||||
void blit_flipped_to_bitmap(Gfx::Bitmap& bitmap, Gfx::IntRect const& target) const
|
||||
requires IsSame<T, u32>
|
||||
{
|
||||
VERIFY(bitmap.format() == Gfx::BitmapFormat::BGRA8888 || bitmap.format() == Gfx::BitmapFormat::BGRx8888);
|
||||
int source_y = 0;
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
namespace SoftGPU {
|
||||
|
||||
template<typename T>
|
||||
static constexpr T reverse_component_bytes_if_needed(T value, GPU::ImageDataLayout const& image_data_layout) requires(sizeof(T) == 2 || sizeof(T) == 4)
|
||||
static constexpr T reverse_component_bytes_if_needed(T value, GPU::ImageDataLayout const& image_data_layout)
|
||||
requires(sizeof(T) == 2 || sizeof(T) == 4)
|
||||
{
|
||||
if (image_data_layout.packing.component_bytes_order == GPU::ComponentBytesOrder::Normal)
|
||||
return value;
|
||||
|
|
|
@ -223,18 +223,21 @@ struct Options {
|
|||
}
|
||||
Vector<CipherSuite> usable_cipher_suites = default_usable_cipher_suites();
|
||||
|
||||
#define OPTION_WITH_DEFAULTS(typ, name, ...) \
|
||||
static typ default_##name() { return typ { __VA_ARGS__ }; } \
|
||||
typ name = default_##name(); \
|
||||
Options& set_##name(typ new_value)& \
|
||||
{ \
|
||||
name = move(new_value); \
|
||||
return *this; \
|
||||
} \
|
||||
Options&& set_##name(typ new_value)&& \
|
||||
{ \
|
||||
name = move(new_value); \
|
||||
return move(*this); \
|
||||
#define OPTION_WITH_DEFAULTS(typ, name, ...) \
|
||||
static typ default_##name() \
|
||||
{ \
|
||||
return typ { __VA_ARGS__ }; \
|
||||
} \
|
||||
typ name = default_##name(); \
|
||||
Options& set_##name(typ new_value)& \
|
||||
{ \
|
||||
name = move(new_value); \
|
||||
return *this; \
|
||||
} \
|
||||
Options&& set_##name(typ new_value)&& \
|
||||
{ \
|
||||
name = move(new_value); \
|
||||
return move(*this); \
|
||||
}
|
||||
|
||||
OPTION_WITH_DEFAULTS(Version, version, Version::V12)
|
||||
|
|
|
@ -42,34 +42,43 @@ void add_test_case_to_suite(NonnullRefPtr<TestCase> const& test_case);
|
|||
void set_suite_setup_function(Function<void()> setup);
|
||||
}
|
||||
|
||||
#define TEST_SETUP \
|
||||
static void __setup(); \
|
||||
struct __setup_type { \
|
||||
__setup_type() { Test::set_suite_setup_function(__setup); } \
|
||||
}; \
|
||||
static struct __setup_type __setup_type; \
|
||||
#define TEST_SETUP \
|
||||
static void __setup(); \
|
||||
struct __setup_type { \
|
||||
__setup_type() \
|
||||
{ \
|
||||
Test::set_suite_setup_function(__setup); \
|
||||
} \
|
||||
}; \
|
||||
static struct __setup_type __setup_type; \
|
||||
static void __setup()
|
||||
|
||||
#define __TESTCASE_FUNC(x) __test_##x
|
||||
#define __TESTCASE_TYPE(x) __TestCase_##x
|
||||
|
||||
#define TEST_CASE(x) \
|
||||
static void __TESTCASE_FUNC(x)(); \
|
||||
struct __TESTCASE_TYPE(x) { \
|
||||
__TESTCASE_TYPE(x) \
|
||||
() { add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __TESTCASE_FUNC(x), false))); } \
|
||||
}; \
|
||||
static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \
|
||||
#define TEST_CASE(x) \
|
||||
static void __TESTCASE_FUNC(x)(); \
|
||||
struct __TESTCASE_TYPE(x) { \
|
||||
__TESTCASE_TYPE(x) \
|
||||
() \
|
||||
{ \
|
||||
add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __TESTCASE_FUNC(x), false))); \
|
||||
} \
|
||||
}; \
|
||||
static struct __TESTCASE_TYPE(x) __TESTCASE_TYPE(x); \
|
||||
static void __TESTCASE_FUNC(x)()
|
||||
|
||||
#define __BENCHMARK_FUNC(x) __benchmark_##x
|
||||
#define __BENCHMARK_TYPE(x) __BenchmarkCase_##x
|
||||
|
||||
#define BENCHMARK_CASE(x) \
|
||||
static void __BENCHMARK_FUNC(x)(); \
|
||||
struct __BENCHMARK_TYPE(x) { \
|
||||
__BENCHMARK_TYPE(x) \
|
||||
() { add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __BENCHMARK_FUNC(x), true))); } \
|
||||
}; \
|
||||
static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \
|
||||
#define BENCHMARK_CASE(x) \
|
||||
static void __BENCHMARK_FUNC(x)(); \
|
||||
struct __BENCHMARK_TYPE(x) { \
|
||||
__BENCHMARK_TYPE(x) \
|
||||
() \
|
||||
{ \
|
||||
add_test_case_to_suite(adopt_ref(*new ::Test::TestCase(#x, __BENCHMARK_FUNC(x), true))); \
|
||||
} \
|
||||
}; \
|
||||
static struct __BENCHMARK_TYPE(x) __BENCHMARK_TYPE(x); \
|
||||
static void __BENCHMARK_FUNC(x)()
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
virtual ~EscapeSequenceExecutor() = default;
|
||||
|
||||
using Parameters = Span<unsigned const>;
|
||||
using Intermediates = Span<const u8>;
|
||||
using OscParameter = Span<const u8>;
|
||||
using OscParameters = Span<const OscParameter>;
|
||||
using Intermediates = Span<u8 const>;
|
||||
using OscParameter = Span<u8 const>;
|
||||
using OscParameters = Span<OscParameter const>;
|
||||
|
||||
virtual void emit_code_point(u32) = 0;
|
||||
virtual void execute_control_code(u8) = 0;
|
||||
|
|
|
@ -16,12 +16,18 @@
|
|||
|
||||
namespace Operators {
|
||||
|
||||
#define DEFINE_BINARY_OPERATOR(Name, operation) \
|
||||
struct Name { \
|
||||
template<typename Lhs, typename Rhs> \
|
||||
auto operator()(Lhs lhs, Rhs rhs) const { return lhs operation rhs; } \
|
||||
\
|
||||
static StringView name() { return #operation##sv; } \
|
||||
#define DEFINE_BINARY_OPERATOR(Name, operation) \
|
||||
struct Name { \
|
||||
template<typename Lhs, typename Rhs> \
|
||||
auto operator()(Lhs lhs, Rhs rhs) const \
|
||||
{ \
|
||||
return lhs operation rhs; \
|
||||
} \
|
||||
\
|
||||
static StringView name() \
|
||||
{ \
|
||||
return #operation##sv; \
|
||||
} \
|
||||
}
|
||||
|
||||
DEFINE_BINARY_OPERATOR(Equals, ==);
|
||||
|
|
|
@ -82,7 +82,8 @@ struct ParseUntilAnyOfResult {
|
|||
Vector<T> values;
|
||||
};
|
||||
template<typename T, u8... terminators, typename... Args>
|
||||
static ParseResult<ParseUntilAnyOfResult<T>> parse_until_any_of(InputStream& stream, Args&... args) requires(requires(InputStream& stream, Args... args) { T::parse(stream, args...); })
|
||||
static ParseResult<ParseUntilAnyOfResult<T>> parse_until_any_of(InputStream& stream, Args&... args)
|
||||
requires(requires(InputStream& stream, Args... args) { T::parse(stream, args...); })
|
||||
{
|
||||
ScopeLogger<WASM_BINPARSER_DEBUG> logger;
|
||||
ReconsumableStream new_stream { stream };
|
||||
|
|
|
@ -35,7 +35,8 @@ struct SimpleException {
|
|||
template<typename ValueType>
|
||||
class [[nodiscard]] ExceptionOr {
|
||||
public:
|
||||
ExceptionOr() requires(IsSame<ValueType, Empty>)
|
||||
ExceptionOr()
|
||||
requires(IsSame<ValueType, Empty>)
|
||||
: m_result(Empty {})
|
||||
{
|
||||
}
|
||||
|
@ -54,7 +55,8 @@ public:
|
|||
// Most commonly: Value from Object* or similar, so we can omit the curly braces from "return { TRY(...) };".
|
||||
// Disabled for POD types to avoid weird conversion shenanigans.
|
||||
template<typename WrappedValueType>
|
||||
ExceptionOr(WrappedValueType result) requires(!IsPOD<ValueType>)
|
||||
ExceptionOr(WrappedValueType result)
|
||||
requires(!IsPOD<ValueType>)
|
||||
: m_result(move(result))
|
||||
{
|
||||
}
|
||||
|
@ -87,7 +89,8 @@ public:
|
|||
ExceptionOr(ExceptionOr const& other) = default;
|
||||
~ExceptionOr() = default;
|
||||
|
||||
ValueType& value() requires(!IsSame<ValueType, Empty>)
|
||||
ValueType& value()
|
||||
requires(!IsSame<ValueType, Empty>)
|
||||
{
|
||||
return m_result.value();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue