Commit 68965c0f by John Kessenich

Fix g++ build break (portibility problems with stl hash). This partly turns off…

Fix g++ build break (portibility problems with stl hash). This partly turns off the stl improvements. It also removes some old code that ancient compilers used to need. However, the main issue is getting access to hash functions for unordered_map in portable way.
parent 6ab3d582
...@@ -93,9 +93,9 @@ typedef pool_allocator<char> TStringAllocator; ...@@ -93,9 +93,9 @@ typedef pool_allocator<char> TStringAllocator;
typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TString; typedef std::basic_string <char, std::char_traits<char>, TStringAllocator> TString;
// Repackage the std::hash for use by unordered map/set with a TString key. // Repackage the std::hash for use by unordered map/set with a TString key.
struct TStringHash { //struct TStringHash {
size_t operator()(const TString& string) const { return std::hash<TString>()(string); } // size_t operator()(const TString& string) const { return std::hash<TString>()(string); }
}; //};
inline TString* NewPoolTString(const char* s) inline TString* NewPoolTString(const char* s)
{ {
...@@ -128,31 +128,14 @@ public: ...@@ -128,31 +128,14 @@ public:
}; };
template <class T> class TList : public std::list<T, pool_allocator<T> > { template <class T> class TList : public std::list<T, pool_allocator<T> > {
public:
typedef typename std::list<T, pool_allocator<T> >::size_type size_type;
TList() : std::list<T, pool_allocator<T> >() {}
TList(const pool_allocator<T>& a) : std::list<T, pool_allocator<T> >(a) {}
TList(size_type i): std::list<T, pool_allocator<T> >(i) {}
}; };
template <class K, class D, class CMP = std::less<K> > template <class K, class D, class CMP = std::less<K> >
class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<K, D> > > { class TMap : public std::map<K, D, CMP, pool_allocator<std::pair<K, D> > > {
public:
typedef pool_allocator<std::pair <K, D> > tAllocator;
TMap() : std::map<K, D, CMP, tAllocator >() {}
// use correct two-stage name lookup supported in gcc 3.4 and above
TMap(const tAllocator& a) : std::map<K, D, CMP, tAllocator>(TBaseMap<K, D, CMP, tAllocator >::key_compare(), a) {}
}; };
template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_to<K> > template <class K, class D, class HASH = std::hash<K>, class PRED = std::equal_to<K> >
class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K, D> > > { class TUnorderedMap : public std::unordered_map<K, D, HASH, PRED, pool_allocator<std::pair<K, D> > > {
public:
typedef pool_allocator<std::pair <K, D> > tAllocator;
TUnorderedMap() : std::unordered_map<K, D, HASH, PRED, tAllocator >() {}
// use correct two-stage name lookup supported in gcc 3.4 and above
TUnorderedMap(const tAllocator& a) : std::unordered_map<K, D, HASH, PRED, tAllocator>(TBaseMap<K, D, HASH, PRED, tAllocator >::key_compare(), a) {}
}; };
// //
......
...@@ -306,7 +306,8 @@ protected: ...@@ -306,7 +306,8 @@ protected:
TInputScanner* currentScanner; TInputScanner* currentScanner;
int numErrors; // number of compile-time errors encountered int numErrors; // number of compile-time errors encountered
bool parsingBuiltins; // true if parsing built-in symbols/functions bool parsingBuiltins; // true if parsing built-in symbols/functions
TUnorderedMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to // need portable TStringHash TUnorderedMap<TString, TExtensionBehavior, TStringHash> extensionBehavior; // for each extension string, what its current behavior is set to
TMap<TString, TExtensionBehavior> extensionBehavior; // for each extension string, what its current behavior is set to
static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex() static const int maxSamplerIndex = EsdNumDims * (EbtNumTypes * (2 * 2 * 2)); // see computeSamplerTypeIndex()
TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex]; TPrecisionQualifier defaultSamplerPrecision[maxSamplerIndex];
bool afterEOF; bool afterEOF;
......
...@@ -192,7 +192,8 @@ public: ...@@ -192,7 +192,8 @@ public:
}; };
MemoryPool *pool; MemoryPool *pool;
typedef TUnorderedMap<int, Symbol*> TSymbolMap; // need portable hash typedef TUnorderedMap<int, Symbol*> TSymbolMap;
typedef TMap<int, Symbol*> TSymbolMap;
TSymbolMap symbols; // this has light use... just defined macros TSymbolMap symbols; // this has light use... just defined macros
protected: protected:
...@@ -436,7 +437,8 @@ protected: ...@@ -436,7 +437,8 @@ protected:
// //
// From PpAtom.cpp // From PpAtom.cpp
// //
typedef TUnorderedMap<const TString, int, TStringHash> TAtomMap; // need portable TStringHash typedef TUnorderedMap<const TString, int, TStringHash> TAtomMap;
typedef TMap<const TString, int> TAtomMap;
typedef TVector<const TString*> TStringMap; typedef TVector<const TString*> TStringMap;
TAtomMap atomMap; TAtomMap atomMap;
TStringMap stringMap; TStringMap stringMap;
......
...@@ -108,7 +108,8 @@ public: ...@@ -108,7 +108,8 @@ public:
protected: protected:
friend class glslang::TLiveTraverser; friend class glslang::TLiveTraverser;
typedef std::unordered_map<TString, int> TNameToIndex; // Need a TString hash: typedef std::unordered_map<TString, int> TNameToIndex;
typedef std::map<TString, int> TNameToIndex;
typedef std::vector<TObjectReflection> TMapIndexToReflection; typedef std::vector<TObjectReflection> TMapIndexToReflection;
TObjectReflection badReflection; // return for queries of -1 or generally out of range; has expected descriptions with in it for this TObjectReflection badReflection; // return for queries of -1 or generally out of range; has expected descriptions with in it for this
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment