Clarify comments on 'this' checks that forbid the each class's prototype object.
authorJim Blandy <jimb@mozilla.com>
Mon, 23 May 2011 15:26:27 -0700
changeset 74446 6a006a09da0ce0adceb1c7e62d733949d90de52f
parent 74445 1fb7cb53a55514180b0b83e003cc611fd86b4d20
child 74447 26d722c9da86ceabb048c8b23bca9a8d5470d26a
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Clarify comments on 'this' checks that forbid the each class's prototype object.
js/src/jsdbg.cpp
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -106,18 +106,19 @@ CheckThisClass(JSContext *cx, Value *vp,
     }
     JSObject *thisobj = &vp[1].toObject();
     if (thisobj->getClass() != clasp) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                              clasp->name, fnname, thisobj->getClass()->name);
         return NULL;
     }
 
-    // Check for e.g. Debug.prototype, which is of the Debug JSClass but isn't
-    // really a Debug object.
+    // Forbid e.g. Debug.prototype, which is of the Debug JSClass but isn't
+    // really a Debug object. The prototype object is distinguished by
+    // having a NULL private value.
     if ((clasp->flags & JSCLASS_HAS_PRIVATE) && !thisobj->getPrivate()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                              clasp->name, fnname, "prototype object");
         return NULL;
     }
     return thisobj;
 }
 
@@ -1072,18 +1073,19 @@ CheckThisFrame(JSContext *cx, Value *vp,
     }
     JSObject *thisobj = &vp[1].toObject();
     if (thisobj->getClass() != &DebugFrame_class) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                              "Debug.Frame", fnname, thisobj->getClass()->name);
         return NULL;
     }
 
-    // Check for Debug.Frame.prototype, which is of class DebugFrame_class but
-    // isn't really a working Debug.Frame object.
+    // Forbid Debug.Frame.prototype, which is of class DebugFrame_class but
+    // isn't really a working Debug.Frame object. The prototype object is
+    // distinguished by having a NULL private value. Also, forbid popped frames.
     if (!thisobj->getPrivate()) {
         if (thisobj->getReservedSlot(JSSLOT_DEBUGFRAME_OWNER).isUndefined()) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                                  "Debug.Frame", fnname, "prototype object");
             return NULL;
         }
         if (checkLive) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEBUG_FRAME_NOT_LIVE,
@@ -1254,18 +1256,19 @@ DebugObject_checkThis(JSContext *cx, Val
     }
     JSObject *thisobj = &vp[1].toObject();
     if (thisobj->clasp != &DebugObject_class) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                              "Debug.Object", fnname, thisobj->getClass()->name);
         return NULL;
     }
 
-    // Check for Debug.Object.prototype, which is of class DebugObject_class
-    // but isn't a real working Debug.Object.
+    // Forbid Debug.Object.prototype, which is of class DebugObject_class
+    // but isn't a real working Debug.Object. The prototype object is
+    // distinguished by having an 'undefined' referent.
     if (thisobj->getReservedSlot(JSSLOT_DEBUGOBJECT_CCW).isUndefined()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO,
                              "Debug.Object", fnname, "prototype object");
         return NULL;
     }
     return thisobj;
 }