mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-27 19:07:31 +09:00
Issue #2304 - Part 1 - Prerequisite: Make Handle<Maybe<>> more convenient. This is required to implement JS::NothingHandleValue. https://bugzilla.mozilla.org/show_bug.cgi?id=1631114
This commit is contained in:
parent
1489a6f8b5
commit
3c9bbc9665
3 changed files with 31 additions and 0 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
|
|
@ -1278,6 +1279,33 @@ class MutableWrappedPtrOperations<UniquePtr<T, D>, Container>
|
|||
void reset(T* ptr = T()) { uniquePtr().reset(ptr); }
|
||||
};
|
||||
|
||||
template <typename T, typename Container>
|
||||
class WrappedPtrOperations<mozilla::Maybe<T>, Container> {
|
||||
const mozilla::Maybe<T>& maybe() const {
|
||||
return static_cast<const Container*>(this)->get();
|
||||
}
|
||||
|
||||
public:
|
||||
// This only supports a subset of Maybe's interface.
|
||||
bool isSome() const { return maybe().isSome(); }
|
||||
bool isNothing() const { return maybe().isNothing(); }
|
||||
const T value() const { return maybe().value(); }
|
||||
const T* operator->() const { return maybe().ptr(); }
|
||||
const T& operator*() const { return maybe().ref(); }
|
||||
};
|
||||
|
||||
template <typename T, typename Container>
|
||||
class MutableWrappedPtrOperations<mozilla::Maybe<T>, Container>
|
||||
: public WrappedPtrOperations<mozilla::Maybe<T>, Container> {
|
||||
mozilla::Maybe<T>& maybe() { return static_cast<Container*>(this)->get(); }
|
||||
|
||||
public:
|
||||
// This only supports a subset of Maybe's interface.
|
||||
T* operator->() { return maybe().ptr(); }
|
||||
T& operator*() { return maybe().ref(); }
|
||||
void reset() { return maybe().reset(); }
|
||||
};
|
||||
|
||||
namespace gc {
|
||||
|
||||
template <typename T, typename TraceCallbacks>
|
||||
|
|
|
|||
|
|
@ -1535,6 +1535,7 @@ extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue;
|
|||
extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue;
|
||||
extern JS_PUBLIC_DATA(const HandleValue) TrueHandleValue;
|
||||
extern JS_PUBLIC_DATA(const HandleValue) FalseHandleValue;
|
||||
extern JS_PUBLIC_DATA(const Handle<mozilla::Maybe<Value>>) NothingHandleValue;
|
||||
|
||||
} // namespace JS
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ static const JS::Value JSVAL_NULL = JS::Value::fromTagAndPayload(JSVAL_TAG_NULL
|
|||
static const JS::Value JSVAL_FALSE = JS::Value::fromTagAndPayload(JSVAL_TAG_BOOLEAN, false);
|
||||
static const JS::Value JSVAL_TRUE = JS::Value::fromTagAndPayload(JSVAL_TAG_BOOLEAN, true);
|
||||
static const JS::Value JSVAL_VOID = JS::Value::fromTagAndPayload(JSVAL_TAG_UNDEFINED, 0);
|
||||
static const mozilla::Maybe<JS::Value> JSVAL_NOTHING;
|
||||
|
||||
namespace JS {
|
||||
|
||||
|
|
@ -16,5 +17,6 @@ const HandleValue NullHandleValue = HandleValue::fromMarkedLocation(&JSVAL_NULL)
|
|||
const HandleValue UndefinedHandleValue = HandleValue::fromMarkedLocation(&JSVAL_VOID);
|
||||
const HandleValue TrueHandleValue = HandleValue::fromMarkedLocation(&JSVAL_TRUE);
|
||||
const HandleValue FalseHandleValue = HandleValue::fromMarkedLocation(&JSVAL_FALSE);
|
||||
const Handle<mozilla::Maybe<Value>> NothingHandleValue = Handle<mozilla::Maybe<Value>>::fromMarkedLocation(&JSVAL_NOTHING);
|
||||
|
||||
} // namespace JS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue