diff options
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)"; |