hle: rename legacy errors to Results

This commit is contained in:
Liam 2023-03-06 19:04:12 -05:00
parent 6d61430311
commit 1d0fe75e7c
35 changed files with 169 additions and 183 deletions

View file

@ -61,7 +61,7 @@ void ARP_R::GetApplicationLaunchProperty(HLERequestContext& ctx) {
if (!title_id.has_value()) {
LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_REGISTERED);
rb.Push(Glue::ResultProcessIdNotRegistered);
return;
}
@ -109,7 +109,7 @@ void ARP_R::GetApplicationControlProperty(HLERequestContext& ctx) {
if (!title_id.has_value()) {
LOG_ERROR(Service_ARP, "Failed to get title ID for process ID!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_REGISTERED);
rb.Push(Glue::ResultProcessIdNotRegistered);
return;
}
@ -178,7 +178,7 @@ private:
if (process_id == 0) {
LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_PROCESS_ID);
rb.Push(Glue::ResultInvalidProcessId);
return;
}
@ -186,7 +186,7 @@ private:
LOG_ERROR(Service_ARP,
"Attempted to issue registrar, but registrar is already issued!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_ACCESS);
rb.Push(Glue::ResultAlreadyBound);
return;
}
@ -205,7 +205,7 @@ private:
Service_ARP,
"Attempted to set application launch property, but registrar is already issued!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_ACCESS);
rb.Push(Glue::ResultAlreadyBound);
return;
}
@ -224,7 +224,7 @@ private:
Service_ARP,
"Attempted to set application control property, but registrar is already issued!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_ACCESS);
rb.Push(Glue::ResultAlreadyBound);
return;
}
@ -263,7 +263,7 @@ void ARP_W::AcquireRegistrar(HLERequestContext& ctx) {
system, [this](u64 process_id, ApplicationLaunchProperty launch, std::vector<u8> control) {
const auto res = GetTitleIDForProcessID(system, process_id);
if (!res.has_value()) {
return ERR_NOT_REGISTERED;
return Glue::ResultProcessIdNotRegistered;
}
return manager.Register(*res, launch, std::move(control));
@ -283,7 +283,7 @@ void ARP_W::UnregisterApplicationInstance(HLERequestContext& ctx) {
if (process_id == 0) {
LOG_ERROR(Service_ARP, "Must have non-zero process ID!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_INVALID_PROCESS_ID);
rb.Push(Glue::ResultInvalidProcessId);
return;
}
@ -292,7 +292,7 @@ void ARP_W::UnregisterApplicationInstance(HLERequestContext& ctx) {
if (!title_id.has_value()) {
LOG_ERROR(Service_ARP, "No title ID for process ID!");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ERR_NOT_REGISTERED);
rb.Push(Glue::ResultProcessIdNotRegistered);
return;
}

View file

@ -7,9 +7,8 @@
namespace Service::Glue {
constexpr Result ERR_INVALID_RESOURCE{ErrorModule::ARP, 30};
constexpr Result ERR_INVALID_PROCESS_ID{ErrorModule::ARP, 31};
constexpr Result ERR_INVALID_ACCESS{ErrorModule::ARP, 42};
constexpr Result ERR_NOT_REGISTERED{ErrorModule::ARP, 102};
constexpr Result ResultInvalidProcessId{ErrorModule::ARP, 31};
constexpr Result ResultAlreadyBound{ErrorModule::ARP, 42};
constexpr Result ResultProcessIdNotRegistered{ErrorModule::ARP, 102};
} // namespace Service::Glue

View file

@ -17,12 +17,12 @@ ARPManager::~ARPManager() = default;
ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id) const {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
return Glue::ResultInvalidProcessId;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return ERR_NOT_REGISTERED;
return Glue::ResultProcessIdNotRegistered;
}
return iter->second.launch;
@ -30,12 +30,12 @@ ResultVal<ApplicationLaunchProperty> ARPManager::GetLaunchProperty(u64 title_id)
ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
return Glue::ResultInvalidProcessId;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return ERR_NOT_REGISTERED;
return Glue::ResultProcessIdNotRegistered;
}
return iter->second.control;
@ -44,12 +44,12 @@ ResultVal<std::vector<u8>> ARPManager::GetControlProperty(u64 title_id) const {
Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
std::vector<u8> control) {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
return Glue::ResultInvalidProcessId;
}
const auto iter = entries.find(title_id);
if (iter != entries.end()) {
return ERR_INVALID_ACCESS;
return Glue::ResultAlreadyBound;
}
entries.insert_or_assign(title_id, MapEntry{launch, std::move(control)});
@ -58,12 +58,12 @@ Result ARPManager::Register(u64 title_id, ApplicationLaunchProperty launch,
Result ARPManager::Unregister(u64 title_id) {
if (title_id == 0) {
return ERR_INVALID_PROCESS_ID;
return Glue::ResultInvalidProcessId;
}
const auto iter = entries.find(title_id);
if (iter == entries.end()) {
return ERR_NOT_REGISTERED;
return Glue::ResultProcessIdNotRegistered;
}
entries.erase(iter);

View file

@ -30,23 +30,23 @@ public:
~ARPManager();
// Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
// previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
// ERR_INVALID_PROCESS_ID if the title ID is 0.
// previously registered, otherwise ResultProcessIdNotRegistered if it was never registered or
// ResultInvalidProcessId if the title ID is 0.
ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
// Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
// the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
// never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
// the provided title ID if it was previously registered, otherwise ResultProcessIdNotRegistered
// if it was never registered or ResultInvalidProcessId if the title ID is 0.
ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
// Adds a new entry to the internal database with the provided parameters, returning
// ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
// step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
// ResultProcessIdNotRegistered if attempting to re-register a title ID without an intermediate
// Unregister step, and ResultInvalidProcessId if the title ID is 0.
Result Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
// Removes the registration for the provided title ID from the database, returning
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
// title ID is 0.
// ResultProcessIdNotRegistered if it doesn't exist in the database and ResultInvalidProcessId
// if the title ID is 0.
Result Unregister(u64 title_id);
// Removes all entries from the database, always succeeds. Should only be used when resetting