mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 332648 - Part e: Move AutoArrayRooter to jsapi.h; r=evilpie
This commit is contained in:
parent
44ec0553bc
commit
776fd33214
@ -231,7 +231,7 @@ private:
|
||||
}
|
||||
|
||||
nsAutoTArray<jsval, 16> vals;
|
||||
js::AutoArrayRooter avr;
|
||||
JS::AutoArrayRooter avr;
|
||||
};
|
||||
|
||||
/****************************************************************
|
||||
|
@ -49,9 +49,6 @@
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsRootedJSValueArray;
|
||||
class nsScriptNameSpaceManager;
|
||||
namespace js {
|
||||
class AutoArrayRooter;
|
||||
}
|
||||
namespace mozilla {
|
||||
template <class> class Maybe;
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
|
||||
JSBool ok;
|
||||
|
||||
{
|
||||
js::AutoArrayRooter tvr(cx, 0, jsargs);
|
||||
JS::AutoArrayRooter tvr(cx, 0, jsargs);
|
||||
|
||||
// Convert args
|
||||
for (PRUint32 i = 0; i < argCount; ++i) {
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "prenv.h"
|
||||
#include "prclist.h"
|
||||
|
||||
#include "jscntxt.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "nsPluginHost.h"
|
||||
@ -1652,7 +1651,7 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
|
||||
|
||||
// Root obj and the rval (below).
|
||||
jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
|
||||
js::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
|
||||
JS::AutoArrayRooter tvr(cx, ArrayLength(vec), vec);
|
||||
jsval *rval = &vec[1];
|
||||
|
||||
if (result) {
|
||||
|
@ -975,6 +975,34 @@ class AutoStringRooter : private AutoGCRooter {
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoArrayRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoArrayRooter(JSContext *cx, size_t len, Value *vec
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, len), array(vec)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeLength(size_t newLength) {
|
||||
tag = ptrdiff_t(newLength);
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeArray(Value *newArray, size_t newLength) {
|
||||
changeLength(newLength);
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
Value *array;
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
} /* namespace JS */
|
||||
|
||||
/************************************************************************/
|
||||
|
@ -1598,34 +1598,6 @@ typedef RootedVar<jsid> RootedVarId;
|
||||
typedef RootedVar<Value> RootedVarValue;
|
||||
|
||||
/* FIXME(bug 332648): Move this into a public header. */
|
||||
class AutoArrayRooter : private AutoGCRooter {
|
||||
public:
|
||||
AutoArrayRooter(JSContext *cx, size_t len, Value *vec
|
||||
JS_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: AutoGCRooter(cx, len), array(vec)
|
||||
{
|
||||
JS_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeLength(size_t newLength) {
|
||||
tag = ptrdiff_t(newLength);
|
||||
JS_ASSERT(tag >= 0);
|
||||
}
|
||||
|
||||
void changeArray(Value *newArray, size_t newLength) {
|
||||
changeLength(newLength);
|
||||
array = newArray;
|
||||
}
|
||||
|
||||
Value *array;
|
||||
|
||||
friend void AutoGCRooter::trace(JSTracer *trc);
|
||||
|
||||
private:
|
||||
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
class AutoIdRooter : private AutoGCRooter
|
||||
{
|
||||
public:
|
||||
|
@ -2050,7 +2050,7 @@ AutoGCRooter::trace(JSTracer *trc)
|
||||
|
||||
JS_ASSERT(tag >= 0);
|
||||
MarkRootRange(trc, tag, static_cast<AutoArrayRooter *>(this)->array,
|
||||
"js::AutoArrayRooter.array");
|
||||
"JS::AutoArrayRooter.array");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -216,7 +216,7 @@ ReifyPropertyOps(JSContext *cx, JSObject *obj, jsid id, uintN orig_attrs,
|
||||
{
|
||||
// Generate both getter and setter and stash them in the prototype.
|
||||
jsval roots[2] = { JSVAL_NULL, JSVAL_NULL };
|
||||
js::AutoArrayRooter tvr(cx, ArrayLength(roots), roots);
|
||||
JS::AutoArrayRooter tvr(cx, ArrayLength(roots), roots);
|
||||
|
||||
uintN attrs = JSPROP_SHARED | (orig_attrs & JSPROP_ENUMERATE);
|
||||
JSObject *getterobj;
|
||||
|
Loading…
Reference in New Issue
Block a user