diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-26 17:15:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-26 17:51:00 +0200 |
commit | fe6474e69273a033a22f7961228b75a9eb967ab7 (patch) | |
tree | 299d6ef88ac0025cd8ee782e74f75647b44d0b9f | |
parent | ce2c5b375c85667425d4a4198a1f8e23836aa41e (diff) | |
download | serenity-fe6474e69273a033a22f7961228b75a9eb967ab7.zip |
Kernel: Switch to using AK::is and AK::downcast
-rw-r--r-- | Kernel/VM/AnonymousVMObject.h | 10 | ||||
-rw-r--r-- | Kernel/VM/ContiguousVMObject.h | 8 | ||||
-rw-r--r-- | Kernel/VM/InodeVMObject.h | 8 | ||||
-rw-r--r-- | Kernel/VM/PurgeableVMObject.h | 8 | ||||
-rw-r--r-- | Kernel/VM/VMObject.h | 11 |
5 files changed, 14 insertions, 31 deletions
diff --git a/Kernel/VM/AnonymousVMObject.h b/Kernel/VM/AnonymousVMObject.h index 13b7222f80..1a0f5f13ba 100644 --- a/Kernel/VM/AnonymousVMObject.h +++ b/Kernel/VM/AnonymousVMObject.h @@ -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() diff --git a/Kernel/VM/ContiguousVMObject.h b/Kernel/VM/ContiguousVMObject.h index 84f54ef4dc..0693bf67aa 100644 --- a/Kernel/VM/ContiguousVMObject.h +++ b/Kernel/VM/ContiguousVMObject.h @@ -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() diff --git a/Kernel/VM/InodeVMObject.h b/Kernel/VM/InodeVMObject.h index ca5f0af6e7..727199ff7e 100644 --- a/Kernel/VM/InodeVMObject.h +++ b/Kernel/VM/InodeVMObject.h @@ -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() diff --git a/Kernel/VM/PurgeableVMObject.h b/Kernel/VM/PurgeableVMObject.h index 0b63801284..846222deab 100644 --- a/Kernel/VM/PurgeableVMObject.h +++ b/Kernel/VM/PurgeableVMObject.h @@ -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() diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index bb0314301c..e7043f03c1 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -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); -} - } |