Bug 714264 - Move declarations around such that it's possible to include jsprvtd.h before Vector.h or HashTable.h. r=luke
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -43,16 +43,18 @@
#ifndef jshashtable_h_
#define jshashtable_h_
#include "TemplateLib.h"
#include "Utility.h"
namespace js {
+class TempAllocPolicy;
+
/* Integral types for all hash functions. */
typedef uint32_t HashNumber;
/*****************************************************************************/
namespace detail {
template <class T, class HashPolicy, class AllocPolicy>
@@ -953,17 +955,20 @@ struct IsPodType<HashMapEntry<K, V> >
* - see "Hash policy" above (default js::DefaultHasher<Key>)
* AllocPolicy:
* - see "Allocation policies" in jsalloc.h
*
* N.B: HashMap is not reentrant: Key/Value/HashPolicy/AllocPolicy members
* called by HashMap must not call back into the same HashMap object.
* N.B: Due to the lack of exception handling, the user must call |init()|.
*/
-template <class Key, class Value, class HashPolicy, class AllocPolicy>
+template <class Key,
+ class Value,
+ class HashPolicy = DefaultHasher<Key>,
+ class AllocPolicy = TempAllocPolicy>
class HashMap
{
public:
typedef typename HashPolicy::Lookup Lookup;
typedef HashMapEntry<Key, Value> Entry;
private:
@@ -1195,17 +1200,17 @@ class HashMap
* - see "Hash policy" above (default js::DefaultHasher<Key>)
* AllocPolicy:
* - see "Allocation policies" in jsalloc.h
*
* N.B: HashSet is not reentrant: T/HashPolicy/AllocPolicy members called by
* HashSet must not call back into the same HashSet object.
* N.B: Due to the lack of exception handling, the user must call |init()|.
*/
-template <class T, class HashPolicy, class AllocPolicy>
+template <class T, class HashPolicy = DefaultHasher<T>, class AllocPolicy = TempAllocPolicy>
class HashSet
{
typedef typename HashPolicy::Lookup Lookup;
/* Implement HashSet in terms of HashTable. */
struct SetOps : HashPolicy {
typedef T KeyType;
static const KeyType &getKey(const T &t) { return t; }
--- a/js/public/Vector.h
+++ b/js/public/Vector.h
@@ -49,17 +49,21 @@
/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4345)
#endif
namespace js {
-template <class T, size_t N, class AllocPolicy>
+class TempAllocPolicy;
+
+template <class T,
+ size_t MinInlineCapacity = 0,
+ class AllocPolicy = TempAllocPolicy>
class Vector;
/*
* This template class provides a default implementation for vector operations
* when the element type is not known to be a POD, as judged by IsPodType.
*/
template <class T, size_t N, class AP, bool IsPod>
struct VectorImpl
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -50,18 +50,22 @@
* declaring a pointer to struct type, or defining a member of struct type.
*
* A few fundamental scalar types are defined here too. Neither the scalar
* nor the struct typedefs should change much, therefore the nearly-global
* make dependency induced by this file should not prove painful.
*/
#include "jsapi.h"
+#include "jsutil.h"
-#include "jsutil.h"
+#ifdef __cplusplus
+#include "js/HashTable.h"
+#include "js/Vector.h"
+#endif
JS_BEGIN_EXTERN_C
/*
* Convenience constants.
*/
#define JS_BITS_PER_UINT32_LOG2 5
#define JS_BITS_PER_UINT32 32
@@ -183,35 +187,16 @@ class ProxyHandler;
class Wrapper;
class CrossCompartmentWrapper;
class TempAllocPolicy;
class RuntimeAllocPolicy;
class GlobalObject;
-template <class T,
- size_t MinInlineCapacity = 0,
- class AllocPolicy = TempAllocPolicy>
-class Vector;
-
-template <class>
-struct DefaultHasher;
-
-template <class Key,
- class Value,
- class HashPolicy = DefaultHasher<Key>,
- class AllocPolicy = TempAllocPolicy>
-class HashMap;
-
-template <class T,
- class HashPolicy = DefaultHasher<T>,
- class AllocPolicy = TempAllocPolicy>
-class HashSet;
-
template <typename K,
typename V,
size_t InlineElems>
class InlineMap;
class LifoAlloc;
class PropertyCache;