diff options
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 51c7306b713..f03608a955d 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -2880,6 +2880,28 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return d;"; out << eb; + out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx b, java.util.Map ctx)"; + out << sb; + out << nl << name << "Prx d = null;"; + out << nl << "if(b != null)"; + out << sb; + out << nl << "try"; + out << sb; + out << nl << "d = (" << name << "Prx)b;"; + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "if(b.ice_isA(\"" << scoped << "\", ctx))"; + out << sb; + out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; + out << nl << "h.__copyFrom(b);"; + out << nl << "d = h;"; + out << eb; + out << eb; + out << eb; + out << nl << "return d;"; + out << eb; + out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx b, String f)"; out << sb; out << nl << name << "Prx d = null;"; @@ -2902,6 +2924,29 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << "return d;"; out << eb; + out << sp << nl << "public static " << name << "Prx" + << nl << "checkedCast(Ice.ObjectPrx b, String f, java.util.Map ctx)"; + out << sb; + out << nl << name << "Prx d = null;"; + out << nl << "if(b != null)"; + out << sb; + out << nl << "Ice.ObjectPrx bb = b.ice_newFacet(f);"; + out << nl << "try"; + out << sb; + out << nl << "if(bb.ice_isA(\"" << scoped << "\", ctx))"; + out << sb; + out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; + out << nl << "h.__copyFrom(bb);"; + out << nl << "d = h;"; + out << eb; + out << eb; + out << nl << "catch(Ice.FacetNotExistException ex)"; + out << sb; + out << eb; + out << eb; + out << nl << "return d;"; + out << eb; + out << sp << nl << "public static " << name << "Prx" << nl << "uncheckedCast(Ice.ObjectPrx b)"; out << sb; out << nl << name << "Prx d = null;"; |