Bug 928736 - Fix compiler warnings related to context options namespace importing. r=luke
authorBenjamin Peterson <benjamin@python.org>
Wed, 23 Oct 2013 23:51:37 -0400
changeset 152234 17a6af9a1c58efd858fb7573428665423cad12ba
parent 152233 592f54e43014efc9120a5d9586c5c5543a2b746e
child 152285 5d5591687e676247c617f98f0a02c744250285d1
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersluke
bugs928736
milestone27.0a1
Bug 928736 - Fix compiler warnings related to context options namespace importing. r=luke
js/src/NamespaceImports.h
js/src/jsapi-tests/testFuncCallback.cpp
js/src/jsapi-tests/testJSEvaluateScript.cpp
js/src/jsapi-tests/testProfileStrings.cpp
js/src/jsapi-tests/tests.h
js/src/shell/js.cpp
--- a/js/src/NamespaceImports.h
+++ b/js/src/NamespaceImports.h
@@ -33,26 +33,19 @@ class AutoValueVector;
 class AutoIdArray;
 
 class AutoGCRooter;
 class AutoArrayRooter;
 template <typename T> class AutoVectorRooter;
 template<typename K, typename V> class AutoHashMapRooter;
 template<typename T> class AutoHashSetRooter;
 
-class JS_PUBLIC_API(ContextOptions);
-class JS_PUBLIC_API(AutoSaveContextOptions);
-
-JS_PUBLIC_API(ContextOptions &) ContextOptionsRef(JSContext *cx);
-
 class ContextOptions;
 class AutoSaveContextOptions;
 
-ContextOptions &ContextOptionsRef(JSContext *cx);
-
 }
 
 // Do the importing.
 namespace js {
 
 using JS::Value;
 using JS::BooleanValue;
 using JS::DoubleValue;
@@ -118,14 +111,13 @@ using JS::MutableHandleId;
 using JS::MutableHandleObject;
 using JS::MutableHandleScript;
 using JS::MutableHandleString;
 using JS::MutableHandleValue;
 
 using JS::Zone;
 
 using JS::ContextOptions;
-using JS::ContextOptionsRef;
 using JS::AutoSaveContextOptions;
 
 } /* namespace js */
 
 #endif /* NamespaceImports_h */
--- a/js/src/jsapi-tests/testFuncCallback.cpp
+++ b/js/src/jsapi-tests/testFuncCallback.cpp
@@ -128,14 +128,14 @@ BEGIN_TEST(testFuncCallback_bug507012)
 // Make sure that the method jit is enabled.
 // We'll probably want to test in all modes.
 virtual
 JSContext *createContext()
 {
     JSContext *cx = JSAPITest::createContext();
     if (!cx)
         return nullptr;
-    ContextOptionsRef(cx).setBaseline(true)
-                         .setIon(true);
+    JS::ContextOptionsRef(cx).setBaseline(true)
+                             .setIon(true);
     return cx;
 }
 
 END_TEST(testFuncCallback_bug507012)
--- a/js/src/jsapi-tests/testJSEvaluateScript.cpp
+++ b/js/src/jsapi-tests/testJSEvaluateScript.cpp
@@ -4,34 +4,34 @@
 
 #include "jsapi-tests/tests.h"
 
 BEGIN_TEST(testJSEvaluateScript)
 {
     JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, nullptr, global));
     CHECK(obj);
 
-    CHECK(ContextOptionsRef(cx).varObjFix());
+    CHECK(JS::ContextOptionsRef(cx).varObjFix());
 
     static const char src[] = "var x = 5;";
 
     JS::RootedValue retval(cx);
     CHECK(JS_EvaluateScript(cx, obj, src, sizeof(src) - 1, __FILE__, __LINE__,
                             retval.address()));
 
     bool hasProp = true;
     CHECK(JS_AlreadyHasOwnProperty(cx, obj, "x", &hasProp));
     CHECK(!hasProp);
 
     hasProp = false;
     CHECK(JS_HasProperty(cx, global, "x", &hasProp));
     CHECK(hasProp);
 
     // Now do the same thing, but without JSOPTION_VAROBJFIX
-    ContextOptionsRef(cx).setVarObjFix(false);
+    JS::ContextOptionsRef(cx).setVarObjFix(false);
 
     static const char src2[] = "var y = 5;";
 
     CHECK(JS_EvaluateScript(cx, obj, src2, sizeof(src2) - 1, __FILE__, __LINE__,
                             retval.address()));
 
     hasProp = false;
     CHECK(JS_AlreadyHasOwnProperty(cx, obj, "y", &hasProp));
--- a/js/src/jsapi-tests/testProfileStrings.cpp
+++ b/js/src/jsapi-tests/testProfileStrings.cpp
@@ -136,18 +136,18 @@ BEGIN_TEST(testProfileStrings_isCalledWi
     }
     return true;
 }
 END_TEST(testProfileStrings_isCalledWithInterpreter)
 
 BEGIN_TEST(testProfileStrings_isCalledWithJIT)
 {
     CHECK(initialize(cx));
-    ContextOptionsRef(cx).setBaseline(true)
-                         .setIon(true);
+    JS::ContextOptionsRef(cx).setBaseline(true)
+                             .setIon(true);
 
     EXEC("function g() { var p = new Prof(); p.test_fn(); }");
     EXEC("function f() { g(); }");
     EXEC("function e() { f(); }");
     EXEC("function d() { e(); }");
     EXEC("function c() { d(); }");
     EXEC("function b() { c(); }");
     EXEC("function a() { b(); }");
@@ -185,23 +185,23 @@ BEGIN_TEST(testProfileStrings_isCalledWi
     }
     return true;
 }
 END_TEST(testProfileStrings_isCalledWithJIT)
 
 BEGIN_TEST(testProfileStrings_isCalledWhenError)
 {
     CHECK(initialize(cx));
-    ContextOptionsRef(cx).setBaseline(true)
-                         .setIon(true);
+    JS::ContextOptionsRef(cx).setBaseline(true)
+                             .setIon(true);
 
     EXEC("function check2() { throw 'a'; }");
 
     reset(cx);
-    ContextOptionsRef(cx).setDontReportUncaught(true);
+    JS::ContextOptionsRef(cx).setDontReportUncaught(true);
     {
         JS::RootedValue rval(cx);
         /* Make sure the stack resets and we have an entry for each stack */
         bool ok = JS_CallFunctionName(cx, global, "check2", 0, nullptr, rval.address());
         CHECK(!ok);
         CHECK(psize == 0);
         CHECK(cx->runtime()->spsProfiler.stringsCount() == 1);
 
@@ -209,18 +209,18 @@ BEGIN_TEST(testProfileStrings_isCalledWh
     }
     return true;
 }
 END_TEST(testProfileStrings_isCalledWhenError)
 
 BEGIN_TEST(testProfileStrings_worksWhenEnabledOnTheFly)
 {
     CHECK(initialize(cx));
-    ContextOptionsRef(cx).setBaseline(true)
-                         .setIon(true);
+    JS::ContextOptionsRef(cx).setBaseline(true)
+                             .setIon(true);
 
     EXEC("function b(p) { p.test_fn(); }");
     EXEC("function a() { var p = new Prof(); p.enable(); b(p); }");
     reset(cx);
     js::EnableRuntimeProfilingStack(cx->runtime(), false);
     {
         /* enable it in the middle of JS and make sure things check out */
         JS::RootedValue rval(cx);
--- a/js/src/jsapi-tests/tests.h
+++ b/js/src/jsapi-tests/tests.h
@@ -295,17 +295,17 @@ class JSAPITest
                 (unsigned int) report->lineno,
                 message);
     }
 
     virtual JSContext * createContext() {
         JSContext *cx = JS_NewContext(rt, 8192);
         if (!cx)
             return nullptr;
-        ContextOptionsRef(cx).setVarObjFix(true);
+        JS::ContextOptionsRef(cx).setVarObjFix(true);
         JS_SetErrorReporter(cx, &reportError);
         return cx;
     }
 
     virtual const JSClass * getGlobalClass() {
         return basicGlobalClass();
     }
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -419,18 +419,18 @@ RunFile(JSContext *cx, Handle<JSObject*>
     }
     ungetc(ch, file);
 
     int64_t t1 = PRMJ_Now();
     RootedScript script(cx);
 
     {
         AutoSaveContextOptions asco(cx);
-        ContextOptionsRef(cx).setCompileAndGo(true)
-                             .setNoScriptRval(true);
+        JS::ContextOptionsRef(cx).setCompileAndGo(true)
+                                 .setNoScriptRval(true);
 
         CompileOptions options(cx);
         options.setUTF8(true)
                .setFileAndLine(filename, 1);
 
         gGotError = false;
         script = JS::Compile(cx, obj, options, file);
         JS_ASSERT_IF(!script, gGotError);
@@ -685,35 +685,35 @@ ResolvePath(JSContext *cx, HandleString 
     return JS_NewStringCopyZ(cx, buffer);
 }
 
 static bool
 Options(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
-    ContextOptions oldOptions = ContextOptionsRef(cx);
+    ContextOptions oldOptions = JS::ContextOptionsRef(cx);
     for (unsigned i = 0; i < args.length(); i++) {
         JSString *str = JS_ValueToString(cx, args[i]);
         if (!str)
             return false;
         args[i].setString(str);
 
         JSAutoByteString opt(cx, str);
         if (!opt)
             return false;
 
         if (strcmp(opt.ptr(), "strict") == 0)
-            ContextOptionsRef(cx).toggleExtraWarnings();
+            JS::ContextOptionsRef(cx).toggleExtraWarnings();
         else if (strcmp(opt.ptr(), "typeinfer") == 0)
-            ContextOptionsRef(cx).toggleTypeInference();
+            JS::ContextOptionsRef(cx).toggleTypeInference();
         else if (strcmp(opt.ptr(), "werror") == 0)
-            ContextOptionsRef(cx).toggleWerror();
+            JS::ContextOptionsRef(cx).toggleWerror();
         else if (strcmp(opt.ptr(), "strict_mode") == 0)
-            ContextOptionsRef(cx).toggleStrictMode();
+            JS::ContextOptionsRef(cx).toggleStrictMode();
         else {
             char* msg = JS_sprintf_append(nullptr,
                                           "unknown option name '%s'."
                                           " The valid names are strict,"
                                           " typeinfer, werror, and strict_mode.",
                                           opt.ptr());
             if (!msg) {
                 JS_ReportOutOfMemory(cx);
@@ -820,17 +820,17 @@ class AutoNewContext
     AutoNewContext() : oldcx(nullptr), newcx(nullptr) {}
 
     bool enter(JSContext *cx) {
         JS_ASSERT(!JS_IsExceptionPending(cx));
         oldcx = cx;
         newcx = NewContext(JS_GetRuntime(cx));
         if (!newcx)
             return false;
-        ContextOptionsRef(newcx).setDontReportUncaught(true);
+        JS::ContextOptionsRef(newcx).setDontReportUncaught(true);
         js::SetDefaultObjectForContext(newcx, JS::CurrentGlobalOrNull(cx));
 
         newRequest.construct(newcx);
         newCompartment.construct(newcx, JS::CurrentGlobalOrNull(cx));
         return true;
     }
 
     JSContext *get() { return newcx; }
@@ -1059,17 +1059,17 @@ Evaluate(JSContext *cx, unsigned argc, j
         if (saveFrameChain && !asfc.save())
             return false;
 
         JSAutoCompartment ac(cx, global);
         RootedScript script(cx);
 
         {
             AutoSaveContextOptions asco(cx);
-            ContextOptionsRef(cx).setCompileAndGo(compileAndGo)
+            JS::ContextOptionsRef(cx).setCompileAndGo(compileAndGo)
                                  .setNoScriptRval(noScriptRval);
 
             CompileOptions options(cx);
             options.setFileAndLine(fileName, lineNumber)
                    .setElement(element)
                    .setSourcePolicy(sourcePolicy);
 
             script = JS::Compile(cx, global, options, codeChars, codeLength);
@@ -1222,18 +1222,18 @@ Run(JSContext *cx, unsigned argc, jsval 
         return false;
 
     JS::Anchor<JSString *> a_str(str);
 
     RootedScript script(cx);
     int64_t startClock = PRMJ_Now();
     {
         AutoSaveContextOptions asco(cx);
-        ContextOptionsRef(cx).setCompileAndGo(true)
-                             .setNoScriptRval(true);
+        JS::ContextOptionsRef(cx).setCompileAndGo(true)
+                                 .setNoScriptRval(true);
 
         script = JS_CompileUCScript(cx, thisobj, ucbuf, buflen, filename.ptr(), 1);
         if (!script)
             return false;
     }
 
     if (!JS_ExecuteScript(cx, thisobj, script, nullptr))
         return false;
@@ -2059,18 +2059,18 @@ DisassFile(JSContext *cx, unsigned argc,
         return false;
     JSAutoByteString filename(cx, str);
     if (!filename)
         return false;
     RootedScript script(cx);
 
     {
         AutoSaveContextOptions asco(cx);
-        ContextOptionsRef(cx).setCompileAndGo(true)
-                             .setNoScriptRval(true);
+        JS::ContextOptionsRef(cx).setCompileAndGo(true)
+                                 .setNoScriptRval(true);
 
         CompileOptions options(cx);
         options.setUTF8(true)
                .setFileAndLine(filename.ptr(), 1);
 
         script = JS::Compile(cx, thisobj, options, filename.ptr());
         if (!script)
             return false;
@@ -3178,18 +3178,18 @@ Compile(JSContext *cx, unsigned argc, js
         const char *typeName = JS_GetTypeName(cx, JS_TypeOfValue(cx, arg0));
         JS_ReportError(cx, "expected string to compile, got %s", typeName);
         return false;
     }
 
     RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
     JSString *scriptContents = JSVAL_TO_STRING(arg0);
     AutoSaveContextOptions asco(cx);
-    ContextOptionsRef(cx).setCompileAndGo(true)
-                         .setNoScriptRval(true);
+    JS::ContextOptionsRef(cx).setCompileAndGo(true)
+                              .setNoScriptRval(true);
     bool ok = JS_CompileUCScript(cx, global, JS_GetStringCharsZ(cx, scriptContents),
                                  JS_GetStringLength(scriptContents), "<string>", 1);
     JS_SET_RVAL(cx, vp, UndefinedValue());
     return ok;
 }
 
 static bool
 Parse(JSContext *cx, unsigned argc, jsval *vp)
@@ -5286,23 +5286,23 @@ NewContext(JSRuntime *rt)
     if (!data) {
         DestroyContext(cx, false);
         return nullptr;
     }
 
     JS_SetContextPrivate(cx, data);
     JS_SetErrorReporter(cx, my_ErrorReporter);
     if (enableTypeInference)
-        ContextOptionsRef(cx).toggleTypeInference();
+        JS::ContextOptionsRef(cx).toggleTypeInference();
     if (enableIon)
-        ContextOptionsRef(cx).toggleIon();
+        JS::ContextOptionsRef(cx).toggleIon();
     if (enableBaseline)
-        ContextOptionsRef(cx).toggleBaseline();
+        JS::ContextOptionsRef(cx).toggleBaseline();
     if (enableAsmJS)
-        ContextOptionsRef(cx).toggleAsmJS();
+        JS::ContextOptionsRef(cx).toggleAsmJS();
     return cx;
 }
 
 static void
 DestroyContext(JSContext *cx, bool withGC)
 {
     JSShellContextData *data = GetContextData(cx);
     JS_SetContextPrivate(cx, nullptr);
@@ -5416,17 +5416,17 @@ ProcessArgs(JSContext *cx, JSObject *obj
         compileOnly = true;
 
     if (op->getBoolOption('w'))
         reportWarnings = true;
     else if (op->getBoolOption('W'))
         reportWarnings = false;
 
     if (op->getBoolOption('s'))
-        ContextOptionsRef(cx).toggleExtraWarnings();
+        JS::ContextOptionsRef(cx).toggleExtraWarnings();
 
     if (op->getBoolOption('d')) {
         JS_SetRuntimeDebugMode(JS_GetRuntime(cx), true);
         JS_SetDebugMode(cx, true);
     }
 
     jsCacheDir = op->getStringOption("js-cache");
     if (jsCacheDir) {
@@ -5447,26 +5447,26 @@ ProcessArgs(JSContext *cx, JSObject *obj
     int32_t threadCount = op->getIntOption("thread-count");
     if (threadCount >= 0)
         cx->runtime()->requestHelperThreadCount(threadCount);
 #endif /* JS_THREADSAFE */
 
 #if defined(JS_ION)
     if (op->getBoolOption("no-ion")) {
         enableIon = false;
-        ContextOptionsRef(cx).toggleIon();
+        JS::ContextOptionsRef(cx).toggleIon();
     }
     if (op->getBoolOption("no-asmjs")) {
         enableAsmJS = false;
-        ContextOptionsRef(cx).toggleAsmJS();
+        JS::ContextOptionsRef(cx).toggleAsmJS();
     }
 
     if (op->getBoolOption("no-baseline")) {
         enableBaseline = false;
-        ContextOptionsRef(cx).toggleBaseline();
+        JS::ContextOptionsRef(cx).toggleBaseline();
     }
 
     if (const char *str = op->getStringOption("ion-gvn")) {
         if (strcmp(str, "off") == 0)
             jit::js_IonOptions.gvn = false;
         else if (strcmp(str, "pessimistic") == 0)
             jit::js_IonOptions.gvnIsOptimistic = false;
         else if (strcmp(str, "optimistic") == 0)
@@ -5636,17 +5636,17 @@ Shell(JSContext *cx, OptionParser *op, c
     JSAutoRequest ar(cx);
 
     /*
      * First check to see if type inference is enabled. These flags
      * must be set on the compartment when it is constructed.
      */
     if (op->getBoolOption("no-ti")) {
         enableTypeInference = false;
-        ContextOptionsRef(cx).toggleTypeInference();
+        JS::ContextOptionsRef(cx).toggleTypeInference();
     }
 
     if (op->getBoolOption("fuzzing-safe"))
         fuzzingSafe = true;
     else
         fuzzingSafe = (getenv("MOZ_FUZZING_SAFE") && getenv("MOZ_FUZZING_SAFE")[0] != '0');
 
     RootedObject glob(cx);