Issue #1877 - Resolve RELEASE_OR_BETA conditionals.

This commit is contained in:
Moonchild 2022-02-04 01:44:41 +00:00 • committed by roytam1
commit d4eac725fd
30 changed files with 75 additions and 144 deletions

View file

@ -131,16 +131,24 @@ class ObjectOpResult
Uninitialized = uintptr_t(-1)
};
static const uintptr_t SoftFailBit = uintptr_t(1) << (sizeof(uintptr_t) * 8 - 1);
ObjectOpResult() : code_(Uninitialized) {}
/* Return true if succeed() was called. */
/* Return true if succeed() or failSoft() was called. */
bool ok() const {
MOZ_ASSERT(code_ != Uninitialized);
return code_ == OkCode;
return code_ == OkCode || (code_ & SoftFailBit);
}
explicit operator bool() const { return ok(); }
/* Return true if succeed() was called. */
bool confirmOk() const {
MOZ_ASSERT(code_ != Uninitialized);
return code_ == OkCode;
}
/* Set this ObjectOpResult to true and return true. */
bool succeed() {
code_ = OkCode;
@ -160,10 +168,26 @@ class ObjectOpResult
*/
bool fail(uint32_t msg) {
MOZ_ASSERT(msg != OkCode);
MOZ_ASSERT((msg & SoftFailBit) == 0);
code_ = msg;
return true;
}
/*
* DEPRECATED: This is a non-standard compatibility hack.
*
* Set this ObjectOpResult to true, but remembers an error code.
* This is used for situations where we really want to fail,
* but can't for legacy reasons.
*
* Always returns true, as a convenience.
*/
bool failSoft(uint32_t msg) {
// The msg code is currently never extracted again.
code_ = msg | SoftFailBit;
return true;
}
JS_PUBLIC_API(bool) failCantRedefineProp();
JS_PUBLIC_API(bool) failReadOnly();
JS_PUBLIC_API(bool) failGetterOnly();