Actually fix bustage: JS_STATIC_ASSERT cannot be used in classes.
authorLuke Wagner <lw@mozilla.com>
Tue, 18 Aug 2009 09:21:53 -0700
changeset 31882 ae6c57bbd8dbe61f8de314a0aff42415f4723665
parent 31881 3efe7be558118b7ec11b41bcfed96655567807f1
child 31883 c857e77e6f01fe66b85bef10fb8cb30d9bfb372a
push id8746
push userrsayre@mozilla.com
push dateTue, 25 Aug 2009 16:53:43 +0000
treeherdermozilla-central@189759c41621 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.3a1pre
Actually fix bustage: JS_STATIC_ASSERT cannot be used in classes.
js/src/jsvector.h
--- a/js/src/jsvector.h
+++ b/js/src/jsvector.h
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef jsvector_h_
 #define jsvector_h_
 
 #include <string.h>
 #include <new>
 
-#include "jsutil.h"
 #include "jsbit.h"
 
 /* Library of template meta-programs for use in the C++ JS data-structures. */
 namespace JSUtils {
 
 /* Statically compute min/max. */
 template <size_t i, size_t j> struct min {
     static const size_t result = i < j ? i : j;
@@ -69,22 +68,26 @@ template <size_t i> struct CeilingLog2 {
     static const size_t result = FloorLog2<2 * i - 1>::result;
 };
 
 /* Statically compute the number of bits in the given unsigned type. */
 template <class T> struct BitSize {
     static const size_t result = sizeof(T) * JS_BITS_PER_BYTE;
 };
 
+/* Allow Assertions by only including the 'result' typedef if 'true'. */
+template <bool> struct StaticAssert {};
+template <> struct StaticAssert<true> { typedef int result; };
+
 /*
  * Produce an N-bit mask, where N <= BitSize<size_t>::result.  Handle the
  * language-undefined edge case when N = BitSize<size_t>::result.
  */
 template <size_t N> struct NBitMask {
-    JS_STATIC_ASSERT(N < BitSize<size_t>::result);
+    typedef typename StaticAssert<N < BitSize<size_t>::result>::result _;
     static const size_t result = ~((size_t(1) << N) - 1);
 };
 template <> struct NBitMask<BitSize<size_t>::result> {
     static const size_t result = size_t(-1);
 };
 
 /*
  * For the unsigned integral type size_t, compute a mask M for N such that