Преглед на файлове

core: memory: Add templated GetPointer methods.

bunnei преди 5 години
родител
ревизия
24e1e17a8a
променени са 1 файла, в които са добавени 10 реда и са изтрити 0 реда
  1. 10 0
      src/core/memory.h

+ 10 - 0
src/core/memory.h

@@ -116,6 +116,11 @@ public:
      */
     u8* GetPointer(VAddr vaddr);
 
+    template <typename T>
+    T* GetPointer(VAddr vaddr) {
+        return reinterpret_cast<T*>(GetPointer(vaddr));
+    }
+
     /**
      * Gets a pointer to the given address.
      *
@@ -126,6 +131,11 @@ public:
      */
     const u8* GetPointer(VAddr vaddr) const;
 
+    template <typename T>
+    const T* GetPointer(VAddr vaddr) const {
+        return reinterpret_cast<T*>(GetPointer(vaddr));
+    }
+
     /**
      * Reads an 8-bit unsigned value from the current process' address space
      * at the given virtual address.