Bug 332648 - Part e: Move AutoArrayRooter to jsapi.h; r=evilpie

This commit is contained in:
Ms2ger 2012-01-11 09:23:09 +01:00
parent 44ec0553bc
commit 776fd33214
8 changed files with 33 additions and 37 deletions

View File

@ -231,7 +231,7 @@ private:
}
nsAutoTArray<jsval, 16> vals;
js::AutoArrayRooter avr;
JS::AutoArrayRooter avr;
};
/****************************************************************

View File

@ -49,9 +49,6 @@
class nsIXPConnectJSObjectHolder;
class nsRootedJSValueArray;
class nsScriptNameSpaceManager;
namespace js {
class AutoArrayRooter;
}
namespace mozilla {
template <class> class Maybe;
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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 */
/************************************************************************/

View File

@ -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:

View File

@ -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

View File

@ -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;