diff options
author | Michi Henning <michi@zeroc.com> | 2004-12-07 03:42:33 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2004-12-07 03:42:33 +0000 |
commit | f2b17fda37ef30d1c79df2aeae9b1d02ffaa8f86 (patch) | |
tree | 9b4c8e9895b775d0b6add1c7b6b0766d53d228b1 /cpp/src/slice2cs/Gen.cpp | |
parent | removed bogus character in file (diff) | |
download | ice-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/slice2cs/Gen.cpp')
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 61f22690c97..a51903c5487 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -3121,6 +3121,25 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return null;"; _out << eb; + _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b, Ice.Context ctx)"; + _out << sb; + _out << nl << "if(b == null)"; + _out << sb; + _out << nl << "return null;"; + _out << eb; + _out << nl << "if(b is " << name << "Prx)"; + _out << sb; + _out << nl << "return (" << name << "Prx)b;"; + _out << eb; + _out << nl << "if(b.ice_isA(\"" << p->scoped() << "\", ctx))"; + _out << sb; + _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; + _out << nl << "h.__copyFrom(b);"; + _out << nl << "return h;"; + _out << eb; + _out << nl << "return null;"; + _out << eb; + _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b, string f)"; _out << sb; _out << nl << "if(b == null)"; @@ -3143,6 +3162,28 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << nl << "return null;"; _out << eb; + _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b, string f, Ice.Context ctx)"; + _out << sb; + _out << nl << "if(b == null)"; + _out << sb; + _out << nl << "return null;"; + _out << eb; + _out << nl << "Ice.ObjectPrx bb = b.ice_newFacet(f);"; + _out << nl << "try"; + _out << sb; + _out << nl << "if(bb.ice_isA(\"" << p->scoped() << "\", ctx))"; + _out << sb; + _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; + _out << nl << "h.__copyFrom(bb);"; + _out << nl << "return h;"; + _out << eb; + _out << eb; + _out << nl << "catch(Ice.FacetNotExistException)"; + _out << sb; + _out << eb; + _out << nl << "return null;"; + _out << eb; + _out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx b)"; _out << sb; _out << nl << "if(b == null)"; |