mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
Everywhere: Stop using NonnullRefPtrVector
This class had slightly confusing semantics and the added weirdness doesn't seem worth it just so we can say "." instead of "->" when iterating over a vector of NNRPs. This patch replaces NonnullRefPtrVector<T> with Vector<NNRP<T>>.
This commit is contained in:
parent
104be6c8ac
commit
8a48246ed1
168 changed files with 1280 additions and 1280 deletions
|
@ -152,7 +152,7 @@ public:
|
|||
class Object : public ValueNode {
|
||||
public:
|
||||
Object() = default;
|
||||
Object(DeprecatedString name, NonnullRefPtrVector<Node const> properties, NonnullRefPtrVector<Node const> sub_objects)
|
||||
Object(DeprecatedString name, Vector<NonnullRefPtr<Node const>> properties, Vector<NonnullRefPtr<Node const>> sub_objects)
|
||||
: m_properties(move(properties))
|
||||
, m_sub_objects(move(sub_objects))
|
||||
, m_name(move(name))
|
||||
|
@ -182,7 +182,7 @@ public:
|
|||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(child);
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (property.key() != "layout" && is<JsonValueNode>(property.value().ptr()))
|
||||
callback(property.key(), static_ptr_cast<JsonValueNode>(property.value()));
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
for (auto const& child : m_sub_objects) {
|
||||
// doesn't capture layout as intended, as that's behind a kv-pair
|
||||
if (is<Object>(child)) {
|
||||
TRY(callback(static_cast<Object const&>(child)));
|
||||
TRY(callback(static_cast<Object const&>(*child)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ public:
|
|||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(child);
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (property.key() == "layout") {
|
||||
VERIFY(is<Object>(property.value().ptr()));
|
||||
return static_cast<Object const&>(*property.value());
|
||||
|
@ -232,7 +232,7 @@ public:
|
|||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(child);
|
||||
auto const& property = static_cast<KeyValuePair const&>(*child);
|
||||
if (property.key() == property_name)
|
||||
return property.value();
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ public:
|
|||
builder.append('\n');
|
||||
|
||||
for (auto const& property : m_properties)
|
||||
property.format(builder, indentation + 1, false);
|
||||
property->format(builder, indentation + 1, false);
|
||||
|
||||
if (!m_properties.is_empty() && !m_sub_objects.is_empty())
|
||||
builder.append('\n');
|
||||
|
@ -259,7 +259,7 @@ public:
|
|||
// This loop is necessary as we need to know what the last child is.
|
||||
for (size_t i = 0; i < m_sub_objects.size(); ++i) {
|
||||
auto const& child = m_sub_objects[i];
|
||||
child.format(builder, indentation + 1, false);
|
||||
child->format(builder, indentation + 1, false);
|
||||
|
||||
if (is<Object>(child) && i != m_sub_objects.size() - 1)
|
||||
builder.append('\n');
|
||||
|
@ -274,9 +274,9 @@ public:
|
|||
|
||||
private:
|
||||
// Properties and comments
|
||||
NonnullRefPtrVector<Node const> m_properties;
|
||||
Vector<NonnullRefPtr<Node const>> m_properties;
|
||||
// Sub objects and comments
|
||||
NonnullRefPtrVector<Node const> m_sub_objects;
|
||||
Vector<NonnullRefPtr<Node const>> m_sub_objects;
|
||||
DeprecatedString m_name {};
|
||||
};
|
||||
|
||||
|
@ -304,18 +304,18 @@ public:
|
|||
|
||||
bool has_main_class() const { return m_main_class != nullptr; }
|
||||
|
||||
NonnullRefPtrVector<Comment const> leading_comments() const { return m_leading_comments; }
|
||||
Vector<NonnullRefPtr<Comment const>> leading_comments() const { return m_leading_comments; }
|
||||
Object const& main_class() const
|
||||
{
|
||||
VERIFY(!m_main_class.is_null());
|
||||
return *m_main_class.ptr();
|
||||
}
|
||||
NonnullRefPtrVector<Comment const> trailing_comments() const { return m_trailing_comments; }
|
||||
Vector<NonnullRefPtr<Comment const>> trailing_comments() const { return m_trailing_comments; }
|
||||
|
||||
virtual void format(StringBuilder& builder, size_t indentation, [[maybe_unused]] bool is_inline) const override
|
||||
{
|
||||
for (auto const& comment : m_leading_comments)
|
||||
comment.format(builder, indentation, false);
|
||||
comment->format(builder, indentation, false);
|
||||
|
||||
if (!m_leading_comments.is_empty())
|
||||
builder.append('\n');
|
||||
|
@ -324,13 +324,13 @@ public:
|
|||
builder.append('\n');
|
||||
|
||||
for (auto const& comment : m_trailing_comments)
|
||||
comment.format(builder, indentation, false);
|
||||
comment->format(builder, indentation, false);
|
||||
}
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Comment const> m_leading_comments;
|
||||
Vector<NonnullRefPtr<Comment const>> m_leading_comments;
|
||||
RefPtr<Object const> m_main_class;
|
||||
NonnullRefPtrVector<Comment const> m_trailing_comments;
|
||||
Vector<NonnullRefPtr<Comment const>> m_trailing_comments;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue