Readd ctypes, xpconnect, plugin, xpinstall, canvas, and typed array changes from bug 548702.

This commit is contained in:
Jeff Walden 2010-03-29 19:47:40 -07:00
Родитель c2dcd0b0c7
Коммит 36182c5d48
17 изменённых файлов: 79 добавлений и 81 удалений

Просмотреть файл

@ -68,7 +68,7 @@ nsICanvasRenderingContextWebGL_BufferData(JSContext *cx, uintN argc, jsval *vp)
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -134,7 +134,7 @@ nsICanvasRenderingContextWebGL_BufferSubData(JSContext *cx, uintN argc, jsval *v
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -204,7 +204,7 @@ nsICanvasRenderingContextWebGL_TexImage2D(JSContext *cx, uintN argc, jsval *vp)
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -306,7 +306,7 @@ nsICanvasRenderingContextWebGL_TexSubImage2D(JSContext *cx, uintN argc, jsval *v
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -407,7 +407,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv(JSContext *cx, uintN argc, js
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -427,7 +427,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv(JSContext *cx, uintN argc, js
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -477,7 +477,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv(JSContext *cx, uintN argc, js
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -497,7 +497,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv(JSContext *cx, uintN argc, js
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -547,7 +547,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv(JSContext *cx, uintN ar
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -571,7 +571,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv(JSContext *cx, uintN ar
JSObject *arg2 = JSVAL_TO_OBJECT(argv[2]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -618,7 +618,7 @@ helper_nsICanvasRenderingContextWebGL_VertexAttrib_x_fv(JSContext *cx, uintN arg
nsICanvasRenderingContextWebGL *self;
xpc_qsSelfRef selfref;
JSAutoTempValueRooter tvr(cx);
js::AutoValueRooter tvr(cx);
if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr, tvr.addr(), nsnull))
return JS_FALSE;
@ -638,7 +638,7 @@ helper_nsICanvasRenderingContextWebGL_VertexAttrib_x_fv(JSContext *cx, uintN arg
JSObject *arg1 = JSVAL_TO_OBJECT(argv[1]);
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -780,7 +780,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_iv_tn(JSContext *cx, JSObject *o
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -835,7 +835,7 @@ helper_nsICanvasRenderingContextWebGL_Uniform_x_fv_tn(JSContext *cx, JSObject *o
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;
@ -890,7 +890,7 @@ helper_nsICanvasRenderingContextWebGL_UniformMatrix_x_fv_tn(JSContext *cx, JSObj
return JSVAL_VOID;
}
JSAutoTempValueRooter obj_tvr(cx);
js::AutoValueRooter obj_tvr(cx);
js::TypedArray *wa = 0;

Просмотреть файл

@ -293,7 +293,7 @@ Function::Create(JSContext* aContext,
return NULL;
JSObject* fnObj = JS_GetFunctionObject(fn);
JSAutoTempValueRooter fnRoot(aContext, fnObj);
js::AutoObjectRooter fnRoot(aContext, fnObj);
// stash a pointer to self, which Function::Call will need at call time
if (!JS_SetReservedSlot(aContext, fnObj, SLOT_FUNCTION, PRIVATE_TO_JSVAL(self.get())))

Просмотреть файл

@ -1382,10 +1382,10 @@ js_IsTypedArray(JSObject *obj)
JS_FRIEND_API(JSObject *)
js_CreateArrayBuffer(JSContext *cx, jsuint nbytes)
{
JSAutoTempValueRooter tvr(cx);
AutoValueRooter tvr(cx);
js_NewNumberInRootedValue(cx, jsdouble(nbytes), tvr.addr());
JSAutoTempValueRooter rval(cx);
AutoValueRooter rval(cx);
if (!ArrayBuffer::class_constructor(cx, cx->globalObject,
1, tvr.addr(),
rval.addr()))
@ -1437,7 +1437,7 @@ js_CreateTypedArray(JSContext *cx, jsint atype, jsuint nelements)
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
jsval vals[2];
JSAutoTempValueRooter tvr(cx, 2, vals);
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
if (!js_NewNumberInRootedValue(cx, jsdouble(nelements), &vals[0]))
return NULL;
@ -1454,7 +1454,7 @@ js_CreateTypedArrayWithArray(JSContext *cx, jsint atype, JSObject *arrayArg)
JS_ASSERT(atype >= 0 && atype < TypedArray::TYPE_MAX);
jsval vals[2];
JSAutoTempValueRooter tvr(cx, 2, vals);
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
vals[0] = OBJECT_TO_JSVAL(arrayArg);
@ -1474,7 +1474,7 @@ js_CreateTypedArrayWithBuffer(JSContext *cx, jsint atype, JSObject *bufArg,
JS_ASSERT(length < 0 || byteoffset >= 0);
jsval vals[4];
JSAutoTempValueRooter tvr(cx, 4, vals);
AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vals), vals);
int argc = 1;
vals[0] = OBJECT_TO_JSVAL(bufArg);

Просмотреть файл

@ -40,7 +40,7 @@
#include "xpcprivate.h"
#include "nsDOMError.h"
#include "jsdbgapi.h"
#include "jscntxt.h" // For JSAutoTempValueRooter.
#include "jscntxt.h" // For js::AutoValueRooter.
#include "jsobj.h"
#include "XPCNativeWrapper.h"
#include "XPCWrapper.h"
@ -283,17 +283,16 @@ WrapObject(JSContext *cx, JSObject *parent, jsval v, jsval *vp)
*vp = OBJECT_TO_JSVAL(wrapperObj);
jsval exposedProps = JSVAL_VOID;
JSAutoTempValueRooter tvr(cx, 1, &exposedProps);
js::AutoValueRooter exposedProps(cx, JSVAL_VOID);
if (!GetExposedProperties(cx, JSVAL_TO_OBJECT(v), &exposedProps)) {
if (!GetExposedProperties(cx, JSVAL_TO_OBJECT(v), exposedProps.addr())) {
return JS_FALSE;
}
if (!JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sWrappedObjSlot, v) ||
!JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sFlagsSlot,
JSVAL_ZERO) ||
!JS_SetReservedSlot(cx, wrapperObj, sExposedPropsSlot, exposedProps)) {
!JS_SetReservedSlot(cx, wrapperObj, XPCWrapper::sFlagsSlot, JSVAL_ZERO) ||
!JS_SetReservedSlot(cx, wrapperObj, sExposedPropsSlot,
exposedProps.value())) {
return JS_FALSE;
}
@ -778,7 +777,7 @@ XPC_COW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
return nsnull;
}
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
js::AutoObjectRooter tvr(cx, wrapperIter);
// Initialize our COW.
jsval v = OBJECT_TO_JSVAL(wrappedObj);

Просмотреть файл

@ -40,7 +40,7 @@
#include "xpcprivate.h"
#include "nsDOMError.h"
#include "jsdbgapi.h"
#include "jscntxt.h" // For JSAutoTempValueRooter.
#include "jscntxt.h" // For js::AutoValueRooter.
#include "XPCWrapper.h"
#include "nsIDOMWindow.h"
#include "nsIDOMWindowCollection.h"
@ -830,7 +830,7 @@ GetUXPCObject(JSContext *cx, JSObject *obj)
return nsnull;
}
JSAutoTempValueRooter tvr(cx, uxpco);
js::AutoValueRooter tvr(cx, uxpco);
jsval wrappedObj, parentScope;
if (!JS_GetReservedSlot(cx, obj, sWrappedObjSlot, &wrappedObj) ||
@ -1206,7 +1206,7 @@ XPC_XOW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
return nsnull;
}
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
js::AutoObjectRooter tvr(cx, wrapperIter);
// Initialize our XOW.
jsval v = OBJECT_TO_JSVAL(wrappedObj);

Просмотреть файл

@ -1144,7 +1144,7 @@ XPC_NW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
return nsnull;
}
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
js::AutoObjectRooter tvr(cx, wrapperIter);
// Initialize our native wrapper.
XPCWrappedNative *wn = static_cast<XPCWrappedNative *>(JS_GetPrivate(cx, obj));

Просмотреть файл

@ -40,7 +40,7 @@
#include "xpcprivate.h"
#include "nsDOMError.h"
#include "jsdbgapi.h"
#include "jscntxt.h" // For JSAutoTempValueRooter.
#include "jscntxt.h" // For js::AutoValueRooter.
#include "XPCNativeWrapper.h"
#include "XPCWrapper.h"
@ -137,7 +137,7 @@ WrapObject(JSContext *cx, JSObject *parent, jsval v, jsval *vp)
}
*vp = OBJECT_TO_JSVAL(wrapperObj);
JSAutoTempValueRooter tvr(cx, *vp);
js::AutoValueRooter tvr(cx, *vp);
if (!JS_SetReservedSlot(cx, wrapperObj, sWrappedObjSlot, v) ||
!JS_SetReservedSlot(cx, wrapperObj, sFlagsSlot, JSVAL_ZERO)) {
@ -437,7 +437,7 @@ XPC_SOW_GetOrSetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp,
return JS_FALSE;
}
JSAutoTempValueRooter tvr(cx, 1, vp);
js::AutoArrayRooter tvr(cx, 1, vp);
JSObject *wrappedObj = GetWrappedObject(cx, obj);
if (!wrappedObj) {
@ -649,7 +649,7 @@ XPC_SOW_Iterator(JSContext *cx, JSObject *obj, JSBool keysonly)
return nsnull;
}
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
js::AutoValueRooter tvr(cx, OBJECT_TO_JSVAL(wrapperIter));
// Initialize our SOW.
jsval v = OBJECT_TO_JSVAL(wrappedObj);

Просмотреть файл

@ -153,8 +153,8 @@ IteratorNext(JSContext *cx, uintN argc, jsval *vp)
}
jsval vec[2] = { STRING_TO_JSVAL(str), v };
JSAutoTempValueRooter tvr(cx, 2, vec);
JSObject *array = JS_NewArrayObject(cx, 2, vec);
js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(vec), vec);
JSObject *array = JS_NewArrayObject(cx, JS_ARRAY_LENGTH(vec), vec);
if (!array) {
return JS_FALSE;
}
@ -192,7 +192,7 @@ CreateIteratorObj(JSContext *cx, JSObject *tempWrapper,
return nsnull;
}
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(iterObj));
js::AutoObjectRooter tvr(cx, iterObj);
// Do this sooner rather than later to avoid complications in
// IteratorFinalize.
@ -213,7 +213,7 @@ CreateIteratorObj(JSContext *cx, JSObject *tempWrapper,
// call enumerate, and then re-set the prototype. As we do this, we have
// to protec the temporary wrapper from garbage collection.
JSAutoTempValueRooter tvr(cx, tempWrapper);
js::AutoValueRooter tvr(cx, tempWrapper);
if (!JS_SetPrototype(cx, iterObj, wrapperObj) ||
!XPCWrapper::Enumerate(cx, iterObj, wrapperObj) ||
!JS_SetPrototype(cx, iterObj, tempWrapper)) {

Просмотреть файл

@ -835,7 +835,7 @@ def writeQuickStub(f, customMethodCalls, member, stubName, isSetter=False):
if isGetter:
pthisval = 'vp'
elif isSetter:
f.write(" JSAutoTempValueRooter tvr(cx);\n")
f.write(" js::AutoValueRooter tvr(cx);\n")
pthisval = 'tvr.addr()'
else:
pthisval = '&vp[1]' # as above, ok to overwrite vp[1]

Просмотреть файл

@ -1582,23 +1582,23 @@ XPCConvert::ConstructException(nsresult rv, const char* message,
/********************************/
class AutoExceptionRestorer : public JSAutoTempValueRooter
class AutoExceptionRestorer
{
public:
AutoExceptionRestorer(JSContext *cx, jsval v)
: JSAutoTempValueRooter(cx, v),
mVal(v)
: mContext(cx), tvr(cx, v)
{
JS_ClearPendingException(mContext);
}
~AutoExceptionRestorer()
{
JS_SetPendingException(mContext, mVal);
JS_SetPendingException(mContext, tvr.value());
}
private:
jsval mVal;
JSContext * const mContext;
js::AutoValueRooter tvr;
};
// static

Просмотреть файл

@ -173,7 +173,7 @@ GeneratePropertyOp(JSContext *cx, JSObject *obj, jsval idval, uintN argc,
JSObject *funobj = JS_GetFunctionObject(fun);
JSAutoTempValueRooter tvr(cx, OBJECT_TO_JSVAL(funobj));
js::AutoObjectRooter tvr(cx, funobj);
// Unfortunately, we cannot guarantee that JSPropertyOp is aligned. Use a
// second object to work around this.
@ -198,7 +198,7 @@ ReifyPropertyOps(JSContext *cx, JSObject *obj, jsval idval, jsid interned_id,
{
// Generate both getter and setter and stash them in the prototype.
jsval roots[2] = { JSVAL_NULL, JSVAL_NULL };
JSAutoTempValueRooter tvr(cx, 2, roots);
js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(roots), roots);
uintN attrs = JSPROP_SHARED;
JSObject *getterobj;

Просмотреть файл

@ -321,7 +321,7 @@ struct xpc_qsArgValArray
memset(array, 0, N * sizeof(jsval));
}
JSAutoTempValueRooter tvr;
js::AutoArrayRooter tvr;
jsval array[N];
};

Просмотреть файл

@ -1517,8 +1517,7 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
JSStackFrame *fp;
nsIPrincipal *principal = secMan->GetCxSubjectPrincipalAndFrame(cx, &fp);
jsval retval = OBJECT_TO_JSVAL(obj);
JSAutoTempValueRooter atvr(cx, 1, &retval);
js::AutoValueRooter retval(cx, obj);
if(principal && fp)
{
@ -1535,7 +1534,7 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
}
nsresult rv = xpc->GetWrapperForObject(cx, obj, scope, principal, flags,
&retval);
retval.addr());
if(NS_FAILED(rv))
{
XPCThrower::Throw(rv, cx);
@ -1543,7 +1542,7 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
}
}
return JSVAL_TO_OBJECT(retval);
return JSVAL_TO_OBJECT(retval.value());
}
JSObjectOps *

Просмотреть файл

@ -562,7 +562,7 @@ TestArgFormatter(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
// Prepare an array of arguments for JS_ConvertArguments
jsval argv[5];
JSAutoTempValueRooter tvr(jscontext, 5, argv);
js::AutoArrayRooter tvr(jscontext, JS_ARRAY_LENGTH(argv), argv);
if (!PushArguments(jscontext, 5, argv,
"s %ip %iv %is s",

Просмотреть файл

@ -673,35 +673,35 @@ doInvoke(NPObject *npobj, NPIdentifier method, const NPVariant *args,
}
}
JSTempValueRooter tvr;
JS_PUSH_TEMP_ROOT(cx, 0, jsargs, &tvr);
// Convert args
for (PRUint32 i = 0; i < argCount; ++i) {
jsargs[i] = NPVariantToJSVal(npp, cx, args + i);
++tvr.count;
}
jsval v;
JSBool ok;
if (ctorCall) {
JSObject *global = ::JS_GetGlobalForObject(cx, npjsobj->mJSObj);
JSObject *newObj =
::JS_ConstructObjectWithArguments(cx, JS_GET_CLASS(cx, npjsobj->mJSObj),
nsnull, global, argCount, jsargs);
{
js::AutoArrayRooter tvr(cx, 0, jsargs);
if (newObj) {
v = OBJECT_TO_JSVAL(newObj);
ok = JS_TRUE;
} else {
ok = JS_FALSE;
// Convert args
for (PRUint32 i = 0; i < argCount; ++i) {
jsargs[i] = NPVariantToJSVal(npp, cx, args + i);
tvr.changeLength(i + 1);
}
} else {
ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
}
JS_POP_TEMP_ROOT(cx, &tvr);
if (ctorCall) {
JSObject *global = ::JS_GetGlobalForObject(cx, npjsobj->mJSObj);
JSObject *newObj =
::JS_ConstructObjectWithArguments(cx, JS_GET_CLASS(cx, npjsobj->mJSObj),
nsnull, global, argCount, jsargs);
if (newObj) {
v = OBJECT_TO_JSVAL(newObj);
ok = JS_TRUE;
} else {
ok = JS_FALSE;
}
} else {
ok = ::JS_CallFunctionValue(cx, npjsobj->mJSObj, fv, argCount, jsargs, &v);
}
}
if (jsargs != jsargs_buf)
PR_Free(jsargs);
@ -837,7 +837,7 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier identifier,
AutoJSExceptionReporter reporter(cx);
jsval v = NPVariantToJSVal(npp, cx, value);
JSAutoTempValueRooter tvr(cx, v);
js::AutoValueRooter tvr(cx, v);
if (JSVAL_IS_STRING(id)) {
JSString *str = JSVAL_TO_STRING(id);

Просмотреть файл

@ -1698,7 +1698,7 @@ _evaluate(NPP npp, NPObject* npobj, NPString *script, NPVariant *result)
// Root obj and the rval (below).
jsval vec[] = { OBJECT_TO_JSVAL(obj), JSVAL_NULL };
JSAutoTempValueRooter tvr(cx, NS_ARRAY_LENGTH(vec), vec);
js::AutoArrayRooter tvr(cx, NS_ARRAY_LENGTH(vec), vec);
jsval *rval = &vec[1];
if (result) {

Просмотреть файл

@ -247,7 +247,7 @@ XPITriggerEvent::Run()
// Build arguments into rooted jsval array
jsval args[2] = { JSVAL_NULL, JSVAL_NULL };
JSAutoTempValueRooter tvr(cx, JS_ARRAY_LENGTH(args), args);
js::AutoArrayRooter tvr(cx, JS_ARRAY_LENGTH(args), args);
// args[0] is the URL
JSString *str = JS_NewUCStringCopyZ(cx, reinterpret_cast<const jschar*>(URL.get()));