Bug 677079 - Part x: Move AutoValueVector to jsapi.h; r=evilpie

This commit is contained in:
Ms2ger 2012-01-15 09:13:11 +01:00
parent bcf6141336
commit 93d155a6e0
4 changed files with 22 additions and 34 deletions

View File

@ -1106,6 +1106,19 @@ class AutoVectorRooter : protected AutoGCRooter
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class AutoValueVector : public AutoVectorRooter<Value>
{
public:
explicit AutoValueVector(JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoVectorRooter<Value>(cx, VALVECTOR)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
}
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
} /* namespace JS */
/************************************************************************/

View File

@ -2073,25 +2073,6 @@ SetValueRangeToNull(Value *vec, size_t len)
SetValueRangeToNull(vec, vec + len);
}
class AutoValueVector : public AutoVectorRooter<Value>
{
public:
explicit AutoValueVector(JSContext *cx
JS_GUARD_OBJECT_NOTIFIER_PARAM)
: AutoVectorRooter<Value>(cx, VALVECTOR)
{
JS_GUARD_OBJECT_NOTIFIER_INIT;
}
const jsval *jsval_begin() const { return begin(); }
jsval *jsval_begin() { return begin(); }
const jsval *jsval_end() const { return end(); }
jsval *jsval_end() { return end(); }
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class AutoObjectVector : public AutoVectorRooter<JSObject *>
{
public:

View File

@ -1310,7 +1310,6 @@ struct WrapperHasher
typedef HashMap<Value, Value, WrapperHasher, SystemAllocPolicy> WrapperMap;
class AutoValueVector;
class AutoIdVector;
} /* namespace js */

View File

@ -49,7 +49,7 @@
#include "AccessCheck.h"
#include "nsJSUtils.h"
#include "jscntxt.h" // js::AutoValueVector
#include "jsapi.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsXPCWrappedJSClass, nsIXPCWrappedJSClass)
@ -1173,20 +1173,14 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
jsval* sp = nsnull;
jsval* argv = nsnull;
uint8_t i;
uint8_t argc=0;
uint8_t paramCount=0;
nsresult retval = NS_ERROR_FAILURE;
nsresult pending_result = NS_OK;
JSBool success;
JSBool readyToDoTheCall = false;
nsID param_iid;
JSObject* obj;
const char* name = info->name;
jsval fval;
JSBool foundDependentParam;
XPCContext* xpcc;
JSContext* cx;
JSObject* thisObj;
// Make sure not to set the callee on ccx until after we've gone through
// the whole nsIXPCFunctionThisTranslator bit. That code uses ccx to
@ -1197,13 +1191,14 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
if (!ccx.IsValid())
return retval;
xpcc = ccx.GetXPCContext();
cx = ccx.GetJSContext();
XPCContext *xpcc = ccx.GetXPCContext();
JSContext *cx = ccx.GetJSContext();
if (!cx || !xpcc || !IsReflectable(methodIndex))
return NS_ERROR_FAILURE;
obj = thisObj = wrapper->GetJSObject();
JSObject *obj = wrapper->GetJSObject();
JSObject *thisObj = obj;
JSAutoEnterCompartment ac;
if (!ac.enter(cx, obj))
@ -1211,13 +1206,13 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
ccx.SetScopeForNewJSObjects(obj);
js::AutoValueVector args(cx);
JS::AutoValueVector args(cx);
AutoScriptEvaluate scriptEval(cx);
ContextPrincipalGuard principalGuard(ccx);
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
paramCount = info->num_args;
argc = paramCount -
uint8_t paramCount = info->num_args;
uint8_t argc = paramCount -
(paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);
if (!scriptEval.StartEvaluating(obj, xpcWrappedJSErrorReporter))
@ -1353,7 +1348,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
goto pre_call_clean_up;
}
argv = args.jsval_begin();
argv = args.begin();
sp = argv;
// build the args