mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 08:50:37 +00:00
Kernel: Switch to using AK::is and AK::downcast
This commit is contained in:
parent
ce2c5b375c
commit
fe6474e692
Notes:
sideshowbarker
2024-07-19 04:36:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/fe6474e6927
5 changed files with 14 additions and 31 deletions
|
@ -26,8 +26,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/VM/VMObject.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
#include <Kernel/VM/VMObject.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -56,10 +56,8 @@ private:
|
|||
virtual bool is_anonymous() const override { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool is<AnonymousVMObject>(const VMObject& vmobject)
|
||||
{
|
||||
return vmobject.is_anonymous();
|
||||
}
|
||||
|
||||
}
|
||||
AK_BEGIN_TYPE_TRAITS(Kernel::AnonymousVMObject)
|
||||
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_anonymous(); }
|
||||
AK_END_TYPE_TRAITS()
|
||||
|
|
|
@ -51,10 +51,8 @@ private:
|
|||
virtual bool is_contiguous() const override { return true; }
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool is<ContiguousVMObject>(const VMObject& vmobject)
|
||||
{
|
||||
return vmobject.is_contiguous();
|
||||
}
|
||||
|
||||
}
|
||||
AK_BEGIN_TYPE_TRAITS(Kernel::ContiguousVMObject)
|
||||
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_contiguous(); }
|
||||
AK_END_TYPE_TRAITS()
|
||||
|
|
|
@ -66,10 +66,8 @@ protected:
|
|||
Bitmap m_dirty_pages;
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool is<InodeVMObject>(const VMObject& vmobject)
|
||||
{
|
||||
return vmobject.is_inode();
|
||||
}
|
||||
|
||||
}
|
||||
AK_BEGIN_TYPE_TRAITS(Kernel::InodeVMObject)
|
||||
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_inode(); }
|
||||
AK_END_TYPE_TRAITS()
|
||||
|
|
|
@ -64,10 +64,8 @@ private:
|
|||
bool m_volatile { false };
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool is<PurgeableVMObject>(const VMObject& vmobject)
|
||||
{
|
||||
return vmobject.is_purgeable();
|
||||
}
|
||||
|
||||
}
|
||||
AK_BEGIN_TYPE_TRAITS(Kernel::PurgeableVMObject)
|
||||
static bool is_type(const Kernel::VMObject& vmobject) { return vmobject.is_purgeable(); }
|
||||
AK_END_TYPE_TRAITS()
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <AK/InlineLinkedList.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <Kernel/Lock.h>
|
||||
|
||||
|
@ -84,14 +85,4 @@ private:
|
|||
VMObject(VMObject&&) = delete;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline bool is(const VMObject&) { return false; }
|
||||
|
||||
template<typename T>
|
||||
inline T& to(VMObject& object)
|
||||
{
|
||||
ASSERT(is<typename RemoveConst<T>::Type>(object));
|
||||
return static_cast<T&>(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue