summaryrefslogtreecommitdiff
path: root/cpp/src/slice2java/Gen.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-12-07 03:42:33 +0000
committerMichi Henning <michi@zeroc.com>2004-12-07 03:42:33 +0000
commitf2b17fda37ef30d1c79df2aeae9b1d02ffaa8f86 (patch)
tree9b4c8e9895b775d0b6add1c7b6b0766d53d228b1 /cpp/src/slice2java/Gen.cpp
parentremoved bogus character in file (diff)
downloadice-f2b17fda37ef30d1c79df2aeae9b1d02ffaa8f86.tar.bz2
ice-f2b17fda37ef30d1c79df2aeae9b1d02ffaa8f86.tar.xz
ice-f2b17fda37ef30d1c79df2aeae9b1d02ffaa8f86.zip
Added context parameter to checkedCast() for Java, C#, and VB.
Diffstat (limited to 'cpp/src/slice2java/Gen.cpp')
-rw-r--r--cpp/src/slice2java/Gen.cpp45
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;";