diff options
author | Mark Spruiell <mes@zeroc.com> | 2011-03-27 12:18:20 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2011-03-27 12:18:20 -0700 |
commit | 2518b5cb1d0a0257e4ec881383330e01c42be35f (patch) | |
tree | 5496c8aeb1eb4148ccbf59eafed7a0e736f67728 /cpp/src/slice2java/Gen.cpp | |
parent | 4919 - Glacier2::Application appName() fix in C++/C# (diff) | |
download | ice-2518b5cb1d0a0257e4ec881383330e01c42be35f.tar.bz2 ice-2518b5cb1d0a0257e4ec881383330e01c42be35f.tar.xz ice-2518b5cb1d0a0257e4ec881383330e01c42be35f.zip |
4740 - generate ice_staticId in PrxHelper classes for Java/C#
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 4af08b247d4..996ec8acc03 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -4181,7 +4181,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << nl << "catch(ClassCastException ex)"; out << sb; - out << nl << "if(__obj.ice_isA(\"" << scoped << "\"))"; + out << nl << "if(__obj.ice_isA(ice_staticId()))"; out << sb; out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();"; out << nl << "__h.__copyFrom(__obj);"; @@ -4204,7 +4204,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << nl << "catch(ClassCastException ex)"; out << sb; - out << nl << "if(__obj.ice_isA(\"" << scoped << "\", __ctx))"; + out << nl << "if(__obj.ice_isA(ice_staticId(), __ctx))"; out << sb; out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();"; out << nl << "__h.__copyFrom(__obj);"; @@ -4223,7 +4223,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "Ice.ObjectPrx __bb = __obj.ice_facet(__facet);"; out << nl << "try"; out << sb; - out << nl << "if(__bb.ice_isA(\"" << scoped << "\"))"; + out << nl << "if(__bb.ice_isA(ice_staticId()))"; out << sb; out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();"; out << nl << "__h.__copyFrom(__bb);"; @@ -4246,7 +4246,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "Ice.ObjectPrx __bb = __obj.ice_facet(__facet);"; out << nl << "try"; out << sb; - out << nl << "if(__bb.ice_isA(\"" << scoped << "\", __ctx))"; + out << nl << "if(__bb.ice_isA(ice_staticId(), __ctx))"; out << sb; out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();"; out << nl << "__h.__copyFrom(__bb);"; @@ -4292,6 +4292,41 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return __d;"; out << eb; + ClassList allBases = p->allBases(); + StringList ids; + transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped)); + StringList other; + other.push_back(scoped); + other.push_back("::Ice::Object"); + other.sort(); + ids.merge(other); + ids.unique(); + StringList::const_iterator firstIter = ids.begin(); + StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), scoped); + assert(scopedIter != ids.end()); + StringList::difference_type scopedPos = IceUtilInternal::distance(firstIter, scopedIter); + + out << sp << nl << "public static final String[] __ids ="; + out << sb; + + { + StringList::const_iterator q = ids.begin(); + while(q != ids.end()) + { + out << nl << '"' << *q << '"'; + if(++q != ids.end()) + { + out << ','; + } + } + } + out << eb << ';'; + + out << sp << nl << "public static String" << nl << "ice_staticId()"; + out << sb; + out << nl << "return __ids[" << scopedPos << "];"; + out << eb; + out << sp << nl << "protected Ice._ObjectDelM" << nl << "__createDelegateM()"; out << sb; out << nl << "return new _" << name << "DelM();"; |