Bug 1143793 part 1. Remove the obj argument of JS_CompileScript. r=luke

This commit is contained in:
Boris Zbarsky 2015-03-19 10:13:33 -04:00
parent 988b8e01be
commit 730e1cc79d
9 changed files with 17 additions and 20 deletions

View File

@ -375,8 +375,7 @@ XPCShellEnvironment::ProcessFile(JSContext *cx,
JS::CompileOptions options(cx);
options.setFileAndLine("typein", startline);
JS::Rooted<JSScript*> script(cx);
if (JS_CompileScript(cx, global, buffer, strlen(buffer), options,
&script)) {
if (JS_CompileScript(cx, buffer, strlen(buffer), options, &script)) {
JSErrorReporter older;
ok = JS_ExecuteScript(cx, script, &result);

View File

@ -29,7 +29,7 @@ BEGIN_TEST(testGCCellPtr)
const char *code = "function foo() { return 'bar'; }";
JS::CompileOptions opts(cx);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, obj, code, strlen(code), opts, &script));
CHECK(JS_CompileScript(cx, code, strlen(code), opts, &script));
CHECK(script);
CHECK(!JS::GCCellPtr::NullPtr());

View File

@ -30,7 +30,7 @@ BEGIN_TEST(testScriptInfo)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, startLine);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, code, strlen(code), options, &script));
CHECK(JS_CompileScript(cx, code, strlen(code), options, &script));
CHECK(script);
CHECK_EQUAL(JS_GetScriptBaseLineNumber(cx, script), startLine);

View File

@ -42,7 +42,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, code, code_size, options, &script));
CHECK(JS_CompileScript(cx, code, code_size, options, &script));
return tryScript(script);
}
END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript)
@ -52,7 +52,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript_empty)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, "", 0, options, &script));
CHECK(JS_CompileScript(cx, "", 0, options, &script));
return tryScript(script);
}
END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript_empty)
@ -62,7 +62,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScriptForPrincipals)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, code, code_size, options, &script));
CHECK(JS_CompileScript(cx, code, code_size, options, &script));
return tryScript(script);
}
END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScriptForPrincipals)

View File

@ -49,7 +49,7 @@ BEGIN_TEST(testXDR_bug506491)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, s, strlen(s), options, &script));
CHECK(JS_CompileScript(cx, s, strlen(s), options, &script));
CHECK(script);
script = FreezeThaw(cx, script);
@ -76,7 +76,7 @@ BEGIN_TEST(testXDR_bug516827)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, "", 0, options, &script));
CHECK(JS_CompileScript(cx, "", 0, options, &script));
CHECK(script);
script = FreezeThaw(cx, script);
@ -100,7 +100,7 @@ BEGIN_TEST(testXDR_source)
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
JS::RootedScript script(cx);
CHECK(JS_CompileScript(cx, global, *s, strlen(*s), options, &script));
CHECK(JS_CompileScript(cx, *s, strlen(*s), options, &script));
CHECK(script);
script = FreezeThaw(cx, script);
CHECK(script);
@ -125,7 +125,7 @@ BEGIN_TEST(testXDR_sourceMap)
for (const char **sm = sourceMaps; *sm; sm++) {
JS::CompileOptions options(cx);
options.setFileAndLine(__FILE__, __LINE__);
CHECK(JS_CompileScript(cx, global, "", 0, options, &script));
CHECK(JS_CompileScript(cx, "", 0, options, &script));
CHECK(script);
size_t len = strlen(*sm);

View File

@ -3861,10 +3861,10 @@ JS::FinishOffThreadScript(JSContext *maybecx, JSRuntime *rt, void *token)
}
JS_PUBLIC_API(bool)
JS_CompileScript(JSContext *cx, JS::HandleObject obj, const char *ascii,
size_t length, const JS::CompileOptions &options, MutableHandleScript script)
JS_CompileScript(JSContext *cx, const char *ascii, size_t length,
const JS::CompileOptions &options, MutableHandleScript script)
{
return Compile(cx, obj, options, ascii, length, script);
return Compile(cx, cx->global(), options, ascii, length, script);
}
JS_PUBLIC_API(bool)

View File

@ -3241,8 +3241,7 @@ JS_BufferIsCompilableUnit(JSContext *cx, JS::Handle<JSObject*> obj, const char *
* |script| will always be set. On failure, it will be set to nullptr.
*/
extern JS_PUBLIC_API(bool)
JS_CompileScript(JSContext *cx, JS::HandleObject obj,
const char *ascii, size_t length,
JS_CompileScript(JSContext *cx, const char *ascii, size_t length,
const JS::CompileOptions &options,
JS::MutableHandleScript script);

View File

@ -873,8 +873,7 @@ ProcessFile(JSContext *cx, const char *filename, FILE *file, bool forceTTY)
JS::CompileOptions options(cx);
options.setFileAndLine("typein", startline)
.setCompileAndGo(true);
if (JS_CompileScript(cx, global, buffer, strlen(buffer), options,
&script)) {
if (JS_CompileScript(cx, buffer, strlen(buffer), options, &script)) {
JSErrorReporter older;
if (!compileOnly) {

View File

@ -666,8 +666,8 @@ ProxyAutoConfig::SetupJS()
JS::CompileOptions options(cx);
options.setFileAndLine(mPACURI.get(), 1);
JS::Rooted<JSScript*> script(cx);
if (!JS_CompileScript(cx, global, mPACScript.get(),
mPACScript.Length(), options, &script) ||
if (!JS_CompileScript(cx, mPACScript.get(), mPACScript.Length(), options,
&script) ||
!JS_ExecuteScript(cx, script))
{
nsString alertMessage(NS_LITERAL_STRING("PAC file failed to install from "));