diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/slice2cs/Gen.cpp | 54 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 43 |
2 files changed, 89 insertions, 8 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index dac53b55108..3a42b861d50 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -4764,7 +4764,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return null;"; _out << eb; _out << nl << name << "Prx r = b as " << name << "Prx;"; - _out << nl << "if((r == null) && b.ice_isA(\"" << p->scoped() << "\"))"; + _out << nl << "if((r == null) && b.ice_isA(ice_staticId()))"; _out << sb; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.copyFrom__(b);"; @@ -4781,7 +4781,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return null;"; _out << eb; _out << nl << name << "Prx r = b as " << name << "Prx;"; - _out << nl << "if((r == null) && b.ice_isA(\"" << p->scoped() << "\", ctx))"; + _out << nl << "if((r == null) && b.ice_isA(ice_staticId(), ctx))"; _out << sb; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.copyFrom__(b);"; @@ -4799,7 +4799,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "Ice.ObjectPrx bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; - _out << nl << "if(bb.ice_isA(\"" << p->scoped() << "\"))"; + _out << nl << "if(bb.ice_isA(ice_staticId()))"; _out << sb; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.copyFrom__(bb);"; @@ -4823,7 +4823,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "Ice.ObjectPrx bb = b.ice_facet(f);"; _out << nl << "try"; _out << sb; - _out << nl << "if(bb.ice_isA(\"" << p->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);"; @@ -4864,6 +4864,52 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return h;"; _out << eb; + string scoped = p->scoped(); + ClassList allBases = p->allBases(); + StringList ids; +#if defined(__IBMCPP__) && defined(NDEBUG) + // + // VisualAge C++ 6.0 does not see that ClassDef is a Contained, + // when inlining is on. The code below issues a warning: better + // than an error! + // + transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun<string,ClassDef>(&Contained::scoped)); +#else + transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped)); +#endif + StringList other; + other.push_back(p->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 readonly 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 ice_staticId()"; + _out << sb; + _out << nl << "return ids__[" << scopedPos << "];"; + _out << eb; + _out << sp << nl << "#endregion"; // Checked and unchecked cast operations _out << sp << nl << "#region Marshaling support"; 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();"; |