ams: support building unit test programs on windows/linux/macos
This commit is contained in:
@@ -56,68 +56,76 @@ namespace ams::fs {
|
||||
R_DEFINE_ERROR_RESULT(SystemPartitionNotReady, 3100);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(AllocationFailure, 3200, 3499);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemAccessorA, 3211);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemAccessorB, 3212);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInApplicationA, 3213);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisA, 3215);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisB, 3216);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisC, 3217);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInCodeA, 3218);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentA, 3219);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentStorageA, 3220);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentStorageB, 3221);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDataA, 3222);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDataB, 3223);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDeviceSaveDataA, 3224);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardA, 3225);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardB, 3226);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardC, 3227);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardD, 3228);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInImageDirectoryA, 3232);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSdCardA, 3244);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSdCardB, 3245);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSystemSaveDataA, 3246);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemA, 3247);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemB, 3248);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemC, 3249);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemProxyCoreImplD, 3256);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemProxyCoreImplE, 3257);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInProgramRegistryManagerA, 3258);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemCreatorA, 3280);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFileSystemCreatorA, 3281);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInStorageOnNcaCreatorA, 3288);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInStorageOnNcaCreatorB, 3289);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemBuddyHeapA, 3294);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemBufferManagerA, 3295);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBlockCacheBufferedStorageA, 3296);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBlockCacheBufferedStorageB, 3297);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityVerificationStorageA, 3304);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityVerificationStorageB, 3305);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDirectorySaveDataFileSystem, 3321);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNcaFileSystemDriverI, 3341);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemA, 3347);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemB, 3348);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemC, 3349);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaA, 3350);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaB, 3351);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemD, 3352);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystem, 3355);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNcaReaderA, 3363);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRegisterA, 3365);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRegisterB, 3366);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPathNormalizer, 3367);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDbmRomKeyValueStorage, 3375);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemE, 3377);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInReadOnlyFileSystemA, 3386);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAesCtrCounterExtendedStorageA, 3399);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAesCtrCounterExtendedStorageB, 3400);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemInterfaceAdapter, 3407);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBufferedStorageA, 3411);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityRomFsStorageA, 3412);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNew, 3420);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInMakeUnique, 3422);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAllocateShared, 3423);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailurePooledBufferNotEnoughSize, 3424);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemAccessorA, 3211);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemAccessorB, 3212);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInApplicationA, 3213);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisA, 3215);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisB, 3216);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBisC, 3217);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInCodeA, 3218);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentA, 3219);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentStorageA, 3220);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInContentStorageB, 3221);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDataA, 3222);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDataB, 3223);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDeviceSaveDataA, 3224);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardA, 3225);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardB, 3226);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardC, 3227);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInGameCardD, 3228);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInHostA, 3229);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInHostB, 3230);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInHostC, 3231);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInImageDirectoryA, 3232);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSdCardA, 3244);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSdCardB, 3245);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSystemSaveDataA, 3246);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemA, 3247);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemB, 3248);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemC, 3249);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemProxyCoreImplD, 3256);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemProxyCoreImplE, 3257);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInProgramRegistryManagerA, 3258);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInLocalFileSystemCreatorA, 3279);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemCreatorA, 3280);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFileSystemCreatorA, 3281);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInStorageOnNcaCreatorA, 3288);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInStorageOnNcaCreatorB, 3289);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystemCreatorA, 3290);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemBuddyHeapA, 3294);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemBufferManagerA, 3295);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBlockCacheBufferedStorageA, 3296);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBlockCacheBufferedStorageB, 3297);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityVerificationStorageA, 3304);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityVerificationStorageB, 3305);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDirectorySaveDataFileSystem, 3321);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInLocalFileSystemA, 3322);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInLocalFileSystemB, 3323);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNcaFileSystemDriverI, 3341);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemA, 3347);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemB, 3348);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemC, 3349);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaA, 3350);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaB, 3351);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemD, 3352);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystem, 3355);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNcaReaderA, 3363);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRegisterA, 3365);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRegisterB, 3366);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPathNormalizer, 3367);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDbmRomKeyValueStorage, 3375);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemE, 3377);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInReadOnlyFileSystemA, 3386);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAesCtrCounterExtendedStorageA, 3399);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAesCtrCounterExtendedStorageB, 3400);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemInterfaceAdapter, 3407);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInBufferedStorageA, 3411);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInIntegrityRomFsStorageA, 3412);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInNew, 3420);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemProxyImplA, 3421);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInMakeUnique, 3422);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInAllocateShared, 3423);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailurePooledBufferNotEnoughSize, 3424);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(Internal, 3000, 7999);
|
||||
R_DEFINE_ERROR_RANGE(MmcAccessFailed, 3500, 3999);
|
||||
@@ -284,12 +292,22 @@ namespace ams::fs {
|
||||
R_DEFINE_ERROR_RESULT(GameCardLogoDataCorrupted, 4781);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(Unexpected, 5000, 5999);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInAesCtrStorageA, 5315);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInAesXtsStorageA, 5316);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInFindFileSystemA, 5319);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageA, 5324);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageB, 5325);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageC, 5326);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemA, 5305);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemB, 5306);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemC, 5307);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemD, 5308);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemE, 5309);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInLocalFileSystemF, 5310);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryA, 5312);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryB, 5313);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInPathOnExecutionDirectoryC, 5314);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInAesCtrStorageA, 5315);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInAesXtsStorageA, 5316);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInFindFileSystemA, 5319);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageA, 5324);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageB, 5325);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInCompressedStorageC, 5326);
|
||||
R_DEFINE_ERROR_RESULT(UnexpectedInPathA, 5328);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(PreconditionViolation, 6000, 6499);
|
||||
R_DEFINE_ERROR_RANGE(InvalidArgument, 6001, 6199);
|
||||
@@ -334,6 +352,7 @@ namespace ams::fs {
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageA, 6306);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageB, 6307);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInSwitchStorageA, 6308);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInStorageServiceObjectAdapterA, 6309);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageA, 6310);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageB, 6311);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageC, 6312);
|
||||
@@ -372,9 +391,12 @@ namespace ams::fs {
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemB, 6375);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileA, 6376);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileB, 6377);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInLocalFileA, 6378);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInDirectorySaveDataFileSystemA, 6384);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInCompressedStorageA, 6387);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449);
|
||||
R_DEFINE_ERROR_RESULT(PermissionDeniedForCreateHostFileSystem, 6403);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(PortAcceptableCountLimited, 6450);
|
||||
R_DEFINE_ERROR_RESULT(NeedFlush, 6454);
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace ams::os {
|
||||
|
||||
R_DEFINE_ERROR_RESULT(Busy, 4);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(InvalidParameter, 7);
|
||||
R_DEFINE_ERROR_RESULT(OutOfMemory, 8);
|
||||
R_DEFINE_ERROR_RESULT(OutOfResource, 9);
|
||||
|
||||
@@ -41,4 +42,7 @@ namespace ams::os {
|
||||
R_DEFINE_ERROR_RESULT(SessionClosedForReply, 511);
|
||||
R_DEFINE_ERROR_RESULT(ReceiveListBroken, 512);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(NotImplemented, 1000);
|
||||
R_DEFINE_ERROR_RESULT(NotSupported, 1001);
|
||||
|
||||
}
|
||||
|
||||
@@ -219,6 +219,14 @@ namespace ams {
|
||||
|
||||
}
|
||||
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX) && defined(ATMOSPHERE_ARCH_ARM64) && defined(ATMOSPHERE_IS_STRATOSPHERE)
|
||||
namespace diag::impl {
|
||||
|
||||
void FatalErrorByResultForNx(Result result) noexcept NORETURN;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* Macros for defining new results. */
|
||||
@@ -353,61 +361,66 @@ namespace ams::result::impl {
|
||||
|
||||
/// Returns a result.
|
||||
#define R_THROW(res_expr) \
|
||||
({ \
|
||||
{ \
|
||||
const ::ams::Result _tmp_r_throw_rc = (res_expr); \
|
||||
if constexpr (std::same_as<decltype(__TmpCurrentResultReference), ::ams::Result &>) { __TmpCurrentResultReference = _tmp_r_throw_rc; } \
|
||||
return _tmp_r_throw_rc; \
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns ResultSuccess()
|
||||
#define R_SUCCEED() R_THROW(::ams::ResultSuccess())
|
||||
|
||||
/// Evaluates an expression that returns a result, and returns the result if it would fail.
|
||||
#define R_TRY(res_expr) \
|
||||
({ \
|
||||
{ \
|
||||
if (const auto _tmp_r_try_rc = (res_expr); R_FAILED(_tmp_r_try_rc)) { \
|
||||
R_THROW(_tmp_r_try_rc); \
|
||||
} \
|
||||
})
|
||||
}
|
||||
|
||||
/// Return a result.
|
||||
#define R_RETURN(res_expr) R_THROW(res_expr)
|
||||
|
||||
#ifdef AMS_ENABLE_DEBUG_PRINT
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX) && defined(ATMOSPHERE_IS_STRATOSPHERE) && !defined(AMS_ENABLE_DETAILED_ASSERTIONS) && !defined(AMS_BUILD_FOR_DEBUGGING) && !defined(AMS_BUILD_FOR_AUDITING)
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) do { ::ams::diag::impl::FatalErrorByResultForNx(val); AMS_INFINITE_LOOP(); AMS_ASSUME(false); } while (false)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) do { ::ams::diag::impl::FatalErrorByResultForNx(val); AMS_INFINITE_LOOP(); AMS_ASSUME(false); } while (false)
|
||||
#else
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion("", 0, "", "", val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort("", 0, "", "", val)
|
||||
#if defined(AMS_ENABLE_DETAILED_ASSERTIONS)
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, val)
|
||||
#else
|
||||
#define AMS_CALL_ON_RESULT_ASSERTION_IMPL(cond, val) ::ams::result::impl::OnResultAssertion("", 0, "", "", val)
|
||||
#define AMS_CALL_ON_RESULT_ABORT_IMPL(cond, val) ::ams::result::impl::OnResultAbort("", 0, "", "", val)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// Evaluates an expression that returns a result, and asserts the result if it would fail.
|
||||
#ifdef AMS_ENABLE_ASSERTIONS
|
||||
#define R_ASSERT(res_expr) \
|
||||
({ \
|
||||
{ \
|
||||
if (const auto _tmp_r_assert_rc = (res_expr); AMS_UNLIKELY(R_FAILED(_tmp_r_assert_rc))) { \
|
||||
AMS_CALL_ON_RESULT_ASSERTION_IMPL(#res_expr, _tmp_r_assert_rc); \
|
||||
} \
|
||||
})
|
||||
}
|
||||
#else
|
||||
#define R_ASSERT(res_expr) AMS_UNUSED((res_expr));
|
||||
#endif
|
||||
|
||||
/// Evaluates an expression that returns a result, and aborts if the result would fail.
|
||||
#define R_ABORT_UNLESS(res_expr) \
|
||||
({ \
|
||||
{ \
|
||||
if (const auto _tmp_r_abort_rc = (res_expr); AMS_UNLIKELY(R_FAILED(_tmp_r_abort_rc))) { \
|
||||
AMS_CALL_ON_RESULT_ABORT_IMPL(#res_expr, _tmp_r_abort_rc); \
|
||||
} \
|
||||
})
|
||||
}
|
||||
|
||||
/// Evaluates a boolean expression, and returns a result unless that expression is true.
|
||||
#define R_UNLESS(expr, res) \
|
||||
({ \
|
||||
{ \
|
||||
if (!(expr)) { \
|
||||
R_THROW(res); \
|
||||
} \
|
||||
})
|
||||
}
|
||||
|
||||
/// Evaluates a boolean expression, and succeeds if that expression is true.
|
||||
#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), ResultSuccess())
|
||||
@@ -415,24 +428,24 @@ namespace ams::result::impl {
|
||||
/// Helpers for pattern-matching on a result expression, if the result would fail.
|
||||
#define R_CURRENT_RESULT _tmp_r_try_catch_current_result
|
||||
|
||||
#define R_TRY_CATCH(res_expr) \
|
||||
({ \
|
||||
#define R_TRY_CATCH(res_expr) \
|
||||
{ \
|
||||
const auto R_CURRENT_RESULT = (res_expr); \
|
||||
if (R_FAILED(R_CURRENT_RESULT)) { \
|
||||
if (R_FAILED(R_CURRENT_RESULT)) { \
|
||||
if (false)
|
||||
|
||||
#define R_CATCH(...) \
|
||||
#define R_CATCH(...) \
|
||||
} else if (::ams::result::impl::EvaluateAnyResultIncludes<__VA_ARGS__>(R_CURRENT_RESULT)) { \
|
||||
if (true)
|
||||
|
||||
#define R_CATCH_MODULE(__module__) \
|
||||
#define R_CATCH_MODULE(__module__) \
|
||||
} else if ((R_CURRENT_RESULT).GetModule() == ::ams::R_NAMESPACE_MODULE_ID(__module__)) { \
|
||||
if (true)
|
||||
|
||||
#define R_CONVERT(catch_type, convert_type) \
|
||||
R_CATCH(catch_type) { R_THROW(static_cast<::ams::Result>(convert_type)); }
|
||||
|
||||
#define R_CATCH_ALL() \
|
||||
#define R_CATCH_ALL() \
|
||||
} else if (R_FAILED(R_CURRENT_RESULT)) { \
|
||||
if (true)
|
||||
|
||||
@@ -442,26 +455,26 @@ namespace ams::result::impl {
|
||||
#define R_CATCH_RETHROW(catch_type) \
|
||||
R_CONVERT(catch_type, R_CURRENT_RESULT)
|
||||
|
||||
#define R_END_TRY_CATCH \
|
||||
#define R_END_TRY_CATCH \
|
||||
else if (R_FAILED(R_CURRENT_RESULT)) { \
|
||||
R_THROW(R_CURRENT_RESULT); \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
R_THROW(R_CURRENT_RESULT); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define R_END_TRY_CATCH_WITH_ASSERT \
|
||||
else { \
|
||||
#define R_END_TRY_CATCH_WITH_ASSERT \
|
||||
else { \
|
||||
R_ASSERT(R_CURRENT_RESULT); \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
#define R_END_TRY_CATCH_WITH_ABORT_UNLESS \
|
||||
else { \
|
||||
#define R_END_TRY_CATCH_WITH_ABORT_UNLESS \
|
||||
else { \
|
||||
R_ABORT_UNLESS(R_CURRENT_RESULT); \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user