mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 839376 (part 14) - More exact rooting in shell/js.cpp. r=sfink.
--HG-- extra : rebase_source : 5dbacfb158ff5ea3935c0378f1c691006cb013a8
This commit is contained in:
parent
43ae09558d
commit
ac52e6f319
@ -209,15 +209,14 @@ class ToStringHelper
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ToStringHelper(JSContext *aCx, jsval v, bool aThrow = false)
|
ToStringHelper(JSContext *aCx, jsval v, bool aThrow = false)
|
||||||
: cx(aCx)
|
: cx(aCx), mStr(cx, JS_ValueToString(cx, v))
|
||||||
{
|
{
|
||||||
mStr = JS_ValueToString(cx, v);
|
|
||||||
if (!aThrow && !mStr)
|
if (!aThrow && !mStr)
|
||||||
ReportException(cx);
|
ReportException(cx);
|
||||||
JS_AddNamedStringRoot(cx, &mStr, "Value ToString helper");
|
JS_AddNamedStringRoot(cx, mStr.address(), "Value ToString helper");
|
||||||
}
|
}
|
||||||
~ToStringHelper() {
|
~ToStringHelper() {
|
||||||
JS_RemoveStringRoot(cx, &mStr);
|
JS_RemoveStringRoot(cx, mStr.address());
|
||||||
}
|
}
|
||||||
bool threw() { return !mStr; }
|
bool threw() { return !mStr; }
|
||||||
jsval getJSVal() { return STRING_TO_JSVAL(mStr); }
|
jsval getJSVal() { return STRING_TO_JSVAL(mStr); }
|
||||||
@ -228,7 +227,7 @@ class ToStringHelper
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
JSContext *cx;
|
JSContext *cx;
|
||||||
JSString *mStr;
|
RootedString mStr; // Objects of this class are always stack-allocated.
|
||||||
JSAutoByteString mBytes;
|
JSAutoByteString mBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -357,8 +356,8 @@ ShellOperationCallback(JSContext *cx)
|
|||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
if (!gTimeoutFunc.isNull()) {
|
if (!gTimeoutFunc.isNull()) {
|
||||||
jsval returnedValue;
|
RootedValue returnedValue(cx);
|
||||||
if (!JS_CallFunctionValue(cx, NULL, gTimeoutFunc, 0, NULL, &returnedValue))
|
if (!JS_CallFunctionValue(cx, NULL, gTimeoutFunc, 0, NULL, returnedValue.address()))
|
||||||
return false;
|
return false;
|
||||||
if (returnedValue.isBoolean())
|
if (returnedValue.isBoolean())
|
||||||
result = returnedValue.toBoolean();
|
result = returnedValue.toBoolean();
|
||||||
@ -1740,8 +1739,8 @@ TryNotes(JSContext *cx, HandleScript script, Sprinter *sp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
DisassembleScript(JSContext *cx, HandleScript script, JSFunction *fun, bool lines, bool recursive,
|
DisassembleScript(JSContext *cx, HandleScript script, HandleFunction fun, bool lines,
|
||||||
Sprinter *sp)
|
bool recursive, Sprinter *sp)
|
||||||
{
|
{
|
||||||
if (fun) {
|
if (fun) {
|
||||||
Sprint(sp, "flags:");
|
Sprint(sp, "flags:");
|
||||||
@ -1910,7 +1909,7 @@ DisassFile(JSContext *cx, unsigned argc, jsval *vp)
|
|||||||
Sprinter sprinter(cx);
|
Sprinter sprinter(cx);
|
||||||
if (!sprinter.init())
|
if (!sprinter.init())
|
||||||
return false;
|
return false;
|
||||||
bool ok = DisassembleScript(cx, script, NULL, p.lines, p.recursive, &sprinter);
|
bool ok = DisassembleScript(cx, script, NullPtr(), p.lines, p.recursive, &sprinter);
|
||||||
if (ok)
|
if (ok)
|
||||||
fprintf(stdout, "%s\n", sprinter.string());
|
fprintf(stdout, "%s\n", sprinter.string());
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
Loading…
Reference in New Issue
Block a user