mirror of
https://github.com/PabloMK7/citra.git
synced 2025-11-03 15:18:47 +00:00
kernel: Update to use atmosphere macros and correct Result (#7242)
* kernel: Switch to atmosphere style macros * code: Rename ResultCode to Result * code: Result constants are lower case * Address review comments * core: Remove CASCADE_CODE * R_TRY replaces completely * core: Run clang format
This commit is contained in:
parent
811303ea54
commit
5a7f615da1
132 changed files with 2807 additions and 2995 deletions
|
|
@ -26,8 +26,8 @@ static Core::TimingEventType* applet_update_event = nullptr;
|
|||
/// The interval at which the Applet update callback will be called, 16.6ms
|
||||
static const u64 applet_update_interval_us = 16666;
|
||||
|
||||
ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
||||
const std::shared_ptr<Service::APT::AppletManager>& manager) {
|
||||
Result Applet::Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
||||
const std::shared_ptr<Service::APT::AppletManager>& manager) {
|
||||
switch (id) {
|
||||
case Service::APT::AppletId::SoftwareKeyboard1:
|
||||
case Service::APT::AppletId::SoftwareKeyboard2:
|
||||
|
|
@ -48,8 +48,8 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
|
|||
default:
|
||||
LOG_ERROR(Service_APT, "Could not create applet {}", id);
|
||||
// TODO(Subv): Find the right error code
|
||||
return ResultCode(ErrorDescription::NotFound, ErrorModule::Applet,
|
||||
ErrorSummary::NotSupported, ErrorLevel::Permanent);
|
||||
return Result(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotSupported,
|
||||
ErrorLevel::Permanent);
|
||||
}
|
||||
|
||||
Service::APT::AppletAttributes attributes;
|
||||
|
|
@ -66,7 +66,7 @@ ResultCode Applet::Create(Service::APT::AppletId id, Service::APT::AppletId pare
|
|||
// Schedule the update event
|
||||
Core::System::GetInstance().CoreTiming().ScheduleEvent(
|
||||
usToCycles(applet_update_interval_us), applet_update_event, static_cast<u64>(id));
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) {
|
||||
|
|
@ -104,10 +104,10 @@ bool Applet::IsActive() const {
|
|||
return is_active;
|
||||
}
|
||||
|
||||
ResultCode Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
|
||||
Result Applet::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
|
||||
switch (parameter.signal) {
|
||||
case Service::APT::SignalType::Wakeup: {
|
||||
ResultCode result = Start(parameter);
|
||||
Result result = Start(parameter);
|
||||
if (!result.IsError()) {
|
||||
is_active = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ public:
|
|||
* @param id Id of the applet to create.
|
||||
* @param parent Id of the applet's parent.
|
||||
* @param preload Whether the applet is being preloaded.
|
||||
* @returns ResultCode Whether the operation was successful or not.
|
||||
* @returns Result Whether the operation was successful or not.
|
||||
*/
|
||||
static ResultCode Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
||||
const std::shared_ptr<Service::APT::AppletManager>& manager);
|
||||
static Result Create(Service::APT::AppletId id, Service::APT::AppletId parent, bool preload,
|
||||
const std::shared_ptr<Service::APT::AppletManager>& manager);
|
||||
|
||||
/**
|
||||
* Retrieves the Applet instance identified by the specified id.
|
||||
|
|
@ -35,9 +35,9 @@ public:
|
|||
/**
|
||||
* Handles a parameter from the application.
|
||||
* @param parameter Parameter data to handle.
|
||||
* @returns ResultCode Whether the operation was successful or not.
|
||||
* @returns Result Whether the operation was successful or not.
|
||||
*/
|
||||
ResultCode ReceiveParameter(const Service::APT::MessageParameter& parameter);
|
||||
Result ReceiveParameter(const Service::APT::MessageParameter& parameter);
|
||||
|
||||
/**
|
||||
* Whether the applet is currently running.
|
||||
|
|
@ -62,22 +62,22 @@ protected:
|
|||
/**
|
||||
* Handles a parameter from the application.
|
||||
* @param parameter Parameter data to handle.
|
||||
* @returns ResultCode Whether the operation was successful or not.
|
||||
* @returns Result Whether the operation was successful or not.
|
||||
*/
|
||||
virtual ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0;
|
||||
virtual Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) = 0;
|
||||
|
||||
/**
|
||||
* Handles the Applet start event, triggered from the application.
|
||||
* @param parameter Parameter data to handle.
|
||||
* @returns ResultCode Whether the operation was successful or not.
|
||||
* @returns Result Whether the operation was successful or not.
|
||||
*/
|
||||
virtual ResultCode Start(const Service::APT::MessageParameter& parameter) = 0;
|
||||
virtual Result Start(const Service::APT::MessageParameter& parameter) = 0;
|
||||
|
||||
/**
|
||||
* Sends the LibAppletClosing signal to the application,
|
||||
* along with the relevant data buffers.
|
||||
*/
|
||||
virtual ResultCode Finalize() = 0;
|
||||
virtual Result Finalize() = 0;
|
||||
|
||||
Service::APT::AppletId id; ///< Id of this Applet
|
||||
Service::APT::AppletId parent; ///< Id of this Applet's parent
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
namespace HLE::Applets {
|
||||
|
||||
ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
Result ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
if (parameter.signal != Service::APT::SignalType::Request) {
|
||||
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
|
||||
UNIMPLEMENTED();
|
||||
// TODO(Subv): Find the right error code
|
||||
return ResultCode(-1);
|
||||
return ResultUnknown;
|
||||
}
|
||||
|
||||
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
|
||||
|
|
@ -40,10 +40,10 @@ ResultCode ErrEula::ReceiveParameterImpl(const Service::APT::MessageParameter& p
|
|||
.object = framebuffer_memory,
|
||||
});
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
|
||||
Result ErrEula::Start(const Service::APT::MessageParameter& parameter) {
|
||||
startup_param = parameter.buffer;
|
||||
|
||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
||||
|
|
@ -52,14 +52,14 @@ ResultCode ErrEula::Start(const Service::APT::MessageParameter& parameter) {
|
|||
|
||||
// Let the application know that we're closing.
|
||||
Finalize();
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
ResultCode ErrEula::Finalize() {
|
||||
Result ErrEula::Finalize() {
|
||||
std::vector<u8> buffer(startup_param.size());
|
||||
std::fill(buffer.begin(), buffer.end(), 0);
|
||||
CloseApplet(nullptr, buffer);
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void ErrEula::Update() {}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ public:
|
|||
std::weak_ptr<Service::APT::AppletManager> manager)
|
||||
: Applet(id, parent, preload, std::move(manager)) {}
|
||||
|
||||
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Finalize() override;
|
||||
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Start(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Finalize() override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
namespace HLE::Applets {
|
||||
|
||||
ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
Result MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
if (parameter.signal != Service::APT::SignalType::Request) {
|
||||
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
|
||||
UNIMPLEMENTED();
|
||||
// TODO(Subv): Find the right error code
|
||||
return ResultCode(-1);
|
||||
return ResultUnknown;
|
||||
}
|
||||
|
||||
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
|
||||
|
|
@ -47,10 +47,10 @@ ResultCode MiiSelector::ReceiveParameterImpl(const Service::APT::MessageParamete
|
|||
.object = framebuffer_memory,
|
||||
});
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
|
||||
Result MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
|
||||
ASSERT_MSG(parameter.buffer.size() == sizeof(config),
|
||||
"The size of the parameter (MiiConfig) is wrong");
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ ResultCode MiiSelector::Start(const Service::APT::MessageParameter& parameter) {
|
|||
MiiSelectorConfig frontend_config = ToFrontendConfig(config);
|
||||
frontend_applet->Setup(frontend_config);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void MiiSelector::Update() {
|
||||
|
|
@ -78,11 +78,11 @@ void MiiSelector::Update() {
|
|||
Finalize();
|
||||
}
|
||||
|
||||
ResultCode MiiSelector::Finalize() {
|
||||
Result MiiSelector::Finalize() {
|
||||
std::vector<u8> buffer(sizeof(MiiResult));
|
||||
std::memcpy(buffer.data(), &result, buffer.size());
|
||||
CloseApplet(nullptr, buffer);
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
MiiResult MiiSelector::GetStandardMiiResult() {
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ public:
|
|||
std::weak_ptr<Service::APT::AppletManager> manager)
|
||||
: Applet(id, parent, preload, std::move(manager)) {}
|
||||
|
||||
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Finalize() override;
|
||||
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Start(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Finalize() override;
|
||||
void Update() override;
|
||||
|
||||
static MiiResult GetStandardMiiResult();
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
namespace HLE::Applets {
|
||||
|
||||
ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
Result Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) {
|
||||
if (parameter.signal != Service::APT::SignalType::Request) {
|
||||
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
|
||||
UNIMPLEMENTED();
|
||||
// TODO(Subv): Find the right error code
|
||||
return ResultCode(-1);
|
||||
return ResultUnknown;
|
||||
}
|
||||
|
||||
// The Request message contains a buffer with the size of the framebuffer shared
|
||||
|
|
@ -40,10 +40,10 @@ ResultCode Mint::ReceiveParameterImpl(const Service::APT::MessageParameter& para
|
|||
.object = framebuffer_memory,
|
||||
});
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
|
||||
Result Mint::Start(const Service::APT::MessageParameter& parameter) {
|
||||
startup_param = parameter.buffer;
|
||||
|
||||
// TODO(Subv): Set the expected fields in the response buffer before resending it to the
|
||||
|
|
@ -52,14 +52,14 @@ ResultCode Mint::Start(const Service::APT::MessageParameter& parameter) {
|
|||
|
||||
// Let the application know that we're closing
|
||||
Finalize();
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
ResultCode Mint::Finalize() {
|
||||
Result Mint::Finalize() {
|
||||
std::vector<u8> buffer(startup_param.size());
|
||||
std::fill(buffer.begin(), buffer.end(), 0);
|
||||
CloseApplet(nullptr, buffer);
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void Mint::Update() {}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ public:
|
|||
std::weak_ptr<Service::APT::AppletManager> manager)
|
||||
: Applet(id, parent, preload, std::move(manager)) {}
|
||||
|
||||
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Finalize() override;
|
||||
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Start(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Finalize() override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace HLE::Applets {
|
||||
|
||||
ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
|
||||
Result SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter const& parameter) {
|
||||
switch (parameter.signal) {
|
||||
case Service::APT::SignalType::Request: {
|
||||
// The LibAppJustStarted message contains a buffer with the size of the framebuffer shared
|
||||
|
|
@ -44,7 +44,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
|
|||
.object = framebuffer_memory,
|
||||
});
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
case Service::APT::SignalType::Message: {
|
||||
|
|
@ -58,7 +58,7 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
|
|||
case SoftwareKeyboardCallbackResult::OK:
|
||||
// Finish execution
|
||||
Finalize();
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
|
||||
case SoftwareKeyboardCallbackResult::Close:
|
||||
// Let the frontend display error and quit
|
||||
|
|
@ -66,14 +66,14 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
|
|||
config.return_code = SoftwareKeyboardResult::BannedInput;
|
||||
config.text_offset = config.text_length = 0;
|
||||
Finalize();
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
|
||||
case SoftwareKeyboardCallbackResult::Continue:
|
||||
// Let the frontend display error and get input again
|
||||
// The input will be sent for validation again on next Update().
|
||||
frontend_applet->ShowError(Common::UTF16BufferToUTF8(config.callback_msg));
|
||||
frontend_applet->Execute(ToFrontendConfig(config));
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
|
@ -84,12 +84,12 @@ ResultCode SoftwareKeyboard::ReceiveParameterImpl(Service::APT::MessageParameter
|
|||
LOG_ERROR(Service_APT, "unsupported signal {}", parameter.signal);
|
||||
UNIMPLEMENTED();
|
||||
// TODO(Subv): Find the right error code
|
||||
return ResultCode(-1);
|
||||
return ResultUnknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
|
||||
Result SoftwareKeyboard::Start(Service::APT::MessageParameter const& parameter) {
|
||||
ASSERT_MSG(parameter.buffer.size() == sizeof(config),
|
||||
"The size of the parameter (SoftwareKeyboardConfig) is wrong");
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ ResultCode SoftwareKeyboard::Start(Service::APT::MessageParameter const& paramet
|
|||
|
||||
frontend_applet->Execute(ToFrontendConfig(config));
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
void SoftwareKeyboard::Update() {
|
||||
|
|
@ -166,12 +166,12 @@ void SoftwareKeyboard::DrawScreenKeyboard() {
|
|||
// TODO(Subv): Draw the HLE keyboard, for now just do nothing
|
||||
}
|
||||
|
||||
ResultCode SoftwareKeyboard::Finalize() {
|
||||
Result SoftwareKeyboard::Finalize() {
|
||||
std::vector<u8> buffer(sizeof(SoftwareKeyboardConfig));
|
||||
std::memcpy(buffer.data(), &config, buffer.size());
|
||||
CloseApplet(nullptr, buffer);
|
||||
text_memory = nullptr;
|
||||
return RESULT_SUCCESS;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig(
|
||||
|
|
|
|||
|
|
@ -179,9 +179,9 @@ public:
|
|||
std::weak_ptr<Service::APT::AppletManager> manager)
|
||||
: Applet(id, parent, preload, std::move(manager)) {}
|
||||
|
||||
ResultCode ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Start(const Service::APT::MessageParameter& parameter) override;
|
||||
ResultCode Finalize() override;
|
||||
Result ReceiveParameterImpl(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Start(const Service::APT::MessageParameter& parameter) override;
|
||||
Result Finalize() override;
|
||||
void Update() override;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue