Address review comments from Waldo (bug 672829 comment 23).
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 21 Jul 2011 16:23:21 -0500
changeset 75223 1af365c2b3fc7341f23d43acbeee3f662ad41fb7
parent 75222 6ff6297bebb6e4271a936bd92d7cbd53fc297d3a
child 75224 501052c6263ba6d4b020dbd205df08a41251b9c0
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
bugs672829
milestone8.0a1
Address review comments from Waldo (bug 672829 comment 23).
js/src/vm/GlobalObject.cpp
js/src/vm/GlobalObject.h
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -283,44 +283,43 @@ GlobalObject::getDebuggers()
     JS_ASSERT(debuggers.toObject().clasp == &GlobalDebuggees_class);
     return (DebuggerVector *) debuggers.toObject().getPrivate();
 }
 
 GlobalObject::DebuggerVector *
 GlobalObject::getOrCreateDebuggers(JSContext *cx)
 {
     assertSameCompartment(cx, this);
-    DebuggerVector *vec = getDebuggers();
-    if (vec)
-        return vec;
+    DebuggerVector *debuggers = getDebuggers();
+    if (debuggers)
+        return debuggers;
 
-    JSObject *obj = NewNonFunction<WithProto::Given>(cx, &GlobalDebuggees_class, NULL, NULL);
+    JSObject *obj = NewNonFunction<WithProto::Given>(cx, &GlobalDebuggees_class, NULL, this);
     if (!obj)
         return NULL;
-    vec = cx->new_<DebuggerVector>();
-    if (!vec)
+    debuggers = cx->new_<DebuggerVector>();
+    if (!debuggers)
         return NULL;
-    obj->setPrivate(vec);
-    if (!js_SetReservedSlot(cx, this, DEBUGGERS, ObjectValue(*obj)))
-        return NULL;
-    return vec;
+    obj->setPrivate(debuggers);
+    setReservedSlot(DEBUGGERS, ObjectValue(*obj));
+    return debuggers;
 }
 
 bool
 GlobalObject::addDebugger(JSContext *cx, Debugger *dbg)
 {
-    DebuggerVector *vec = getOrCreateDebuggers(cx);
-    if (!vec)
+    DebuggerVector *debuggers = getOrCreateDebuggers(cx);
+    if (!debuggers)
         return false;
 #ifdef DEBUG
-    for (Debugger **p = vec->begin(); p != vec->end(); p++)
+    for (Debugger **p = debuggers->begin(); p != debuggers->end(); p++)
         JS_ASSERT(*p != dbg);
 #endif
-    if (vec->empty() && !compartment()->addDebuggee(cx, this))
+    if (debuggers->empty() && !compartment()->addDebuggee(cx, this))
         return false;
-    if (!vec->append(dbg)) {
+    if (!debuggers->append(dbg)) {
         compartment()->removeDebuggee(cx, this);
         return false;
     }
     return true;
 }
 
 } // namespace js
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -37,24 +37,25 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GlobalObject_h___
 #define GlobalObject_h___
 
 #include "jsfun.h"
-#include "jsprvtd.h"
 #include "jsvector.h"
 
 extern JSObject *
 js_InitFunctionAndObjectClasses(JSContext *cx, JSObject *obj);
 
 namespace js {
 
+class Debugger;
+
 /*
  * Global object slots are reserved as follows:
  *
  * [0, JSProto_LIMIT)
  *   Stores the original value of the constructor for the corresponding
  *   JSProtoKey.
  * [JSProto_LIMIT, 2 * JSProto_LIMIT)
  *   Stores the prototype, if any, for the constructor for the corresponding
@@ -168,22 +169,26 @@ class GlobalObject : public ::JSObject {
     }
 
     bool getFunctionNamespace(JSContext *cx, Value *vp);
 
     bool initStandardClasses(JSContext *cx);
 
     typedef js::Vector<js::Debugger *, 0, js::SystemAllocPolicy> DebuggerVector;
 
-    // The collection of Debugger objects debugging this global. If this global
-    // is not a debuggee, this returns either NULL or an empty vector.
+    /*
+     * The collection of Debugger objects debugging this global. If this global
+     * is not a debuggee, this returns either NULL or an empty vector.
+     */
     DebuggerVector *getDebuggers();
 
-    // The same, but create the empty vector if one does not already
-    // exist. Returns NULL only on OOM.
+    /*
+     * The same, but create the empty vector if one does not already
+     * exist. Returns NULL only on OOM.
+     */
     DebuggerVector *getOrCreateDebuggers(JSContext *cx);
 
     bool addDebugger(JSContext *cx, Debugger *dbg);
 };
 
 /*
  * Define ctor.prototype = proto as non-enumerable, non-configurable, and
  * non-writable; define proto.constructor = ctor as non-enumerable but