Cleanup for review. This undoes some changes made earlier to tests, fixes some formatting errors, deletes some dead code, and fixes a bug in JSPROP_NATIVE_ACCESSORS support.
authorJason Orendorff <jorendorff@mozilla.com>
Wed, 20 Jul 2011 10:39:01 -0500
changeset 75219 f630b2a5add17e2b32d8186e17862c06fdeeb374
parent 75218 cbfcc2cf513a219d13057f462af1efbab3974fd5
child 75220 fe677014cb6c8d1f89127f8ce589eb181ff8dd85
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone8.0a1
Cleanup for review. This undoes some changes made earlier to tests, fixes some formatting errors, deletes some dead code, and fixes a bug in JSPROP_NATIVE_ACCESSORS support.
js/src/jsapi.cpp
js/src/jsdbg.cpp
js/src/jsinterp.cpp
js/src/jsobj.h
js/src/tests/ecma_3/extensions/regress-429248.js
js/src/tests/js1_5/extensions/regress-422137.js
js/src/tests/shell.js
js/src/vm/GlobalObject.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3396,18 +3396,18 @@ DefineProperty(JSContext *cx, JSObject *
     } else {
         atom = js_Atomize(cx, name, strlen(name));
         if (!atom)
             return JS_FALSE;
         id = ATOM_TO_JSID(atom);
     }
 
     if (attrs & JSPROP_NATIVE_ACCESSORS) {
-        JS_ASSERT(!(flags & (JSPROP_GETTER | JSPROP_SETTER)));
-        flags &= ~JSPROP_NATIVE_ACCESSORS;
+        JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
+        attrs &= ~JSPROP_NATIVE_ACCESSORS;
         if (getter) {
             JSObject *getobj = JS_NewFunction(cx, (JSNative) getter, 0, 0, obj->getGlobal(), NULL);
             if (!getobj)
                 return false;
             getter = JS_DATA_TO_FUNC_PTR(PropertyOp, getobj);
             attrs |= JSPROP_GETTER;
         }
         if (setter) {
--- a/js/src/jsdbg.cpp
+++ b/js/src/jsdbg.cpp
@@ -2973,17 +2973,17 @@ CheckArgCompartment(JSContext *cx, JSObj
     if (v.isObject() && v.toObject().compartment() != obj->compartment()) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_DEBUG_COMPARTMENT_MISMATCH,
                              methodname, propname);
         return false;
     }
     return true;
 }
 
-// Convert Debugger.Objects in decs to debuggee values.
+// Convert Debugger.Objects in desc to debuggee values.
 // Reject non-callable getters and setters.
 static bool
 UnwrapPropDesc(JSContext *cx, Debugger *dbg, JSObject *obj, PropDesc *desc)
 {
     return (!desc->hasValue || (dbg->unwrapDebuggeeValue(cx, &desc->value) &&
                                 CheckArgCompartment(cx, obj, desc->value, "defineProperty",
                                                     "value"))) &&
            (!desc->hasGet || (dbg->unwrapDebuggeeValue(cx, &desc->get) &&
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -5989,28 +5989,28 @@ END_CASE(JSOP_ARRAYPUSH)
             JSTrapStatus st = Debugger::onExceptionUnwind(cx, &rval);
             if (st == JSTRAP_CONTINUE) {
                 handler = cx->debugHooks->throwHook;
                 if (handler)
                     st = handler(cx, script, regs.pc, Jsvalify(&rval), cx->debugHooks->throwHookData);
             }
 
             switch (st) {
-            case JSTRAP_ERROR:
+              case JSTRAP_ERROR:
                 cx->clearPendingException();
                 goto error;
-            case JSTRAP_RETURN:
+              case JSTRAP_RETURN:
                 cx->clearPendingException();
                 regs.fp()->setReturnValue(rval);
                 interpReturnOK = JS_TRUE;
                 goto forced_return;
-            case JSTRAP_THROW:
+              case JSTRAP_THROW:
                 cx->setPendingException(rval);
-            case JSTRAP_CONTINUE:
-            default:;
+              case JSTRAP_CONTINUE:
+              default:;
             }
             CHECK_INTERRUPT_HANDLER();
         }
 
         /*
          * Look for a try block in script that can catch this exception.
          */
         if (!JSScript::isValidOffset(script->trynotesOffset))
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1040,17 +1040,17 @@ struct JSObject : js::gc::Cell {
      * Proxy-specific getters and setters.
      */
 
     inline js::JSProxyHandler *getProxyHandler() const;
     inline const js::Value &getProxyPrivate() const;
     inline void setProxyPrivate(const js::Value &priv);
     inline const js::Value &getProxyExtra() const;
     inline void setProxyExtra(const js::Value &extra);
-    JSWrapper *getWrapperHandler() const;
+    inline JSWrapper *getWrapperHandler() const;
 
     /*
      * With object-specific getters and setters.
      */
     inline JSObject *getWithThis() const;
     inline void setWithThis(JSObject *thisp);
 
     /*
@@ -1493,29 +1493,31 @@ js_PropertyIsEnumerable(JSContext *cx, J
 JS_FRIEND_API(JSBool) js_obj_defineGetter(JSContext *cx, uintN argc, js::Value *vp);
 JS_FRIEND_API(JSBool) js_obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp);
 #endif
 
 extern JSObject *
 js_InitObjectClass(JSContext *cx, JSObject *obj);
 
 namespace js {
+
 JSObject *
 DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
                               JSObject *protoProto, Class *clasp,
                               Native constructor, uintN nargs,
                               JSPropertySpec *ps, JSFunctionSpec *fs,
                               JSPropertySpec *static_ps, JSFunctionSpec *static_fs,
                               JSObject **ctorp = NULL);
 
 bool
 IsStandardClassResolved(JSObject *obj, js::Class *clasp);
 
 void
 MarkStandardClassInitializedNoProto(JSObject *obj, js::Class *clasp);
+
 }
 
 extern JSObject *
 js_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
              js::Class *clasp, js::Native constructor, uintN nargs,
              JSPropertySpec *ps, JSFunctionSpec *fs,
              JSPropertySpec *static_ps, JSFunctionSpec *static_fs,
              JSObject **ctorp = NULL);
--- a/js/src/tests/ecma_3/extensions/regress-429248.js
+++ b/js/src/tests/ecma_3/extensions/regress-429248.js
@@ -49,18 +49,19 @@ test();
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
   function c() { do{}while(0) }
 
-  if (typeof trap == 'function')
+  if (typeof trap == 'function' && typeof setDebug == 'function')
   {
+    setDebug(true);
     trap(c, 0, "");
   }
   c + '';
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_5/extensions/regress-422137.js
+++ b/js/src/tests/js1_5/extensions/regress-422137.js
@@ -49,18 +49,19 @@ test();
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
   function f() { return a(); }
 
-  if (typeof trap == 'function')
+  if (typeof trap == 'function' && typeof setDebug == 'function')
   {
+    setDebug(true);
     trap(f, 0, "print('trap')");
   }
   f + '';
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/shell.js
+++ b/js/src/tests/shell.js
@@ -274,34 +274,16 @@ if (typeof assertEq == 'undefined')
       if (!SameValue(actual, expected))
       {
         throw new TypeError('Assertion failed: got "' + actual + '", expected "' + expected +
                             (message ? ": " + message : ""));
       }
     };
 }
 
-if (typeof assertThrows === 'undefined') {
-    var assertThrows = function assertThrows(f, ctor, msg) {
-        var fullmsg;
-        try {
-            f();
-        } catch (exc) {
-            if (exc instanceof ctor)
-                return;
-            fullmsg = "Assertion failed: expected exception " + ctor.name + ", got " + exc;
-        }
-        if (fullmsg === undefined)
-            fullmsg = "Assertion failed: expected exception " + ctor.name +", no exception thrown";
-        if (msg !== undefined)
-            fullmsg += " - " + msg;
-        throw new Error(fullmsg);
-    };
-}
-
 /*
  * Compare expected result to actual result, if they differ (in value and/or
  * type) report a failure.  If description is provided, include it in the
  * failure report.
  */
 function reportCompare (expected, actual, description) {
   var expected_t = typeof expected;
   var actual_t = typeof actual;
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -168,18 +168,18 @@ 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 Debug 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.
     DebuggerVector *getOrCreateDebuggers(JSContext *cx);
 
     bool addDebugger(JSContext *cx, Debugger *dbg);
 };