From 7eacfe19f6eb71b6550e95c78d9054e1b6110644 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 18 Jun 2015 19:39:15 +0300 Subject: [PATCH] vm::ptr fixes std::function conversion removed (since it's convertible anyway), pointer difference return type changed vm::cptr, vm::bcptr aliases added --- rpcs3/Emu/Memory/vm_ptr.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index f3afcc6277..255cfd8735 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -71,7 +71,7 @@ namespace vm _ptr_base& operator =(const _ptr_base&) = default; }; - template + template struct _ptr_base { AT m_addr; @@ -102,17 +102,6 @@ namespace vm // defined in CB_FUNC.h, call using current PPU thread context RT operator()(T... args) const; - // conversion to function object - operator std::function() const - { - const u32 addr = vm::cast(m_addr); - - return [addr](T... args) -> RT - { - return _ptr_base{ addr }(args...); - }; - } - // conversion to another function pointer template operator _ptr_base() const { @@ -127,7 +116,7 @@ namespace vm _ptr_base& operator =(const _ptr_base&) = default; }; - template + template struct _ptr_base { AT m_addr; @@ -166,6 +155,12 @@ namespace vm // default pointer to pointer for PS3 HLE structures (BE pointer to BE pointer to BE data) template using bpptr = bptr, AT>; + + // native endianness pointer to const BE data + template using cptr = ptr; + + // BE pointer to const BE data + template using bcptr = bptr; } namespace psv @@ -181,6 +176,12 @@ namespace vm // default pointer to pointer for PSV HLE structures (LE pointer to LE pointer to LE data) template using lpptr = lptr>; + + // native endianness pointer to const LE data + template using cptr = ptr; + + // LE pointer to const LE data + template using lcptr = lptr; } // PS3 emulation is main now, so lets it be as default @@ -310,9 +311,9 @@ template inline std::enabl !std::is_function::value && !std::is_function::value && std::is_same, std::remove_cv_t>::value, - u32> operator -(const vm::_ptr_base& left, const vm::_ptr_base& right) + s32> operator -(const vm::_ptr_base& left, const vm::_ptr_base& right) { - return static_cast((left.m_addr - right.m_addr) / sizeof32(T1)); + return static_cast(left.m_addr - right.m_addr) / sizeof32(T1); } // comparison operator for vm::_ptr_base (pointer1 == pointer2)