summaryrefslogtreecommitdiff
path: root/cpp/src/slice2js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2014-10-23 17:40:46 +0200
committerJose <jose@zeroc.com>2014-10-23 17:40:46 +0200
commitc159f0ba2a4320883d70695ed50f5499c3ec18bd (patch)
tree89401fbe9a877844b972ebdab438bd472c58ddfc /cpp/src/slice2js
parentICE-5772 Remove .depend folder on make clean (diff)
downloadice-c159f0ba2a4320883d70695ed50f5499c3ec18bd.tar.bz2
ice-c159f0ba2a4320883d70695ed50f5499c3ec18bd.tar.xz
ice-c159f0ba2a4320883d70695ed50f5499c3ec18bd.zip
Fixed (ICE-5768) - JavaScript HashMap improvement
Diffstat (limited to 'cpp/src/slice2js')
-rw-r--r--cpp/src/slice2js/Gen.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp
index 1fede6f5833..4a3bdbac0cf 100644
--- a/cpp/src/slice2js/Gen.cpp
+++ b/cpp/src/slice2js/Gen.cpp
@@ -1741,13 +1741,16 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
// For some key types, we have to use an equals() method to compare keys
// rather than the native comparison operators.
//
- bool useEquals = false;
- const BuiltinPtr b = BuiltinPtr::dynamicCast(keyType);
+ bool keyUseEquals = false;
+ BuiltinPtr b = BuiltinPtr::dynamicCast(keyType);
if((b && b->kind() == Builtin::KindLong) || StructPtr::dynamicCast(keyType))
{
- useEquals = true;
+ keyUseEquals = true;
}
+ b = BuiltinPtr::dynamicCast(valueType);
+ bool valueUseEquals = !b || (b->kind() == Builtin::KindLong);
+
//
// Stream helpers for dictionaries of objects are lazy initialized
// as the required object type might not be available until later.
@@ -1761,10 +1764,24 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
<< "\"" << getHelper(keyType) << "\", "
<< "\"" << getHelper(valueType) << "\", "
<< (fixed ? "true" : "false") << ", "
- << (useEquals ? "true" : "false");
+ << (keyUseEquals ? "Ice.HashMap.compareEquals" : "undefined");
+
if(isClassType(valueType))
{
- _out<< ", \"" << typeToString(valueType) << "\"";
+ _out << ", \"" << typeToString(valueType) << "\"";
+ }
+ else
+ {
+ _out << ", undefined";
+ }
+
+ if(SequencePtr::dynamicCast(valueType))
+ {
+ _out << ", Ice.ArrayUtil.equals";
+ }
+ else if(valueUseEquals)
+ {
+ _out << ", Ice.HashMap.compareEquals";
}
_out << ");";
}