From a77a75660bc891d820659e166b932d3fc60b5ca6 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 13 Jun 2015 19:36:20 +0300 Subject: [PATCH] Compilation fix --- Utilities/BEType.h | 12 +++--- rpcs3/CMakeLists.txt | 2 +- rpcs3/Emu/SysCalls/Modules/cellL10n.cpp | 53 +++++++++++++++---------- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index ba32ca069e..c3be3eb9e6 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -563,22 +563,22 @@ template struct be_storage template struct be_storage { - typedef u16 type; + using type = u16; }; template struct be_storage { - typedef u32 type; + using type = u32; }; template struct be_storage { - typedef u64 type; + using type = u64; }; template struct be_storage { - typedef u128 type; + using type = u128; }; template using be_storage_t = typename be_storage::type; @@ -587,7 +587,7 @@ template struct be_t { using type = std::remove_cv_t; - using stype = be_storage_t; + using stype = be_storage_t>; stype m_data; @@ -853,7 +853,7 @@ force_inline void convert_le_be(Tto& dst, Tfrom src) template struct le_t { using type = std::remove_cv_t; - using stype = be_storage_t; + using stype = be_storage_t>; stype m_data; diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 4681657712..6ca487be90 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -25,7 +25,7 @@ endif() if (NOT MSVC) add_definitions(-DwxGUI) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fexceptions") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fexceptions") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1 -D_NDEBUG") diff --git a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp index 4bdaa41196..25abd0e916 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellL10n.cpp @@ -8,37 +8,50 @@ #include #endif +//#include #include "cellL10n.h" -#include -#include -#include extern Module cellL10n; s32 UTF16stoUTF8s(vm::ptr utf16, vm::ref utf16_len, vm::ptr utf8, vm::ref utf8_len) { - cellL10n.Warning("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len); + cellL10n.Todo("UTF16stoUTF8s(utf16=*0x%x, utf16_len=*0x%x, utf8=*0x%x, utf8_len=*0x%x)", utf16, utf16_len, utf8, utf8_len); - std::u16string wstr; - wstr.resize(utf16_len); + const u32 max_len = utf8_len; utf8_len = 0; - for (auto& wc : wstr) + for (u32 i = 0, len = 0; i < utf16_len; i++, utf8_len = len) { - wc = *utf16++; + const char16_t ch = utf16[i]; + + // increase required length (TODO) + len = len + 1; + + // validate character (TODO) + if (false) + { + utf16_len = utf16_len - i; + return SRCIllegal; + } + + if (utf8) + { + if (len > max_len) + { + utf16_len = utf16_len - i; + return DSTExhausted; + } + + if (ch <= 0x7f) + { + *utf8++ = static_cast(ch); + } + else + { + *utf8++ = '?'; // TODO + } + } } - std::wstring_convert, char16_t> convert; - std::string str = convert.to_bytes(wstr); - - if (utf8_len < str.size()) - { - utf8_len = str.size(); - return DSTExhausted; - } - - utf8_len = str.size(); - memcpy(utf8.get_ptr(), str.c_str(), str.size()); - return ConversionOK; }