diff options
author | Mark Spruiell <mes@zeroc.com> | 2005-02-09 18:55:46 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2005-02-09 18:55:46 +0000 |
commit | 8e755f59261fc66631a8ed7a319961e5afc31d15 (patch) | |
tree | bf7a9225b4e8c8ca6ce4aa70d6e31689c72d3630 /cpp/src | |
parent | update copyright date (diff) | |
download | ice-8e755f59261fc66631a8ed7a319961e5afc31d15.tar.bz2 ice-8e755f59261fc66631a8ed7a319961e5afc31d15.tar.xz ice-8e755f59261fc66631a8ed7a319961e5afc31d15.zip |
allow metadata for dictionary types
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Slice/JavaUtil.cpp | 19 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 14 |
2 files changed, 26 insertions, 7 deletions
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 5cd86656d14..5a270b708c8 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -455,13 +455,26 @@ Slice::JavaGenerator::typeToString(const TypePtr& type, DictionaryPtr dict = DictionaryPtr::dynamicCast(type); if(dict) { + string dictType = findMetaData(metaData); if(mode == TypeModeOut) { return getAbsolute(dict, package, "", "Holder"); } else { - return "java.util.Map"; + if(dictType.empty()) + { + StringList l = dict->getMetaData(); + dictType = findMetaData(l); + } + if(!dictType.empty()) + { + return dictType; + } + else + { + return "java.util.Map"; + } } } @@ -2452,9 +2465,9 @@ Slice::JavaGenerator::MetaDataVisitor::validate(const SyntaxTreeBasePtr& p, cons const string& file, const string& line) { // - // Currently only sequence types can be affected by metadata. + // Currently only sequence and dictionary types can be affected by metadata. // - if(!metaData.empty() && !SequencePtr::dynamicCast(p)) + if(!metaData.empty() && !SequencePtr::dynamicCast(p) && !DictionaryPtr::dynamicCast(p)) { string str; ContainedPtr cont = ContainedPtr::dynamicCast(p); diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index f03608a955d..f3b86d2aacc 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -3176,6 +3176,8 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) string package = getPackage(p); string keyS = typeToString(key, TypeModeIn, package); string valueS = typeToString(value, TypeModeIn, package); + StringList metaData = p->getMetaData(); + string dictType = findMetaData(metaData); int iter; int i; @@ -3365,10 +3367,12 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << eb; } - out << sp << nl << "public static java.util.Map" << nl << "read(IceInternal.BasicStream __is)"; + out << sp << nl << "public static " << (dictType.empty() ? "java.util.Map" : dictType); + out << nl << "read(IceInternal.BasicStream __is)"; out << sb; out << nl << "int __sz = __is.readSize();"; - out << nl << "java.util.Map __r = new java.util.HashMap(__sz);"; + out << nl << (dictType.empty() ? "java.util.Map" : dictType) << " __r = new " + << (dictType.empty() ? "java.util.HashMap(__sz)" : dictType + "()") << ';'; out << nl << "for(int __i = 0; __i < __sz; __i++)"; out << sb; iter = 0; @@ -3569,10 +3573,12 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) out << eb; out << eb; - out << sp << nl << "public static java.util.Map" << nl << "read(Ice.InputStream __in)"; + out << sp << nl << "public static " << (dictType.empty() ? "java.util.Map" : dictType) + << nl << "read(Ice.InputStream __in)"; out << sb; out << nl << "int __sz = __in.readSize();"; - out << nl << "java.util.Map __r = new java.util.HashMap(__sz);"; + out << nl << (dictType.empty() ? "java.util.Map" : dictType) << " __r = new " + << (dictType.empty() ? "java.util.HashMap(__sz)" : dictType + "()") << ';'; out << nl << "for(int __i = 0; __i < __sz; __i++)"; out << sb; iter = 0; |