mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1325073 - Rename mozilla::MakeGenericErrorResult to mozilla::Err. r=Waldo
This commit is contained in:
parent
2cbcc06b8b
commit
dccaffb213
@ -8,7 +8,6 @@
|
||||
#define jit_Ion_h
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/Result.h"
|
||||
|
||||
#include "jscntxt.h"
|
||||
@ -41,19 +40,9 @@ enum class AbortReason : uint8_t {
|
||||
|
||||
template <typename V>
|
||||
using AbortReasonOr = mozilla::Result<V, AbortReason>;
|
||||
using mozilla::Err;
|
||||
using mozilla::Ok;
|
||||
|
||||
// This is the equivalent of the following, except that these are functions and
|
||||
// not types, which makes this syntax invalid:
|
||||
// using Err = mozilla::MakeGenericErrorResult;
|
||||
template <typename E>
|
||||
inline mozilla::GenericErrorResult<E>
|
||||
Err(E&& aErrorValue)
|
||||
{
|
||||
return mozilla::MakeGenericErrorResult(mozilla::Forward<E>(aErrorValue));
|
||||
}
|
||||
|
||||
|
||||
static_assert(sizeof(AbortReasonOr<Ok>) <= sizeof(uintptr_t),
|
||||
"Unexpected size of AbortReasonOr<Ok>");
|
||||
static_assert(sizeof(AbortReasonOr<bool>) <= sizeof(uintptr_t),
|
||||
|
@ -1118,7 +1118,7 @@ JSContext::alreadyReportedOOM()
|
||||
MOZ_ASSERT(isThrowingOutOfMemory());
|
||||
}
|
||||
#endif
|
||||
return mozilla::MakeGenericErrorResult(reportedOOM);
|
||||
return mozilla::Err(reportedOOM);
|
||||
}
|
||||
|
||||
mozilla::GenericErrorResult<JS::Error&>
|
||||
@ -1128,7 +1128,7 @@ JSContext::alreadyReportedError()
|
||||
if (!helperThread())
|
||||
MOZ_ASSERT(isExceptionPending());
|
||||
#endif
|
||||
return mozilla::MakeGenericErrorResult(reportedError);
|
||||
return mozilla::Err(reportedError);
|
||||
}
|
||||
|
||||
JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options)
|
||||
|
@ -401,7 +401,7 @@ public:
|
||||
|
||||
template <typename E>
|
||||
inline GenericErrorResult<E>
|
||||
MakeGenericErrorResult(E&& aErrorValue)
|
||||
Err(E&& aErrorValue)
|
||||
{
|
||||
return GenericErrorResult<E>(aErrorValue);
|
||||
}
|
||||
@ -418,7 +418,7 @@ MakeGenericErrorResult(E&& aErrorValue)
|
||||
do { \
|
||||
auto mozTryTempResult_ = (expr); \
|
||||
if (mozTryTempResult_.isErr()) { \
|
||||
return ::mozilla::MakeGenericErrorResult(mozTryTempResult_.unwrapErr()); \
|
||||
return ::mozilla::Err(mozTryTempResult_.unwrapErr()); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@ -433,7 +433,7 @@ MakeGenericErrorResult(E&& aErrorValue)
|
||||
do { \
|
||||
auto mozTryVarTempResult_ = (expr); \
|
||||
if (mozTryVarTempResult_.isErr()) { \
|
||||
return ::mozilla::MakeGenericErrorResult( \
|
||||
return ::mozilla::Err( \
|
||||
mozTryVarTempResult_.unwrapErr()); \
|
||||
} \
|
||||
(target) = mozTryVarTempResult_.unwrap(); \
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <string.h>
|
||||
#include "mozilla/Result.h"
|
||||
|
||||
using mozilla::Err;
|
||||
using mozilla::GenericErrorResult;
|
||||
using mozilla::MakeGenericErrorResult;
|
||||
using mozilla::Ok;
|
||||
using mozilla::Result;
|
||||
|
||||
@ -52,7 +52,7 @@ static GenericErrorResult<Failed&>
|
||||
Fail()
|
||||
{
|
||||
static Failed failed;
|
||||
return MakeGenericErrorResult<Failed&>(failed);
|
||||
return Err<Failed&>(failed);
|
||||
}
|
||||
|
||||
static Result<Ok, Failed&>
|
||||
@ -131,7 +131,7 @@ BasicTests()
|
||||
MOZ_RELEASE_ASSERT(res.isOk());
|
||||
MOZ_RELEASE_ASSERT(*res.unwrap() == 123);
|
||||
|
||||
res = MakeGenericErrorResult(d);
|
||||
res = Err(d);
|
||||
MOZ_RELEASE_ASSERT(res.isErr());
|
||||
MOZ_RELEASE_ASSERT(&res.unwrapErr() == &d);
|
||||
MOZ_RELEASE_ASSERT(res.unwrapErr() == 3.14);
|
||||
@ -147,7 +147,7 @@ static Result<Ok, Snafu*>
|
||||
Explode()
|
||||
{
|
||||
static Snafu snafu;
|
||||
return MakeGenericErrorResult(&snafu);
|
||||
return Err(&snafu);
|
||||
}
|
||||
|
||||
static Result<Ok, Failed*>
|
||||
|
Loading…
Reference in New Issue
Block a user