Readd jsregexp.{cpp,h} (and to users of the regex-statics save/restore methods) and nsJSEnvironment.{cpp,h} changes for bug 548702.

This commit is contained in:
Jeff Walden 2010-03-29 12:24:03 -07:00
Родитель ff258a8cb0
Коммит 8577d1493c
5 изменённых файлов: 22 добавлений и 22 удалений

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

@ -2108,15 +2108,11 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
return NS_OK;
}
jsval targetVal = JSVAL_VOID;
JSAutoTempValueRooter tvr(mContext, 1, &targetVal);
JSObject* target = nsnull;
nsresult rv = JSObjectFromInterface(aTarget, aScope, &target);
NS_ENSURE_SUCCESS(rv, rv);
targetVal = OBJECT_TO_JSVAL(target);
js::AutoObjectRooter targetVal(mContext, target);
jsval rval = JSVAL_VOID;
// This one's a lot easier than EvaluateString because we don't have to
@ -2140,7 +2136,7 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
jsval *argv = nsnull;
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<JSAutoTempValueRooter> tvr;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
// Use |target| as the scope for wrapping the arguments, since aScope is
// the safe scope in many cases, which isn't very useful. Wrapping aTarget
@ -2654,7 +2650,7 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg
JSAutoRequest ar(mContext);
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<JSAutoTempValueRooter> tvr;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
nsresult rv;
rv = ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc,
@ -2689,7 +2685,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<JSAutoTempValueRooter> &aRooter)
js::LazilyConstructed<js::AutoArrayRooter> &aRooter)
{
nsresult rv = NS_OK;

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

@ -49,8 +49,11 @@
class nsIXPConnectJSObjectHolder;
class nsAutoPoolRelease;
class JSAutoTempValueRooter;
namespace js { template <class> class LazilyConstructed; }
namespace js {
class AutoObjectRooter;
class AutoArrayRooter;
template <class> class LazilyConstructed;
}
class nsJSContext : public nsIScriptContext,
public nsIXPCScriptNotify
@ -215,7 +218,7 @@ protected:
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<JSAutoTempValueRooter> &aRooter);
js::LazilyConstructed<js::AutoArrayRooter> &aRooter);
nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv);

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

@ -5226,11 +5226,11 @@ js_InitRegExpStatics(JSContext *cx)
JS_FRIEND_API(void)
js_SaveAndClearRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
JSTempValueRooter *tvr)
AutoValueRooter *tvr)
{
*statics = cx->regExpStatics;
JS_PUSH_TEMP_ROOT_STRING(cx, statics->input, tvr);
if (statics->input)
tvr->setString(statics->input);
/*
* Prevent JS_ClearRegExpStatics from freeing moreParens, since we've only
* moved it elsewhere (into statics->moreParens).
@ -5241,12 +5241,11 @@ js_SaveAndClearRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
JS_FRIEND_API(void)
js_RestoreRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
JSTempValueRooter *tvr)
AutoValueRooter *tvr)
{
/* Clear/free any new JSRegExpStatics data before clobbering. */
JS_ClearRegExpStatics(cx);
cx->regExpStatics = *statics;
JS_POP_TEMP_ROOT(cx, tvr);
}
void
@ -5839,7 +5838,7 @@ js_NewRegExpObject(JSContext *cx, TokenStream *ts,
str = js_NewStringCopyN(cx, chars, length);
if (!str)
return NULL;
JSAutoTempValueRooter tvr(cx, str);
AutoValueRooter tvr(cx, str);
re = js_NewRegExp(cx, ts, str, flags, JS_FALSE);
if (!re)
return NULL;

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

@ -65,13 +65,15 @@ struct JSRegExpStatics {
JSSubString rightContext; /* input to right of last match (perl $') */
};
namespace js { class AutoValueRooter; }
extern JS_FRIEND_API(void)
js_SaveAndClearRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
JSTempValueRooter *tvr);
js::AutoValueRooter *tvr);
extern JS_FRIEND_API(void)
js_RestoreRegExpStatics(JSContext *cx, JSRegExpStatics *statics,
JSTempValueRooter *tvr);
js::AutoValueRooter *tvr);
/*
* This struct holds a bitmap representation of a class from a regexp.

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

@ -478,7 +478,7 @@ XPC_SJOW_DelProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
NS_STACK_CLASS class SafeCallGuard {
public:
SafeCallGuard(JSContext *cx, nsIPrincipal *principal)
: cx(cx) {
: cx(cx), tvr(cx) {
nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager();
if (ssm) {
// Note: We pass null as the target frame pointer because we know that
@ -517,7 +517,7 @@ public:
private:
JSContext *cx;
JSRegExpStatics statics;
JSTempValueRooter tvr;
js::AutoValueRooter tvr;
uint32 options;
JSStackFrame *fp;
};
@ -957,7 +957,7 @@ XPC_SJOW_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 the wrapper.
return XPCWrapper::CreateIteratorObj(cx, wrapperIter, obj, unsafeObj,