Bug 621103: Rename js::Anchor to JS::Anchor: 'JS' is the public namespace. r=waldo
authorJim Blandy <jimb@mozilla.com>
Mon, 31 Jan 2011 14:42:53 -0800
changeset 61708 8eb17a6a39aa001ca3f44e56889db1cdc1bb3956
parent 61707 d3e265afe157b64a720ee2dfe66b84d9009005bd
child 61709 c2f1e6f0d3a44903c07e1d554ddfa3497a8f61fe
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewerswaldo
bugs621103
milestone2.0b11pre
Bug 621103: Rename js::Anchor to JS::Anchor: 'JS' is the public namespace. r=waldo
content/canvas/src/CustomQS_WebGL.h
js/src/jsapi-tests/testConservativeGC.cpp
js/src/jsapi.h
js/src/xpconnect/src/qsgen.py
--- a/content/canvas/src/CustomQS_WebGL.h
+++ b/content/canvas/src/CustomQS_WebGL.h
@@ -902,33 +902,33 @@ nsIDOMWebGLRenderingContext_VertexAttrib
 static inline void FASTCALL
 helper_nsIDOMWebGLRenderingContext_Uniform_x_iv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
                                                       JSObject *arg, int nElements)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     nsIDOMWebGLRenderingContext *self;
     xpc_qsSelfRef selfref;
-    js::Anchor<jsval> self_anchor;
+    JS::Anchor<jsval> self_anchor;
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr,
                           &self_anchor.get(), nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
 
     if (!arg) {
         xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformNiv");
         js_SetTraceableNativeFailed(cx);
     }
 
     js::AutoValueRooter obj_tvr(cx);
 
     nsIWebGLUniformLocation *location;
     xpc_qsSelfRef location_selfref;
-    js::Anchor<jsval> location_anchor;
+    JS::Anchor<jsval> location_anchor;
     nsresult rv_convert_arg0
         = xpc_qsUnwrapThis(cx, locationobj, nsnull, &location,
                            &location_selfref.ptr, &location_anchor.get(),
                            nsnull);
     if (NS_FAILED(rv_convert_arg0)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
@@ -974,33 +974,33 @@ helper_nsIDOMWebGLRenderingContext_Unifo
 static inline void FASTCALL
 helper_nsIDOMWebGLRenderingContext_Uniform_x_fv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
                                                       JSObject *arg, int nElements)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     nsIDOMWebGLRenderingContext *self;
     xpc_qsSelfRef selfref;
-    js::Anchor<jsval> self_anchor;
+    JS::Anchor<jsval> self_anchor;
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr,
                           &self_anchor.get(), nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
 
     if (!arg) {
         xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformNfv");
         js_SetTraceableNativeFailed(cx);
     }
 
     js::AutoValueRooter obj_tvr(cx);
 
     nsIWebGLUniformLocation *location;
     xpc_qsSelfRef location_selfref;
-    js::Anchor<jsval> location_anchor;
+    JS::Anchor<jsval> location_anchor;
     nsresult rv_convert_arg0
         = xpc_qsUnwrapThis(cx, locationobj, nsnull, &location,
                            &location_selfref.ptr, &location_anchor.get(),
                            nsnull);
     if (NS_FAILED(rv_convert_arg0)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
@@ -1048,33 +1048,33 @@ helper_nsIDOMWebGLRenderingContext_Unifo
 static inline void FASTCALL
 helper_nsIDOMWebGLRenderingContext_UniformMatrix_x_fv_tn(JSContext *cx, JSObject *obj, JSObject *locationobj,
                                                             JSBool transpose, JSObject *arg, int nElements)
 {
     XPC_QS_ASSERT_CONTEXT_OK(cx);
 
     nsIDOMWebGLRenderingContext *self;
     xpc_qsSelfRef selfref;
-    js::Anchor<jsval> self_anchor;
+    JS::Anchor<jsval> self_anchor;
     if (!xpc_qsUnwrapThis(cx, obj, nsnull, &self, &selfref.ptr,
                           &self_anchor.get(), nsnull)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
 
     if (!arg) {
         xpc_qsThrowMethodFailedWithDetails(cx, NS_ERROR_FAILURE, "nsIDOMWebGLRenderingContext", "uniformMatrixNfv");
         js_SetTraceableNativeFailed(cx);
     }
 
     js::AutoValueRooter obj_tvr(cx);
 
     nsIWebGLUniformLocation *location;
     xpc_qsSelfRef location_selfref;
-    js::Anchor<jsval> location_anchor;
+    JS::Anchor<jsval> location_anchor;
     nsresult rv_convert_arg0
         = xpc_qsUnwrapThis(cx, locationobj, nsnull, &location,
                            &location_selfref.ptr, &location_anchor.get(),
                            nsnull);
     if (NS_FAILED(rv_convert_arg0)) {
         js_SetTraceableNativeFailed(cx);
         return;
     }
--- a/js/src/jsapi-tests/testConservativeGC.cpp
+++ b/js/src/jsapi-tests/testConservativeGC.cpp
@@ -57,17 +57,17 @@ bool checkObjectFields(JSObject *savedCo
     return true;
 }
 
 END_TEST(testConservativeGC)
 
 BEGIN_TEST(testDerivedValues)
 {
   JSString *str = JS_NewStringCopyZ(cx, "once upon a midnight dreary");
-  js::Anchor<JSString *> str_anchor(str);
+  JS::Anchor<JSString *> str_anchor(str);
   static const jschar expected[] = { 'o', 'n', 'c', 'e' };
   const jschar *ch = JS_GetStringCharsZ(cx, str);
   str = NULL;
 
   /* Do a lot of allocation and collection. */
   for (int i = 0; i < 3; i++) {
     for (int j = 0; j < 1000; j++)
       JS_NewStringCopyZ(cx, "as I pondered weak and weary");
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1278,17 +1278,17 @@ extern JS_FRIEND_API(JSBool)
 js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name);
 
 extern JS_FRIEND_API(JSBool)
 js_RemoveRoot(JSRuntime *rt, void *rp);
 
 #ifdef __cplusplus
 JS_END_EXTERN_C
 
-namespace js {
+namespace JS {
 
 /*
  * Protecting non-jsval, non-JSObject *, non-JSString * values from collection
  *
  * Most of the time, the garbage collector's conservative stack scanner works
  * behind the scenes, finding all live values and protecting them from being
  * collected. However, when JSAPI client code obtains a pointer to data the
  * scanner does not know about, owned by an object the scanner does know about,
@@ -1326,22 +1326,22 @@ namespace js {
  *
  * there's no problem, because the value we've extracted, x, is a jsval, a
  * type that the conservative scanner recognizes.
  *
  * Conservative GC frees us from the obligation to explicitly root the types it
  * knows about, but when we work with derived values like |ch|, we must root
  * their owners, as the derived value alone won't keep them alive.
  *
- * A js::Anchor is a kind of GC root that allows us to keep the owners of
+ * A JS::Anchor is a kind of GC root that allows us to keep the owners of
  * derived values like |ch| alive throughout the Anchor's lifetime. We could
  * fix the above code as follows:
  *
  *   void f(JSString *str) {
- *     js::Anchor<JSString *> a_str(str);
+ *     JS::Anchor<JSString *> a_str(str);
  *     const jschar *ch = JS_GetStringCharsZ(str);
  *     ... do stuff with ch, but no uses of str ...;
  *   }
  *
  * This simply ensures that |str| will be live until |a_str| goes out of scope.
  * As long as we don't retain a pointer to the string's characters for longer
  * than that, we have avoided all garbage collection hazards.
  */
@@ -1431,17 +1431,17 @@ inline Anchor<T>::~Anchor() {
 template<>
 inline Anchor<jsval>::~Anchor() {
     volatile jsval sink;
     sink.asBits = hold.asBits;
 }
 #endif
 #endif
 
-}  /* namespace js */
+}  /* namespace JS */
 
 JS_BEGIN_EXTERN_C
 #endif
 
 /*
  * This symbol may be used by embedders to detect the change from the old
  * JS_AddRoot(JSContext *, void *) APIs to the new ones above.
  */
--- a/js/src/xpconnect/src/qsgen.py
+++ b/js/src/xpconnect/src/qsgen.py
@@ -1203,17 +1203,17 @@ def writeTraceableArgumentConversion(f, 
         elif type.name == 'nsIAtom':
             # Should have special atomizing behavior.  Fall through.
             pass
         else:
             if not rvdeclared:
                 f.write("    nsresult rv;\n");
             f.write("    %s *%s;\n" % (type.name, name))
             f.write("    xpc_qsSelfRef %sref;\n" % name)
-            f.write("    js::Anchor<jsval> %sanchor;\n" % name);
+            f.write("    JS::Anchor<jsval> %sanchor;\n" % name);
             f.write("    rv = xpc_qsUnwrapArg<%s>("
                     "cx, js::Jsvalify(js::ValueArgToConstRef(%s)), &%s, &%sref.ptr, &%sanchor.get());\n"
                     % (type.name, argVal, name, name, name))
             f.write("    if (NS_FAILED(rv)) {\n")
             if haveCcx:
                 f.write("        xpc_qsThrowBadArgWithCcx(ccx, rv, %d);\n" % i)
             else:
                 # XXX Fix this to return a real error!
@@ -1343,17 +1343,17 @@ def writeTraceableQuickStub(f, customMet
             f.write("    XPCLazyCallContext lccx(ccx);\n")
 
     # Get the 'self' pointer.
     if customMethodCall is None or not 'thisType' in customMethodCall:
         f.write("    %s *self;\n" % member.iface.name)
     else:
         f.write("    %s *self;\n" % customMethodCall['thisType'])
     f.write("    xpc_qsSelfRef selfref;\n")
-    f.write("    js::Anchor<jsval> selfanchor;\n")
+    f.write("    JS::Anchor<jsval> selfanchor;\n")
     if haveCcx:
         f.write("    if (!xpc_qsUnwrapThisFromCcx(ccx, &self, &selfref.ptr, "
                 "&selfanchor.get())) {\n")
     elif (member.kind == 'method') and isInterfaceType(member.realtype):
         f.write("    XPCLazyCallContext lccx(JS_CALLER, cx, obj);\n")
         f.write("    if (!xpc_qsUnwrapThis(cx, obj, callee, &self, &selfref.ptr, "
                 "&selfanchor.get(), &lccx)) {\n")
     else: