mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-20 18:05:11 -04:00
Results: Implement namespaced, type-safe results.
Because I was working on multiple things at once, this commit also: - Adds wrappers for/linker flags to wrap CXX exceptions to make them abort. This saves ~0x8000 of memory in every system module. - Broadly replaces lines of the pattern if (cond) { return ResultX; } with R_UNLESS(!cond, ResultX());. - Reworks the R_TRY_CATCH macros (and the result macros in general).
This commit is contained in:
parent
15773e4755
commit
4059dc6187
169 changed files with 2172 additions and 1868 deletions
|
@ -60,10 +60,8 @@ namespace sts::ldr::ecs {
|
|||
}
|
||||
|
||||
Result Set(Handle *out, ncm::TitleId title_id) {
|
||||
if (g_map.size() >= MaxExternalContentSourceCount) {
|
||||
/* TODO: Is this an appropriate error? */
|
||||
return ResultLoaderTooManyArguments;
|
||||
}
|
||||
/* TODO: Is this an appropriate error? */
|
||||
R_UNLESS(g_map.size() < MaxExternalContentSourceCount, ldr::ResultTooManyArguments());
|
||||
|
||||
/* Clear any sources. */
|
||||
R_ASSERT(Clear(title_id));
|
||||
|
@ -80,23 +78,22 @@ namespace sts::ldr::ecs {
|
|||
Service srv;
|
||||
serviceCreate(&srv, client.Move());
|
||||
FsFileSystem fs = { srv };
|
||||
auto fs_guard = SCOPE_GUARD { fsFsClose(&fs); };
|
||||
|
||||
/* Try to mount. */
|
||||
if (fsdevMountDevice(device_name, fs) == -1) {
|
||||
serviceClose(&srv);
|
||||
return ResultFsMountNameAlreadyExists;
|
||||
}
|
||||
R_UNLESS(fsdevMountDevice(device_name, fs) >= 0, fs::ResultMountNameAlreadyExists());
|
||||
fs_guard.Cancel();
|
||||
|
||||
/* Add to map. */
|
||||
g_map.emplace(static_cast<u64>(title_id), device_name);
|
||||
*out = server.Move();
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result Clear(ncm::TitleId title_id) {
|
||||
/* Delete if present. */
|
||||
g_map.erase(static_cast<u64>(title_id));
|
||||
return ResultSuccess;
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue