Fix Windows build warnings, followup to bug 745742. r=themaid
authorJeff Walden <jwalden@mit.edu>
Thu, 03 May 2012 19:03:13 -0700
changeset 95361 489e1b75048ea10ec4700ea74fd930dd5a0a0fe1
parent 95360 3de88b31bbcba83129662b064b15ed0c7d59a8ce
child 95362 4608e8e96c871ce701cc2a629f8aa7d3973e507b
push idunknown
push userunknown
push dateunknown
reviewersthemaid
bugs745742
milestone15.0a1
Fix Windows build warnings, followup to bug 745742. r=themaid
js/src/jsobjinlines.h
js/src/jsonparser.h
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -1299,41 +1299,42 @@ class AutoPropDescArrayRooter : private 
 
   private:
     PropDescArray descriptors;
     SkipRoot skip;
 };
 
 class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescriptor
 {
+    SkipRoot skip;
+
+    AutoPropertyDescriptorRooter *thisDuringConstruction() { return this; }
+
   public:
     AutoPropertyDescriptorRooter(JSContext *cx)
-      : AutoGCRooter(cx, DESCRIPTOR), skip(cx, this)
+      : AutoGCRooter(cx, DESCRIPTOR), skip(cx, thisDuringConstruction())
     {
         obj = NULL;
         attrs = 0;
         getter = (PropertyOp) NULL;
         setter = (StrictPropertyOp) NULL;
         value.setUndefined();
     }
 
     AutoPropertyDescriptorRooter(JSContext *cx, PropertyDescriptor *desc)
-      : AutoGCRooter(cx, DESCRIPTOR), skip(cx, this)
+      : AutoGCRooter(cx, DESCRIPTOR), skip(cx, thisDuringConstruction())
     {
         obj = desc->obj;
         attrs = desc->attrs;
         getter = desc->getter;
         setter = desc->setter;
         value = desc->value;
     }
 
     friend void AutoGCRooter::trace(JSTracer *trc);
-
-  private:
-    SkipRoot skip;
 };
 
 inline void
 NewObjectCache::copyCachedToObject(JSObject *dst, JSObject *src)
 {
     js_memcpy(dst, src, dst->sizeOfThis());
 #ifdef JSGC_GENERATIONAL
     Shape::writeBarrierPost(dst->shape_, &dst->shape_);
--- a/js/src/jsonparser.h
+++ b/js/src/jsonparser.h
@@ -47,19 +47,16 @@
 #include "jscntxt.h"
 #include "jsstr.h"
 
 /*
  * NB: This class must only be used on the stack as it contains a js::Value.
  */
 class JSONParser
 {
-    JSONParser(const JSONParser &other) MOZ_DELETE;
-    void operator=(const JSONParser &other) MOZ_DELETE;
-
   public:
     enum ErrorHandling { RaiseError, NoError };
     enum ParsingMode { StrictJSON, LegacyJSON };
 
   private:
     /* Data members */
 
     JSContext * const cx;
@@ -78,32 +75,34 @@ class JSONParser
                  ArrayOpen, ArrayClose,
                  ObjectOpen, ObjectClose,
                  Colon, Comma,
                  OOM, Error };
 #ifdef DEBUG
     Token lastToken;
 #endif
 
+    JSONParser *thisDuringConstruction() { return this; }
+
   public:
     /* Public API */
 
     /*
      * Create a parser for the provided JSON data.  The parser will accept
      * certain legacy, non-JSON syntax if decodingMode is LegacyJSON.
      * Description of this syntax is deliberately omitted: new code should only
      * use strict JSON parsing.
      */
     JSONParser(JSContext *cx, const jschar *data, size_t length,
                ParsingMode parsingMode = StrictJSON,
                ErrorHandling errorHandling = RaiseError)
       : cx(cx),
         current(data, length),
         end(data + length, data, length),
-        root(cx, this),
+        root(cx, thisDuringConstruction()),
         parsingMode(parsingMode),
         errorHandling(errorHandling)
 #ifdef DEBUG
       , lastToken(Error)
 #endif
     {
         JS_ASSERT(current <= end);
     }
@@ -173,11 +172,15 @@ class JSONParser
     Token advancePropertyName();
     Token advancePropertyColon();
     Token advanceAfterProperty();
     Token advanceAfterObjectOpen();
     Token advanceAfterArrayElement();
 
     void error(const char *msg);
     bool errorReturn();
+
+  private:
+    JSONParser(const JSONParser &other) MOZ_DELETE;
+    void operator=(const JSONParser &other) MOZ_DELETE;
 };
 
 #endif /* jsonparser_h___ */