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:
Michael Scire
2019-10-24 01:40:44 -07:00
committed by SciresM
parent 15773e4755
commit 4059dc6187
169 changed files with 2172 additions and 1868 deletions

View File

@@ -28,7 +28,7 @@ Result FsPathUtils::VerifyPath(const char *path, size_t max_path_len, size_t max
const char c = *(cur++);
/* If terminated, we're done. */
if (c == 0) {
return ResultSuccess;
return ResultSuccess();
}
/* TODO: Nintendo converts the path from utf-8 to utf-32, one character at a time. */
@@ -110,7 +110,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
/* It is unclear why first separator and separator are separate states... */
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else if (c == '.') {
state = PathState::CurrentDir;
} else {
@@ -120,7 +120,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::CurrentDir:
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else if (c == '.') {
state = PathState::ParentDir;
} else {
@@ -130,7 +130,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::ParentDir:
if (c == '/') {
*out = false;
return ResultSuccess;
return ResultSuccess();
} else {
state = PathState::Normal;
}
@@ -138,7 +138,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
case PathState::WindowsDriveLetter:
if (c == ':') {
*out = true;
return ResultSuccess;
return ResultSuccess();
} else {
return ResultFsInvalidPathFormat;
}
@@ -161,7 +161,7 @@ Result FsPathUtils::IsNormalized(bool *out, const char *path) {
break;
}
return ResultSuccess;
return ResultSuccess();
}
Result FsPathUtils::Normalize(char *out, size_t max_out_size, const char *src, size_t *out_len) {
@@ -263,5 +263,5 @@ Result FsPathUtils::Normalize(char *out, size_t max_out_size, const char *src, s
R_ASSERT(FsPathUtils::IsNormalized(&normalized, out));
STS_ASSERT(normalized);
return ResultSuccess;
return ResultSuccess();
}