diff options
Diffstat (limited to 'cpp/src')
-rwxr-xr-x | cpp/src/slice2cs/Gen.cpp | 29 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 7 |
2 files changed, 21 insertions, 15 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 4114dd4a3d0..4cb5a310c75 100755 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -3201,17 +3201,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _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() << "\"))"; + _out << nl << name << "Prx r = b as " << name << "Prx;"; + _out << nl << "if((r == null) && b.ice_isA(\"" << p->scoped() << "\"))"; _out << sb; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.copyFrom__(b);"; - _out << nl << "return h;"; + _out << nl << "r = h;"; _out << eb; - _out << nl << "return null;"; + _out << nl << "return r;"; _out << eb; _out << sp << nl << "public static " << name @@ -3221,17 +3218,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _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 << nl << name << "Prx r = b as " << name << "Prx;"; + _out << nl << "if((r == null) && 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 << nl << "r = h;"; _out << eb; - _out << nl << "return null;"; + _out << nl << "return r;"; _out << eb; _out << sp << nl << "public static " << name << "Prx checkedCast(Ice.ObjectPrx b, string f)"; @@ -3286,9 +3280,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) _out << sb; _out << nl << "return null;"; _out << eb; + _out << nl << name << "Prx r = b as " << name << "Prx;"; + _out << nl << "if(r == null)"; + _out << sb; _out << nl << name << "PrxHelper h = new " << name << "PrxHelper();"; _out << nl << "h.copyFrom__(b);"; - _out << nl << "return h;"; + _out << nl << "r = h;"; + _out << eb; + _out << nl << "return r;"; _out << eb; _out << sp << nl << "public static " << name << "Prx uncheckedCast(Ice.ObjectPrx b, string f)"; diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index e49e502d8f7..d802e9388b0 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -3600,10 +3600,17 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << name << "Prx __d = null;"; out << nl << "if(__obj != null)"; out << sb; + out << nl << "try"; + out << sb; + out << nl << "__d = (" << name << "Prx)__obj;"; + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; out << nl << name << "PrxHelper __h = new " << name << "PrxHelper();"; out << nl << "__h.__copyFrom(__obj);"; out << nl << "__d = __h;"; out << eb; + out << eb; out << nl << "return __d;"; out << eb; |