summaryrefslogtreecommitdiff
path: root/js/public
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-02-04 01:44:41 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-19 17:38:02 +0000
commit185a027640f9b18c97eda39a49bfa2dcce58fcdb (patch)
treed29b146d37f0f831ec981316da778c91fd77be8a /js/public
parent99ec088ecf1259643f6124206af024de3ebc49ad (diff)
downloaduxp-185a027640f9b18c97eda39a49bfa2dcce58fcdb.tar.gz
Issue #1877 - Resolve RELEASE_OR_BETA conditionals.
Diffstat (limited to 'js/public')
-rw-r--r--js/public/Class.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/js/public/Class.h b/js/public/Class.h
index 094e4a7ed7..6f1960a308 100644
--- a/js/public/Class.h
+++ b/js/public/Class.h
@@ -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();