mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
8639d8bc21
commit
d26aabff04
140 changed files with 1202 additions and 723 deletions
|
@ -19,26 +19,30 @@ public:
|
|||
LockWeakPtr() = default;
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(WeakPtr<U> const& other) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(WeakPtr<U> const& other)
|
||||
requires(IsBaseOf<T, U>)
|
||||
: m_link(other.m_link)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(WeakPtr<U>&& other) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(WeakPtr<U>&& other)
|
||||
requires(IsBaseOf<T, U>)
|
||||
: m_link(other.take_link())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(WeakPtr<U>&& other) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(WeakPtr<U>&& other)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
m_link = other.take_link();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(WeakPtr<U> const& other) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(WeakPtr<U> const& other)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
if ((void const*)this != (void const*)&other)
|
||||
m_link = other.m_link;
|
||||
|
@ -52,20 +56,23 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(const U& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(U const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
: m_link(object.template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link())
|
||||
{
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(const U* object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(U const* object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
if (object)
|
||||
m_link = object->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link();
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(LockRefPtr<U> const& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(LockRefPtr<U> const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
object.do_while_locked([&](U* obj) {
|
||||
if (obj)
|
||||
|
@ -74,7 +81,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr(NonnullLockRefPtr<U> const& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr(NonnullLockRefPtr<U> const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
object.do_while_locked([&](U* obj) {
|
||||
if (obj)
|
||||
|
@ -83,14 +91,16 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(const U& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(U const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
m_link = object.template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(const U* object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(U const* object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
if (object)
|
||||
m_link = object->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link();
|
||||
|
@ -100,7 +110,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(LockRefPtr<U> const& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(LockRefPtr<U> const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
object.do_while_locked([&](U* obj) {
|
||||
if (obj)
|
||||
|
@ -112,7 +123,8 @@ public:
|
|||
}
|
||||
|
||||
template<typename U>
|
||||
LockWeakPtr& operator=(NonnullLockRefPtr<U> const& object) requires(IsBaseOf<T, U>)
|
||||
LockWeakPtr& operator=(NonnullLockRefPtr<U> const& object)
|
||||
requires(IsBaseOf<T, U>)
|
||||
{
|
||||
object.do_while_locked([&](U* obj) {
|
||||
if (obj)
|
||||
|
@ -175,7 +187,7 @@ inline ErrorOr<LockWeakPtr<U>> LockWeakable<T>::try_make_weak_ptr() const
|
|||
// to add a ref (which should fail if the ref count is at 0) so
|
||||
// that we prevent the destructor and revoke_weak_ptrs from being
|
||||
// triggered until we're done.
|
||||
if (!static_cast<const T*>(this)->try_ref())
|
||||
if (!static_cast<T const*>(this)->try_ref())
|
||||
return LockWeakPtr<U> {};
|
||||
} else {
|
||||
// For non-RefCounted types this means a weak reference can be
|
||||
|
@ -187,14 +199,14 @@ inline ErrorOr<LockWeakPtr<U>> LockWeakable<T>::try_make_weak_ptr() const
|
|||
// There is a small chance that we create a new WeakLink and throw
|
||||
// it away because another thread beat us to it. But the window is
|
||||
// pretty small and the overhead isn't terrible.
|
||||
m_link.assign_if_null(TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<const T&>(*this))))));
|
||||
m_link.assign_if_null(TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) WeakLink(const_cast<T&>(static_cast<T const&>(*this))))));
|
||||
}
|
||||
|
||||
LockWeakPtr<U> weak_ptr(m_link);
|
||||
|
||||
if constexpr (IsBaseOf<AtomicRefCountedBase, T>) {
|
||||
// Now drop the reference we temporarily added
|
||||
if (static_cast<const T*>(this)->unref()) {
|
||||
if (static_cast<T const*>(this)->unref()) {
|
||||
// We just dropped the last reference, which should have called
|
||||
// revoke_weak_ptrs, which should have invalidated our weak_ptr
|
||||
VERIFY(!weak_ptr.strong_ref());
|
||||
|
@ -205,11 +217,11 @@ inline ErrorOr<LockWeakPtr<U>> LockWeakable<T>::try_make_weak_ptr() const
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
struct Formatter<LockWeakPtr<T>> : Formatter<const T*> {
|
||||
struct Formatter<LockWeakPtr<T>> : Formatter<T const*> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, LockWeakPtr<T> const& value)
|
||||
{
|
||||
auto ref = value.strong_ref();
|
||||
return Formatter<const T*>::format(builder, ref.ptr());
|
||||
return Formatter<T const*>::format(builder, ref.ptr());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue