mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781070 - make NullPtr public r=terrence
--HG-- extra : rebase_source : d59f24956708178c310cfca220bfd77d237e8f19
This commit is contained in:
parent
cc0fdd5b0d
commit
95b5365899
@ -118,6 +118,24 @@ class HandleBase {};
|
||||
template <typename T>
|
||||
class MutableHandleBase {};
|
||||
|
||||
/*
|
||||
* js::NullPtr acts like a NULL pointer in contexts that require a Handle.
|
||||
*
|
||||
* Handle provides an implicit constructor for js::NullPtr so that, given:
|
||||
* foo(Handle<JSObject*> h);
|
||||
* callers can simply write:
|
||||
* foo(js::NullPtr());
|
||||
* which avoids creating a Rooted<JSObject*> just to pass NULL.
|
||||
*
|
||||
* This is the SpiderMonkey internal variant. js::NullPtr should be used in
|
||||
* preference to JS::NullPtr to avoid the GOT access required for JS_PUBLIC_API
|
||||
* symbols.
|
||||
*/
|
||||
struct NullPtr
|
||||
{
|
||||
static void * const constNullValue;
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
namespace JS {
|
||||
@ -136,13 +154,15 @@ CheckStackRoots(JSContext *cx);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Handle provides an implicit constructor for NullPtr so that, given:
|
||||
* JS::NullPtr acts like a NULL pointer in contexts that require a Handle.
|
||||
*
|
||||
* Handle provides an implicit constructor for JS::NullPtr so that, given:
|
||||
* foo(Handle<JSObject*> h);
|
||||
* callers can simply write:
|
||||
* foo(NullPtr());
|
||||
* foo(JS::NullPtr());
|
||||
* which avoids creating a Rooted<JSObject*> just to pass NULL.
|
||||
*/
|
||||
struct NullPtr
|
||||
struct JS_PUBLIC_API(NullPtr)
|
||||
{
|
||||
static void * const constNullValue;
|
||||
};
|
||||
@ -170,9 +190,15 @@ class Handle : public js::HandleBase<T>
|
||||
}
|
||||
|
||||
/* Create a handle for a NULL pointer. */
|
||||
Handle(NullPtr) {
|
||||
Handle(js::NullPtr) {
|
||||
typedef typename js::tl::StaticAssert<mozilla::IsPointer<T>::value>::result _;
|
||||
ptr = reinterpret_cast<const T *>(&NullPtr::constNullValue);
|
||||
ptr = reinterpret_cast<const T *>(&js::NullPtr::constNullValue);
|
||||
}
|
||||
|
||||
/* Create a handle for a NULL pointer. */
|
||||
Handle(JS::NullPtr) {
|
||||
typedef typename js::tl::StaticAssert<mozilla::IsPointer<T>::value>::result _;
|
||||
ptr = reinterpret_cast<const T *>(&JS::NullPtr::constNullValue);
|
||||
}
|
||||
|
||||
Handle(MutableHandle<T> handle) {
|
||||
@ -353,7 +379,7 @@ class InternalHandle<T*>
|
||||
* fromMarkedLocation().
|
||||
*/
|
||||
InternalHandle(T *field)
|
||||
: holder(reinterpret_cast<void * const *>(&JS::NullPtr::constNullValue)),
|
||||
: holder(reinterpret_cast<void * const *>(&js::NullPtr::constNullValue)),
|
||||
offset(uintptr_t(field))
|
||||
{}
|
||||
};
|
||||
|
@ -27,6 +27,8 @@ using mozilla::DebugOnly;
|
||||
|
||||
void * const js::NullPtr::constNullValue = NULL;
|
||||
|
||||
JS_PUBLIC_DATA(void * const) JS::NullPtr::constNullValue = NULL;
|
||||
|
||||
/*
|
||||
* There are two mostly separate mark paths. The first is a fast path used
|
||||
* internally in the GC. The second is a slow path used for root marking and
|
||||
|
@ -5028,8 +5028,6 @@ using JS::MutableHandleString;
|
||||
using JS::MutableHandleId;
|
||||
using JS::MutableHandleValue;
|
||||
|
||||
using JS::NullPtr; /* To be removed by bug 781070. */
|
||||
|
||||
using JS::Zone;
|
||||
|
||||
} /* namespace js */
|
||||
|
@ -263,7 +263,7 @@ struct JSCompartment
|
||||
/* Mark cross-compartment wrappers. */
|
||||
void markCrossCompartmentWrappers(JSTracer *trc);
|
||||
|
||||
bool wrap(JSContext *cx, JS::MutableHandleValue vp, JS::HandleObject existing = JS::NullPtr());
|
||||
bool wrap(JSContext *cx, JS::MutableHandleValue vp, JS::HandleObject existing = js::NullPtr());
|
||||
bool wrap(JSContext *cx, JSString **strp);
|
||||
bool wrap(JSContext *cx, js::HeapPtrString *strp);
|
||||
bool wrap(JSContext *cx, JSObject **objp, JSObject *existing = NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user