2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Address review comments

This commit is contained in:
Michael Scire 2019-05-23 01:28:27 -07:00
parent 7fba9c7224
commit d81b58f320
6 changed files with 120 additions and 47 deletions

View file

@ -327,10 +327,10 @@ add_library(core STATIC
hle/service/npns/npns.cpp hle/service/npns/npns.cpp
hle/service/npns/npns.h hle/service/npns/npns.h
hle/service/ns/errors.h hle/service/ns/errors.h
hle/service/ns/language.cpp
hle/service/ns/language.h
hle/service/ns/ns.cpp hle/service/ns/ns.cpp
hle/service/ns/ns.h hle/service/ns/ns.h
hle/service/ns/ns_language.cpp
hle/service/ns/ns_language.h
hle/service/ns/pl_u.cpp hle/service/ns/pl_u.cpp
hle/service/ns/pl_u.h hle/service/ns/pl_u.h
hle/service/nvdrv/devices/nvdevice.h hle/service/nvdrv/devices/nvdevice.h

View file

@ -1,8 +1,9 @@
// Copyright 2018 yuzu emulator team // Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/hle/service/ns/ns_language.h" #include "core/hle/service/ns/language.h"
#include "core/hle/service/set/set.h"
namespace Service::NS { namespace Service::NS {
@ -277,7 +278,7 @@ constexpr ApplicationLanguagePriorityList priority_list_simplified_chinese = {{
}}; }};
const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList( const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(
ApplicationLanguage lang) { const ApplicationLanguage lang) {
switch (lang) { switch (lang) {
case ApplicationLanguage::AmericanEnglish: case ApplicationLanguage::AmericanEnglish:
return &priority_list_american_english; return &priority_list_american_english;
@ -315,75 +316,75 @@ const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(
} }
std::optional<ApplicationLanguage> ConvertToApplicationLanguage( std::optional<ApplicationLanguage> ConvertToApplicationLanguage(
const Service::Set::LanguageCode language_code) { const Set::LanguageCode language_code) {
switch (language_code) { switch (language_code) {
case Service::Set::LanguageCode::EN_US: case Set::LanguageCode::EN_US:
return ApplicationLanguage::AmericanEnglish; return ApplicationLanguage::AmericanEnglish;
case Service::Set::LanguageCode::EN_GB: case Set::LanguageCode::EN_GB:
return ApplicationLanguage::BritishEnglish; return ApplicationLanguage::BritishEnglish;
case Service::Set::LanguageCode::JA: case Set::LanguageCode::JA:
return ApplicationLanguage::Japanese; return ApplicationLanguage::Japanese;
case Service::Set::LanguageCode::FR: case Set::LanguageCode::FR:
return ApplicationLanguage::French; return ApplicationLanguage::French;
case Service::Set::LanguageCode::DE: case Set::LanguageCode::DE:
return ApplicationLanguage::German; return ApplicationLanguage::German;
case Service::Set::LanguageCode::ES_419: case Set::LanguageCode::ES_419:
return ApplicationLanguage::LatinAmericanSpanish; return ApplicationLanguage::LatinAmericanSpanish;
case Service::Set::LanguageCode::ES: case Set::LanguageCode::ES:
return ApplicationLanguage::Spanish; return ApplicationLanguage::Spanish;
case Service::Set::LanguageCode::IT: case Set::LanguageCode::IT:
return ApplicationLanguage::Italian; return ApplicationLanguage::Italian;
case Service::Set::LanguageCode::NL: case Set::LanguageCode::NL:
return ApplicationLanguage::Dutch; return ApplicationLanguage::Dutch;
case Service::Set::LanguageCode::FR_CA: case Set::LanguageCode::FR_CA:
return ApplicationLanguage::CanadianFrench; return ApplicationLanguage::CanadianFrench;
case Service::Set::LanguageCode::PT: case Set::LanguageCode::PT:
return ApplicationLanguage::Portuguese; return ApplicationLanguage::Portuguese;
case Service::Set::LanguageCode::RU: case Set::LanguageCode::RU:
return ApplicationLanguage::Russian; return ApplicationLanguage::Russian;
case Service::Set::LanguageCode::KO: case Set::LanguageCode::KO:
return ApplicationLanguage::Korean; return ApplicationLanguage::Korean;
case Service::Set::LanguageCode::ZH_HANT: case Set::LanguageCode::ZH_HANT:
return ApplicationLanguage::TraditionalChinese; return ApplicationLanguage::TraditionalChinese;
case Service::Set::LanguageCode::ZH_HANS: case Set::LanguageCode::ZH_HANS:
return ApplicationLanguage::SimplifiedChinese; return ApplicationLanguage::SimplifiedChinese;
default: default:
return std::nullopt; return std::nullopt;
} }
} }
std::optional<Service::Set::LanguageCode> ConvertToLanguageCode(const ApplicationLanguage lang) { std::optional<Set::LanguageCode> ConvertToLanguageCode(const ApplicationLanguage lang) {
switch (lang) { switch (lang) {
case ApplicationLanguage::AmericanEnglish: case ApplicationLanguage::AmericanEnglish:
return Service::Set::LanguageCode::EN_US; return Set::LanguageCode::EN_US;
case ApplicationLanguage::BritishEnglish: case ApplicationLanguage::BritishEnglish:
return Service::Set::LanguageCode::EN_GB; return Set::LanguageCode::EN_GB;
case ApplicationLanguage::Japanese: case ApplicationLanguage::Japanese:
return Service::Set::LanguageCode::JA; return Set::LanguageCode::JA;
case ApplicationLanguage::French: case ApplicationLanguage::French:
return Service::Set::LanguageCode::FR; return Set::LanguageCode::FR;
case ApplicationLanguage::German: case ApplicationLanguage::German:
return Service::Set::LanguageCode::DE; return Set::LanguageCode::DE;
case ApplicationLanguage::LatinAmericanSpanish: case ApplicationLanguage::LatinAmericanSpanish:
return Service::Set::LanguageCode::ES_419; return Set::LanguageCode::ES_419;
case ApplicationLanguage::Spanish: case ApplicationLanguage::Spanish:
return Service::Set::LanguageCode::ES; return Set::LanguageCode::ES;
case ApplicationLanguage::Italian: case ApplicationLanguage::Italian:
return Service::Set::LanguageCode::IT; return Set::LanguageCode::IT;
case ApplicationLanguage::Dutch: case ApplicationLanguage::Dutch:
return Service::Set::LanguageCode::NL; return Set::LanguageCode::NL;
case ApplicationLanguage::CanadianFrench: case ApplicationLanguage::CanadianFrench:
return Service::Set::LanguageCode::FR_CA; return Set::LanguageCode::FR_CA;
case ApplicationLanguage::Portuguese: case ApplicationLanguage::Portuguese:
return Service::Set::LanguageCode::PT; return Set::LanguageCode::PT;
case ApplicationLanguage::Russian: case ApplicationLanguage::Russian:
return Service::Set::LanguageCode::RU; return Set::LanguageCode::RU;
case ApplicationLanguage::Korean: case ApplicationLanguage::Korean:
return Service::Set::LanguageCode::KO; return Set::LanguageCode::KO;
case ApplicationLanguage::TraditionalChinese: case ApplicationLanguage::TraditionalChinese:
return Service::Set::LanguageCode::ZH_HANT; return Set::LanguageCode::ZH_HANT;
case ApplicationLanguage::SimplifiedChinese: case ApplicationLanguage::SimplifiedChinese:
return Service::Set::LanguageCode::ZH_HANS; return Set::LanguageCode::ZH_HANS;
default: default:
return std::nullopt; return std::nullopt;
} }

View file

@ -0,0 +1,45 @@
// Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <optional>
#include <string>
#include "common/common_types.h"
namespace Service::Set {
enum class LanguageCode : u64;
}
namespace Service::NS {
/// This is nn::ns::detail::ApplicationLanguage
enum class ApplicationLanguage : u8 {
AmericanEnglish = 0,
BritishEnglish,
Japanese,
French,
German,
LatinAmericanSpanish,
Spanish,
Italian,
Dutch,
CanadianFrench,
Portuguese,
Russian,
Korean,
TraditionalChinese,
SimplifiedChinese,
Count
};
using ApplicationLanguagePriorityList =
const std::array<ApplicationLanguage, static_cast<std::size_t>(ApplicationLanguage::Count)>;
constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) {
return 1U << static_cast<u32>(lang);
}
const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang);
std::optional<ApplicationLanguage> ConvertToApplicationLanguage(Set::LanguageCode language_code);
std::optional<Set::LanguageCode> ConvertToLanguageCode(ApplicationLanguage lang);
} // namespace Service::NS

View file

@ -9,8 +9,9 @@
#include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/hle_ipc.h"
#include "core/hle/service/ns/errors.h" #include "core/hle/service/ns/errors.h"
#include "core/hle/service/ns/ns.h" #include "core/hle/service/ns/ns.h"
#include "core/hle/service/ns/ns_language.h" #include "core/hle/service/ns/language.h"
#include "core/hle/service/ns/pl_u.h" #include "core/hle/service/ns/pl_u.h"
#include "core/hle/service/set/set.h"
#include "core/settings.h" #include "core/settings.h"
namespace Service::NS { namespace Service::NS {
@ -25,6 +26,8 @@ IAccountProxyInterface::IAccountProxyInterface() : ServiceFramework{"IAccountPro
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IAccountProxyInterface::~IAccountProxyInterface() = default;
IApplicationManagerInterface::IApplicationManagerInterface() IApplicationManagerInterface::IApplicationManagerInterface()
: ServiceFramework{"IApplicationManagerInterface"} { : ServiceFramework{"IApplicationManagerInterface"} {
// clang-format off // clang-format off
@ -246,6 +249,8 @@ IApplicationManagerInterface::IApplicationManagerInterface()
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IApplicationManagerInterface::~IApplicationManagerInterface() = default;
void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestContext& ctx) { void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const auto flag = rp.PopRaw<u64>(); const auto flag = rp.PopRaw<u64>();
@ -325,7 +330,7 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
// Get language code from settings // Get language code from settings
const auto language_code = const auto language_code =
Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index); Set::GetLanguageCodeFromIndex(Settings::values.language_index);
// Convert to application language, get priority list // Convert to application language, get priority list
const auto application_language = ConvertToApplicationLanguage(language_code); const auto application_language = ConvertToApplicationLanguage(language_code);
@ -342,7 +347,7 @@ ResultVal<u8> IApplicationManagerInterface::GetApplicationDesiredLanguage(
const auto supported_flag = GetSupportedLanguageFlag(lang); const auto supported_flag = GetSupportedLanguageFlag(lang);
if (supported_languages == 0 || if (supported_languages == 0 ||
(supported_languages & supported_flag) == supported_languages) { (supported_languages & supported_flag) == supported_languages) {
return ResultVal<u8>::WithCode(RESULT_SUCCESS, static_cast<u8>(lang)); return MakeResult(static_cast<u8>(lang));
} }
} }
@ -373,7 +378,7 @@ ResultVal<u64> IApplicationManagerInterface::ConvertApplicationLanguageToLanguag
return ERR_APPLICATION_LANGUAGE_NOT_FOUND; return ERR_APPLICATION_LANGUAGE_NOT_FOUND;
} }
return ResultVal<u64>::WithCode(RESULT_SUCCESS, static_cast<u64>(*language_code)); return MakeResult(static_cast<u64>(*language_code));
} }
IApplicationVersionInterface::IApplicationVersionInterface() IApplicationVersionInterface::IApplicationVersionInterface()
@ -395,6 +400,8 @@ IApplicationVersionInterface::IApplicationVersionInterface()
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IApplicationVersionInterface::~IApplicationVersionInterface() = default;
IContentManagerInterface::IContentManagerInterface() IContentManagerInterface::IContentManagerInterface()
: ServiceFramework{"IContentManagerInterface"} { : ServiceFramework{"IContentManagerInterface"} {
// clang-format off // clang-format off
@ -413,6 +420,8 @@ IContentManagerInterface::IContentManagerInterface()
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IContentManagerInterface::~IContentManagerInterface() = default;
IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface"} { IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -425,6 +434,8 @@ IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface"
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IDocumentInterface::~IDocumentInterface() = default;
IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} { IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -443,6 +454,8 @@ IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTa
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IDownloadTaskInterface::~IDownloadTaskInterface() = default;
IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterface"} { IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterface"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -458,6 +471,8 @@ IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterfa
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IECommerceInterface::~IECommerceInterface() = default;
IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface() IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface()
: ServiceFramework{"IFactoryResetInterface"} { : ServiceFramework{"IFactoryResetInterface"} {
// clang-format off // clang-format off
@ -471,6 +486,8 @@ IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface()
RegisterHandlers(functions); RegisterHandlers(functions);
} }
IFactoryResetInterface::~IFactoryResetInterface() = default;
NS::NS(const char* name) : ServiceFramework{name} { NS::NS(const char* name) : ServiceFramework{name} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -488,7 +505,9 @@ NS::NS(const char* name) : ServiceFramework{name} {
RegisterHandlers(functions); RegisterHandlers(functions);
} }
std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() { NS::~NS() = default;
std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() const {
return GetInterface<IApplicationManagerInterface>(); return GetInterface<IApplicationManagerInterface>();
} }

View file

@ -5,18 +5,19 @@
#pragma once #pragma once
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/service/set/set.h"
namespace Service::NS { namespace Service::NS {
class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> { class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> {
public: public:
explicit IAccountProxyInterface(); explicit IAccountProxyInterface();
~IAccountProxyInterface();
}; };
class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> { class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> {
public: public:
explicit IApplicationManagerInterface(); explicit IApplicationManagerInterface();
~IApplicationManagerInterface();
ResultVal<u8> GetApplicationDesiredLanguage(u32 supported_languages); ResultVal<u8> GetApplicationDesiredLanguage(u32 supported_languages);
ResultVal<u64> ConvertApplicationLanguageToLanguageCode(u8 application_language); ResultVal<u64> ConvertApplicationLanguageToLanguageCode(u8 application_language);
@ -30,38 +31,45 @@ private:
class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> {
public: public:
explicit IApplicationVersionInterface(); explicit IApplicationVersionInterface();
~IApplicationVersionInterface();
}; };
class IContentManagerInterface final : public ServiceFramework<IContentManagerInterface> { class IContentManagerInterface final : public ServiceFramework<IContentManagerInterface> {
public: public:
explicit IContentManagerInterface(); explicit IContentManagerInterface();
~IContentManagerInterface();
}; };
class IDocumentInterface final : public ServiceFramework<IDocumentInterface> { class IDocumentInterface final : public ServiceFramework<IDocumentInterface> {
public: public:
explicit IDocumentInterface(); explicit IDocumentInterface();
~IDocumentInterface();
}; };
class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> { class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> {
public: public:
explicit IDownloadTaskInterface(); explicit IDownloadTaskInterface();
~IDownloadTaskInterface();
}; };
class IECommerceInterface final : public ServiceFramework<IECommerceInterface> { class IECommerceInterface final : public ServiceFramework<IECommerceInterface> {
public: public:
explicit IECommerceInterface(); explicit IECommerceInterface();
~IECommerceInterface();
}; };
class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> { class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> {
public: public:
explicit IFactoryResetInterface(); explicit IFactoryResetInterface();
~IFactoryResetInterface();
}; };
class NS final : public ServiceFramework<NS> { class NS final : public ServiceFramework<NS> {
public: public:
explicit NS(const char* name); explicit NS(const char* name);
~NS();
std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface(); std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const;
private: private:
template <typename T> template <typename T>
@ -74,7 +82,7 @@ private:
} }
template <typename T> template <typename T>
std::shared_ptr<T> GetInterface() { std::shared_ptr<T> GetInterface() const {
static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>, static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>,
"Not a base of ServiceFrameworkBase"); "Not a base of ServiceFrameworkBase");

View file

@ -1,4 +1,4 @@
// Copyright 2018 yuzu emulator team // Copyright 2019 yuzu emulator team
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -32,7 +32,7 @@ using ApplicationLanguagePriorityList =
const std::array<ApplicationLanguage, static_cast<std::size_t>(ApplicationLanguage::Count)>; const std::array<ApplicationLanguage, static_cast<std::size_t>(ApplicationLanguage::Count)>;
constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) { constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) {
return 1u << static_cast<u32>(lang); return 1U << static_cast<u32>(lang);
} }
const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang); const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang);