From 775ed98a18bcbda8742269ad262b5691706521c8 Mon Sep 17 00:00:00 2001 From: "rogerl%netscape.com" Date: Thu, 20 Mar 2003 22:04:14 +0000 Subject: [PATCH] Template build issues. --- js2/src/hash.h | 94 ++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/js2/src/hash.h b/js2/src/hash.h index dcacf8ecfeb..8810be30f67 100644 --- a/js2/src/hash.h +++ b/js2/src/hash.h @@ -247,7 +247,6 @@ namespace JavaScript { Data &insert(Reference &r, Key key); Data &insert(Key key); - Data &insert(Data data); void erase(Reference &r); void erase(Key key); Data *operator[](Key key); @@ -265,6 +264,7 @@ namespace JavaScript { #ifndef _WIN32 template Data &insert(Key key, Value value); template Data &insert(Reference &r, Key key, Value value); + template Data &insert(Data data); #else // Microsoft VC6 bug: VC6 doesn't allow this to be defined outside the // class @@ -291,6 +291,14 @@ namespace JavaScript { return insert(r, key, value); } + template + Data &HashTable::insert(Data data) + { + Key key = data.key(); + Value value = data.value(); + return insert(key, value); + } + #endif }; @@ -356,43 +364,46 @@ namespace JavaScript { #endif return e->data; } -#endif + + // Insert the given key/value pair into the hash table. If an entry with a + // matching key already exists, replace that entry's value. + // Return a reference to the new entry's value. + + // Microsoft VC6 bug: VC6 doesn't allow this to be defined outside the class + template template + Data &HashTable::insert(Key key, Value value) + { + Reference r(*this, key); + if (r) + return *r = value; + else + return insert(r, key, value); + } + + template template + Data &HashTable::insert(Data data) + { + Key key = data.key(); + Value value = data.value(); + return insert(key, value); + } +#endif // !_WIN32 - // Same as above but without a Value argument. - template - inline Data &HashTable::insert(Reference &r, Key key) - { - ASSERT(r.ht == this && !r.entry); - Entry *e = new Entry(r.keyHash, key); - *r.backpointer = e; - ++nEntries; - maybeGrow(); -#ifdef DEBUG - --r.ht->nReferences; - r.ht = 0; -#endif - return e->data; - } - - - - // Insert the given key/value pair into the hash table. If an entry with a - // matching key already exists, replace that entry's value. - // Return a reference to the new entry's value. -#ifndef _WIN32 - // Microsoft VC6 bug: VC6 doesn't allow this to be defined outside the class - template template - Data &HashTable::insert(Key key, Value value) - { - Reference r(*this, key); - if (r) - return *r = value; - else - return insert(r, key, value); - } -#endif - - // Same as above but without a Value argument. + template + inline Data &HashTable::insert(Reference &r, Key key) + { + ASSERT(r.ht == this && !r.entry); + Entry *e = new Entry(r.keyHash, key); + *r.backpointer = e; + ++nEntries; + maybeGrow(); +#ifdef DEBUG + --r.ht->nReferences; + r.ht = 0; +#endif + return e->data; + } + template Data &HashTable::insert(Key key) { @@ -404,15 +415,6 @@ namespace JavaScript { } - // Same as above but with just a Data argument. - template - Data &HashTable::insert(Data data) - { - Key key = data.key(); - Value value = data.value(); - return insert(key, value); - } - // Reference r must point to an existing entry. Delete that entry. // The reference is not valid after this method is called.