bug 724310 - drop cx argument from JSObject field and fixed slots infallible API. r=:Waldo

This commit is contained in:
Igor Bukanov
2012-02-05 21:07:23 +01:00
parent 5df21bd1f7
commit 6fefb1df81
64 changed files with 1000 additions and 1310 deletions

View File

@@ -414,11 +414,11 @@ static void
CPOW_NewEnumerateState_Finalize(JSContext* cx, JSObject* state)
{
nsTArray<nsString>* strIds =
static_cast<nsTArray<nsString>*>(JS_GetPrivate(cx, state));
static_cast<nsTArray<nsString>*>(JS_GetPrivate(state));
if (strIds) {
delete strIds;
JS_SetPrivate(cx, state, NULL);
JS_SetPrivate(state, NULL);
}
}
@@ -452,7 +452,7 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
for (JSObject* proto = mObj;
proto;
proto = JS_GetPrototype(cx, proto))
proto = JS_GetPrototype(proto))
{
AutoIdArray ids(cx, JS_Enumerate(cx, proto));
for (size_t i = 0; i < ids.length(); ++i)
@@ -474,10 +474,10 @@ ObjectWrapperChild::AnswerNewEnumerateInit(/* no in-parameters */
}
*idp = strIds->Length();
*status = (JS_SetPrivate(cx, state, strIds) &&
JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
JSVAL_ZERO) &&
JSObject_to_JSVariant(cx, state, statep));
JS_SetPrivate(state, strIds);
JS_SetReservedSlot(state, sNextIdIndexSlot, JSVAL_ZERO);
*status = JSObject_to_JSVariant(cx, state, statep);
return true;
}
@@ -487,7 +487,6 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
OperationStatus* status, JSVariant* statep, nsString* idp)
{
JSObject* state;
jsval v;
*statep = in_state;
idp->Truncate();
@@ -500,11 +499,13 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
return false;
InfallibleTArray<nsString>* strIds =
static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(cx, state));
static_cast<InfallibleTArray<nsString>*>(JS_GetPrivate(state));
if (!strIds || !JS_GetReservedSlot(cx, state, sNextIdIndexSlot, &v))
if (!strIds)
return false;
jsval v = JS_GetReservedSlot(state, sNextIdIndexSlot);
jsuint i = JSVAL_TO_INT(v);
NS_ASSERTION(i >= 0, "Index of next jsid negative?");
NS_ASSERTION(i <= strIds->Length(), "Index of next jsid too large?");
@@ -515,8 +516,8 @@ ObjectWrapperChild::AnswerNewEnumerateNext(const JSVariant& in_state,
}
*idp = strIds->ElementAt(i);
*status = JS_SetReservedSlot(cx, state, sNextIdIndexSlot,
INT_TO_JSVAL(i + 1));
JS_SetReservedSlot(state, sNextIdIndexSlot, INT_TO_JSVAL(i + 1));
*status = JS_TRUE;
return true;
}