mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
Avoid transitive include of vm_ref.h
Add forward declarations of vm::_ref_base Remove default AT = u32 in _ptr_base and _ref_base (doesn't play well).
This commit is contained in:
parent
cfa1416d64
commit
c01f1a8968
6 changed files with 33 additions and 24 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Emu/Cell/PPUModule.h"
|
#include "Emu/Cell/PPUModule.h"
|
||||||
|
#include "Emu/Memory/vm_ref.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../CPU/CPUThread.h"
|
#include "../CPU/CPUThread.h"
|
||||||
#include "../Memory/vm_ref.h"
|
|
||||||
#include "../Memory/vm_ptr.h"
|
#include "../Memory/vm_ptr.h"
|
||||||
#include "Utilities/lockless.h"
|
#include "Utilities/lockless.h"
|
||||||
|
|
||||||
|
|
|
@ -1084,12 +1084,12 @@ namespace vm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fmt_class_string<vm::_ptr_base<const void>>::format(std::string& out, u64 arg)
|
void fmt_class_string<vm::_ptr_base<const void, u32>>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
fmt_class_string<u32>::format(out, arg);
|
fmt_class_string<u32>::format(out, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fmt_class_string<vm::_ptr_base<const char>>::format(std::string& out, u64 arg)
|
void fmt_class_string<vm::_ptr_base<const char, u32>>::format(std::string& out, u64 arg)
|
||||||
{
|
{
|
||||||
// Special case (may be allowed for some arguments)
|
// Special case (may be allowed for some arguments)
|
||||||
if (arg == 0)
|
if (arg == 0)
|
||||||
|
@ -1111,7 +1111,7 @@ void fmt_class_string<vm::_ptr_base<const char>>::format(std::string& out, u64 a
|
||||||
|
|
||||||
out += u8"“";
|
out += u8"“";
|
||||||
|
|
||||||
for (vm::_ptr_base<const volatile char> ptr = vm::cast(arg);; ptr++)
|
for (vm::_ptr_base<const volatile char, u32> ptr = vm::cast(arg);; ptr++)
|
||||||
{
|
{
|
||||||
if (!vm::check_addr(ptr.addr()))
|
if (!vm::check_addr(ptr.addr()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -268,5 +268,10 @@ namespace vm
|
||||||
}
|
}
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
}
|
|
||||||
|
|
||||||
|
template <typename T, typename AT>
|
||||||
|
class _ptr_base;
|
||||||
|
|
||||||
|
template <typename T, typename AT>
|
||||||
|
class _ref_base;
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Utilities/types.h"
|
#include "Utilities/types.h"
|
||||||
#include "vm_ref.h"
|
#include "Utilities/BEType.h"
|
||||||
|
#include "vm.h"
|
||||||
|
|
||||||
class ppu_thread;
|
class ppu_thread;
|
||||||
|
|
||||||
namespace vm
|
namespace vm
|
||||||
{
|
{
|
||||||
|
template <typename T, typename AT>
|
||||||
|
class _ref_base;
|
||||||
|
|
||||||
// SFINAE helper type for vm::_ptr_base comparison operators (enables comparison between equal types and between any type and void*)
|
// SFINAE helper type for vm::_ptr_base comparison operators (enables comparison between equal types and between any type and void*)
|
||||||
template<typename T1, typename T2, typename RT = void>
|
template<typename T1, typename T2, typename RT = void>
|
||||||
using if_comparable_t = std::enable_if_t<std::is_void<T1>::value || std::is_void<T2>::value || std::is_same<std::remove_cv_t<T1>, std::remove_cv_t<T2>>::value, RT>;
|
using if_comparable_t = std::enable_if_t<std::is_void<T1>::value || std::is_void<T2>::value || std::is_same<std::remove_cv_t<T1>, std::remove_cv_t<T2>>::value, RT>;
|
||||||
|
|
||||||
template<typename T, typename AT = u32>
|
template <typename T, typename AT>
|
||||||
class _ptr_base
|
class _ptr_base
|
||||||
{
|
{
|
||||||
AT m_addr;
|
AT m_addr;
|
||||||
|
@ -61,28 +65,28 @@ namespace vm
|
||||||
|
|
||||||
// Get vm pointer to a struct member
|
// Get vm pointer to a struct member
|
||||||
template <typename MT, typename T2, typename = if_comparable_t<T, T2>>
|
template <typename MT, typename T2, typename = if_comparable_t<T, T2>>
|
||||||
_ptr_base<MT> ptr(MT T2::*const mptr) const
|
_ptr_base<MT, u32> ptr(MT T2::*const mptr) const
|
||||||
{
|
{
|
||||||
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr));
|
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get vm pointer to a struct member with array subscription
|
// Get vm pointer to a struct member with array subscription
|
||||||
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>, typename = if_comparable_t<T, T2>>
|
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>, typename = if_comparable_t<T, T2>>
|
||||||
_ptr_base<ET> ptr(MT T2::*const mptr, u32 index) const
|
_ptr_base<ET, u32> ptr(MT T2::*const mptr, u32 index) const
|
||||||
{
|
{
|
||||||
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr) + u32{sizeof(ET)} * index);
|
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr) + u32{sizeof(ET)} * index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get vm reference to a struct member
|
// Get vm reference to a struct member
|
||||||
template <typename MT, typename T2, typename = if_comparable_t<T, T2>>
|
template <typename MT, typename T2, typename = if_comparable_t<T, T2>>
|
||||||
_ref_base<MT> ref(MT T2::*const mptr) const
|
_ref_base<MT, u32> ref(MT T2::*const mptr) const
|
||||||
{
|
{
|
||||||
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr));
|
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get vm reference to a struct member with array subscription
|
// Get vm reference to a struct member with array subscription
|
||||||
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>, typename = if_comparable_t<T, T2>>
|
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>, typename = if_comparable_t<T, T2>>
|
||||||
_ref_base<ET> ref(MT T2::*const mptr, u32 index) const
|
_ref_base<ET, u32> ref(MT T2::*const mptr, u32 index) const
|
||||||
{
|
{
|
||||||
return vm::cast(vm::cast(m_addr, HERE) + offset32(mptr) + u32{sizeof(ET)} * index);
|
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<void> to vm::ptr<char>)
|
// Perform static_cast (for example, vm::ptr<void> to vm::ptr<char>)
|
||||||
template<typename CT, typename T, typename AT, typename = decltype(static_cast<to_be_t<CT>*>(std::declval<T*>()))>
|
template<typename CT, typename T, typename AT, typename = decltype(static_cast<to_be_t<CT>*>(std::declval<T*>()))>
|
||||||
inline _ptr_base<to_be_t<CT>> static_ptr_cast(const _ptr_base<T, AT>& other)
|
inline _ptr_base<to_be_t<CT>, u32> static_ptr_cast(const _ptr_base<T, AT>& other)
|
||||||
{
|
{
|
||||||
return vm::cast(other.addr(), HERE);
|
return vm::cast(other.addr(), HERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform const_cast (for example, vm::cptr<char> to vm::ptr<char>)
|
// Perform const_cast (for example, vm::cptr<char> to vm::ptr<char>)
|
||||||
template<typename CT, typename T, typename AT, typename = decltype(const_cast<to_be_t<CT>*>(std::declval<T*>()))>
|
template<typename CT, typename T, typename AT, typename = decltype(const_cast<to_be_t<CT>*>(std::declval<T*>()))>
|
||||||
inline _ptr_base<to_be_t<CT>> const_ptr_cast(const _ptr_base<T, AT>& other)
|
inline _ptr_base<to_be_t<CT>, u32> const_ptr_cast(const _ptr_base<T, AT>& other)
|
||||||
{
|
{
|
||||||
return vm::cast(other.addr(), HERE);
|
return vm::cast(other.addr(), HERE);
|
||||||
}
|
}
|
||||||
|
@ -441,7 +445,7 @@ struct to_se<vm::_ptr_base<T, AT>, Se>
|
||||||
template<typename T, typename AT>
|
template<typename T, typename AT>
|
||||||
struct fmt_unveil<vm::_ptr_base<T, AT>, void>
|
struct fmt_unveil<vm::_ptr_base<T, AT>, void>
|
||||||
{
|
{
|
||||||
using type = vm::_ptr_base<T>; // Use only T, ignoring AT
|
using type = vm::_ptr_base<T, u32>; // Use only T, ignoring AT
|
||||||
|
|
||||||
static inline auto get(const vm::_ptr_base<T, AT>& arg)
|
static inline auto get(const vm::_ptr_base<T, AT>& arg)
|
||||||
{
|
{
|
||||||
|
@ -450,25 +454,25 @@ struct fmt_unveil<vm::_ptr_base<T, AT>, void>
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct fmt_class_string<vm::_ptr_base<const void>, void>
|
struct fmt_class_string<vm::_ptr_base<const void, u32>, void>
|
||||||
{
|
{
|
||||||
static void format(std::string& out, u64 arg);
|
static void format(std::string& out, u64 arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct fmt_class_string<vm::_ptr_base<T>, void> : fmt_class_string<vm::_ptr_base<const void>, void>
|
struct fmt_class_string<vm::_ptr_base<T, u32>, void> : fmt_class_string<vm::_ptr_base<const void, u32>, void>
|
||||||
{
|
{
|
||||||
// Classify all pointers as const void*
|
// Classify all pointers as const void*
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct fmt_class_string<vm::_ptr_base<const char>, void>
|
struct fmt_class_string<vm::_ptr_base<const char, u32>, void>
|
||||||
{
|
{
|
||||||
static void format(std::string& out, u64 arg);
|
static void format(std::string& out, u64 arg);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct fmt_class_string<vm::_ptr_base<char>, void> : fmt_class_string<vm::_ptr_base<const char>>
|
struct fmt_class_string<vm::_ptr_base<char, u32>, void> : fmt_class_string<vm::_ptr_base<const char, u32>>
|
||||||
{
|
{
|
||||||
// Classify char* as const char*
|
// Classify char* as const char*
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace vm
|
||||||
template <typename T, typename AT>
|
template <typename T, typename AT>
|
||||||
class _ptr_base;
|
class _ptr_base;
|
||||||
|
|
||||||
template<typename T, typename AT = u32>
|
template <typename T, typename AT>
|
||||||
class _ref_base
|
class _ref_base
|
||||||
{
|
{
|
||||||
AT m_addr;
|
AT m_addr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue