Change methods Debug.Object.prototype.getClass and getPrototype to accessor properties .class and .prototype.
authorJason Orendorff <jorendorff@mozilla.com>
Tue, 10 May 2011 17:36:49 -0500
changeset 74418 a91b890f5781dd22eb33e49c67827ac5b0a1530d
parent 74417 903f198d10ee01f7de2a0451db1fbbc2dafae84d
child 74419 e7aa2aadefe09a6e86883c4da21e858072508db2
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Change methods Debug.Object.prototype.getClass and getPrototype to accessor properties .class and .prototype.
js/src/jit-test/tests/debug/Frame-eval-03.js
js/src/jit-test/tests/debug/Frame-eval-04.js
js/src/jit-test/tests/debug/Frame-this-03.js
js/src/jit-test/tests/debug/Frame-this-04.js
js/src/jit-test/tests/debug/Object-class.js
js/src/jit-test/tests/debug/Object-getClass.js
js/src/jit-test/tests/debug/Object-getPrototype.js
js/src/jit-test/tests/debug/Object-prototype.js
js/src/jsdbg.cpp
--- a/js/src/jit-test/tests/debug/Frame-eval-03.js
+++ b/js/src/jit-test/tests/debug/Frame-eval-03.js
@@ -7,16 +7,16 @@ var g = newGlobal('new-compartment');
 var dbg = new Debug(g);
 var hits = 0;
 dbg.hooks = {
     debuggerHandler: function (frame) {
         assertEq(frame.eval("a").return, 2);
         assertEq(frame.eval("c").return, 4);
         var exc = frame.eval("d").throw;
         assertEq(exc instanceof Debug.Object, true);
-        assertEq(exc.getPrototype(), frame.eval("ReferenceError.prototype").return);
+        assertEq(exc.prototype, frame.eval("ReferenceError.prototype").return);
         hits++;
     }
 };
 g.eval("function f(a, b) { var c = a + b; debugger; eval('debugger;'); }");
 g.eval("f(2, 2);");
 g.eval("var a = 2, b = 2, c = a + b; debugger;");
 assertEq(hits, 3);
--- a/js/src/jit-test/tests/debug/Frame-eval-04.js
+++ b/js/src/jit-test/tests/debug/Frame-eval-04.js
@@ -6,9 +6,9 @@ var dbg = new Debug(g);
 var exc, SEp;
 dbg.hooks = {
     debuggerHandler: function (frame) {
         exc = frame.eval("#$@!").throw;
         SEp = frame.eval("SyntaxError.prototype").return;
     }
 };
 g.eval("debugger;");
-assertEq(exc.getPrototype(), SEp);
+assertEq(exc.prototype, SEp);
--- a/js/src/jit-test/tests/debug/Frame-this-03.js
+++ b/js/src/jit-test/tests/debug/Frame-this-03.js
@@ -6,18 +6,18 @@ function classOf(obj) {
 }
 
 var g = newGlobal('new-compartment');
 var dbg = new Debug(g);
 var hits = 0;
 dbg.hooks = {
     debuggerHandler: function (frame) {
         hits++;
-        assertEq(typeof frame.this, 'object');
-        assertEq(frame.this.getClass(), g.v == null ? classOf(g) : classOf(Object(g.v)));
+        assertEq(frame.this instanceof Debug.Object, true);
+        assertEq(frame.this.class, g.v == null ? classOf(g) : classOf(Object(g.v)));
     }
 };
 
 g.eval("function f() { debugger; }");
 
 g.eval("Boolean.prototype.f = f; v = true; v.f();");
 g.eval("f.call(v);");
 g.eval("Number.prototype.f = f; v = 3.14; v.f();");
--- a/js/src/jit-test/tests/debug/Frame-this-04.js
+++ b/js/src/jit-test/tests/debug/Frame-this-04.js
@@ -6,18 +6,18 @@ function classOf(obj) {
 }
 
 var g = newGlobal('new-compartment');
 var dbg = new Debug(g);
 var hits = 0;
 dbg.hooks = {
     debuggerHandler: function (frame) {
         hits++;
-        assertEq(typeof frame.this, 'object');
-        assertEq(frame.this.getClass(), classOf(Object(g.v)));
+        assertEq(frame.this instanceof Debug.Object, true);
+        assertEq(frame.this.class, classOf(Object(g.v)));
     }
 };
 
 g.eval("function f() { debugger; }");
 
 g.eval("v = {}; f.call(v);");
 g.eval("v.f = f; v.f();");
 g.eval("v = new Date; f.call(v);");
rename from js/src/jit-test/tests/debug/Object-getClass.js
rename to js/src/jit-test/tests/debug/Object-class.js
--- a/js/src/jit-test/tests/debug/Object-getClass.js
+++ b/js/src/jit-test/tests/debug/Object-class.js
@@ -1,19 +1,19 @@
 // |jit-test| debug
 
 var g = newGlobal('new-compartment');
 var dbg = new Debug(g);
 var hits = 0;
 dbg.hooks = {
     debuggerHandler: function (frame) {
         var arr = frame.arguments;
-        assertEq(arr[0].getClass(), "Object");
-        assertEq(arr[1].getClass(), "Array");
-        assertEq(arr[2].getClass(), "Function");
-        assertEq(arr[3].getClass(), "Date");
-        assertEq(arr[4].getClass(), "Proxy");
+        assertEq(arr[0].class, "Object");
+        assertEq(arr[1].class, "Array");
+        assertEq(arr[2].class, "Function");
+        assertEq(arr[3].class, "Date");
+        assertEq(arr[4].class, "Proxy");
         hits++;
     }
 };
 
 g.eval("(function () { debugger; })(Object.prototype, [], eval, new Date, Proxy.create({}));");
 assertEq(hits, 1);
rename from js/src/jit-test/tests/debug/Object-getPrototype.js
rename to js/src/jit-test/tests/debug/Object-prototype.js
--- a/js/src/jit-test/tests/debug/Object-getPrototype.js
+++ b/js/src/jit-test/tests/debug/Object-prototype.js
@@ -8,16 +8,16 @@ var dbgeval = function () {
         dbg.hooks = {debuggerHandler: function (frame) { lastval = frame.arguments[0]; }};
         return function dbgeval(s) {
             g.eval("f(" + s + ");");
             return lastval;
         };
     }();
 
 var Op = dbgeval("Object.prototype");
-assertEq(Op.getPrototype(), null);
-assertEq(dbgeval("({})").getPrototype(), Op);
+assertEq(Op.prototype, null);
+assertEq(dbgeval("({})").prototype, Op);
 
-var Ap = dbgeval("[]").getPrototype();
+var Ap = dbgeval("[]").prototype;
 assertEq(Ap, dbgeval("Array.prototype"));
-assertEq(Ap.getPrototype(), Op);
+assertEq(Ap.prototype, Op);
 
-assertEq(dbgeval("Object").getPrototype(), dbgeval("Function.prototype"));
+assertEq(dbgeval("Object").prototype, dbgeval("Function.prototype"));
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -931,25 +931,25 @@ DebugObject_construct(JSContext *cx, uin
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NO_CONSTRUCTOR, "Debug.Object");
     return false;
 }
 
 static JSBool
 DebugObject_getPrototype(JSContext *cx, uintN argc, Value *vp)
 {
-    THIS_DEBUGOBJECT_REFERENT(cx, vp, "getClass", refobj);
+    THIS_DEBUGOBJECT_REFERENT(cx, vp, "get prototype", refobj);
     vp->setObjectOrNull(refobj->getProto());
     return Debug::fromChildJSObject(&vp[1].toObject())->wrapDebuggeeValue(cx, vp);
 }
 
 static JSBool
 DebugObject_getClass(JSContext *cx, uintN argc, Value *vp)
 {
-    THIS_DEBUGOBJECT_REFERENT(cx, vp, "getClass", refobj);
+    THIS_DEBUGOBJECT_REFERENT(cx, vp, "get class", refobj);
     const char *s = refobj->clasp->name;
     JSAtom *str = js_Atomize(cx, s, strlen(s), 0);
     if (!str)
         return false;
     vp->setString(str);
     return true;
 }
 
@@ -1020,23 +1020,23 @@ DebugObject_apply(JSContext *cx, uintN a
     // Call the function. Use newCompletionValue to return to the debugger
     // compartment and populate *vp.
     Value rval;
     bool ok = ExternalInvoke(cx, thisv, calleev, argv.length(), argv.begin(), &rval);
     return dbg->newCompletionValue(ac, ok, rval, vp);
 }
 
 static JSPropertySpec DebugObject_properties[] = {
+    JS_PSG("prototype", DebugObject_getPrototype, 0),
+    JS_PSG("class", DebugObject_getClass, 0),
     JS_PSG("name", DebugObject_getName, 0),
     JS_PS_END
 };
 
 static JSFunctionSpec DebugObject_methods[] = {
-    JS_FN("getPrototype", DebugObject_getPrototype, 0, 0),
-    JS_FN("getClass", DebugObject_getClass, 0, 0),
     JS_FN("apply", DebugObject_apply, 0, 0),
     JS_FS_END
 };
 
 // === Glue
 
 extern JS_PUBLIC_API(JSBool)
 JS_DefineDebugObject(JSContext *cx, JSObject *obj)