diff --git a/rpcs3/Emu/Cell/Modules/cellL10n.cpp b/rpcs3/Emu/Cell/Modules/cellL10n.cpp index 4345493ac1..7d007c5a42 100644 --- a/rpcs3/Emu/Cell/Modules/cellL10n.cpp +++ b/rpcs3/Emu/Cell/Modules/cellL10n.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "Emu/Cell/PPUModule.h" +#include "Emu/Memory/vm_ref.h" #ifdef _WIN32 #include diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index d96998d7a9..8fe8f16054 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -1,7 +1,6 @@ #pragma once #include "../CPU/CPUThread.h" -#include "../Memory/vm_ref.h" #include "../Memory/vm_ptr.h" #include "Utilities/lockless.h" diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 8f2e6a6709..48faf48880 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -1084,12 +1084,12 @@ namespace vm } } -void fmt_class_string>::format(std::string& out, u64 arg) +void fmt_class_string>::format(std::string& out, u64 arg) { fmt_class_string::format(out, arg); } -void fmt_class_string>::format(std::string& out, u64 arg) +void fmt_class_string>::format(std::string& out, u64 arg) { // Special case (may be allowed for some arguments) if (arg == 0) @@ -1111,7 +1111,7 @@ void fmt_class_string>::format(std::string& out, u64 a out += u8"“"; - for (vm::_ptr_base ptr = vm::cast(arg);; ptr++) + for (vm::_ptr_base ptr = vm::cast(arg);; ptr++) { if (!vm::check_addr(ptr.addr())) { diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index 2ea85e4e5b..1aae3e619d 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -268,5 +268,10 @@ namespace vm } void close(); -} + template + class _ptr_base; + + template + class _ref_base; +} diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index b4c02b9377..01eea01347 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -1,17 +1,21 @@ #pragma once #include "Utilities/types.h" -#include "vm_ref.h" +#include "Utilities/BEType.h" +#include "vm.h" class ppu_thread; namespace vm { + template + class _ref_base; + // SFINAE helper type for vm::_ptr_base comparison operators (enables comparison between equal types and between any type and void*) template using if_comparable_t = std::enable_if_t::value || std::is_void::value || std::is_same, std::remove_cv_t>::value, RT>; - template + template class _ptr_base { AT m_addr; @@ -61,28 +65,28 @@ namespace vm // Get vm pointer to a struct member template > - _ptr_base ptr(MT T2::*const mptr) const + _ptr_base ptr(MT T2::*const mptr) const { return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr)); } // Get vm pointer to a struct member with array subscription template , typename = if_comparable_t> - _ptr_base ptr(MT T2::*const mptr, u32 index) const + _ptr_base ptr(MT T2::*const mptr, u32 index) const { return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr) + u32{sizeof(ET)} * index); } // Get vm reference to a struct member template > - _ref_base ref(MT T2::*const mptr) const + _ref_base ref(MT T2::*const mptr) const { return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr)); } // Get vm reference to a struct member with array subscription template , typename = if_comparable_t> - _ref_base ref(MT T2::*const mptr, u32 index) const + _ref_base ref(MT T2::*const mptr, u32 index) const { return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr) + u32{sizeof(ET)} * index); } @@ -296,14 +300,14 @@ namespace vm // Perform static_cast (for example, vm::ptr to vm::ptr) template*>(std::declval()))> - inline _ptr_base> static_ptr_cast(const _ptr_base& other) + inline _ptr_base, u32> static_ptr_cast(const _ptr_base& other) { return vm::cast(other.addr(), HERE); } // Perform const_cast (for example, vm::cptr to vm::ptr) template*>(std::declval()))> - inline _ptr_base> const_ptr_cast(const _ptr_base& other) + inline _ptr_base, u32> const_ptr_cast(const _ptr_base& other) { return vm::cast(other.addr(), HERE); } @@ -441,7 +445,7 @@ struct to_se, Se> template struct fmt_unveil, void> { - using type = vm::_ptr_base; // Use only T, ignoring AT + using type = vm::_ptr_base; // Use only T, ignoring AT static inline auto get(const vm::_ptr_base& arg) { @@ -449,26 +453,26 @@ struct fmt_unveil, void> } }; -template<> -struct fmt_class_string, void> +template <> +struct fmt_class_string, void> { static void format(std::string& out, u64 arg); }; -template -struct fmt_class_string, void> : fmt_class_string, void> +template +struct fmt_class_string, void> : fmt_class_string, void> { // Classify all pointers as const void* }; -template<> -struct fmt_class_string, void> +template <> +struct fmt_class_string, void> { static void format(std::string& out, u64 arg); }; -template<> -struct fmt_class_string, void> : fmt_class_string> +template <> +struct fmt_class_string, void> : fmt_class_string> { // Classify char* as const char* }; diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index c0525d1c6c..806f5aa4a1 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -6,10 +6,10 @@ namespace vm { - template + template class _ptr_base; - template + template class _ref_base { AT m_addr;