Bug 1325073 - Rename mozilla::MakeGenericErrorResult to mozilla::Err. r=Waldo

This commit is contained in:
Nicolas B. Pierron 2017-03-08 13:33:07 +00:00
parent 2cbcc06b8b
commit dccaffb213
4 changed files with 10 additions and 21 deletions

View File

@ -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),

View File

@ -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)

View File

@ -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(); \

View File

@ -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*>