summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp41
-rw-r--r--cpp/src/slice2java/Gen.cpp45
-rwxr-xr-xcpp/src/slice2vb/Gen.cpp50
-rw-r--r--cpp/test/Ice/operations/operationsS.dsp4
4 files changed, 138 insertions, 2 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)";
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;";
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp
index 80e12353be1..68acbab0fd0 100755
--- a/cpp/src/slice2vb/Gen.cpp
+++ b/cpp/src/slice2vb/Gen.cpp
@@ -3566,6 +3566,31 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out.dec();
_out << nl << "End Function";
+ _out << sp << nl << "Public Shared Function checkedCast(ByVal b As Ice.ObjectPrx, ByVal ctx As Ice.Context) As "
+ << name << "Prx";
+ _out.inc();
+ _out << nl << "If b Is Nothing Then";
+ _out.inc();
+ _out << nl << "Return Nothing";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "If TypeOf b Is " << name << "Prx Then";
+ _out.inc();
+ _out << nl << "Return CType(b, " << name << "Prx)";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "If b.ice_isA(\"" << p->scoped() << "\", ctx) Then";
+ _out.inc();
+ _out << nl << "Dim h As " << name << "PrxHelper = New " << name << "PrxHelper";
+ _out << nl << "h.__copyFrom(b)";
+ _out << nl << "Return h";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "Return Nothing";
+ _out.dec();
+ _out << nl << "End Function";
+
+
_out << sp << nl << "Public Shared Function checkedCast(ByVal B As Ice.ObjectPrx, ByVal f As String) As "
<< name << "Prx";
_out.inc();
@@ -3591,6 +3616,31 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
_out.dec();
_out << nl << "End Function";
+ _out << sp << nl << "Public Shared Function checkedCast(ByVal B As Ice.ObjectPrx, ByVal f As String, "
+ << "ByVal ctx As Ice.Context) As " << name << "Prx";
+ _out.inc();
+ _out << nl << "If b Is Nothing Then";
+ _out.inc();
+ _out << nl << "Return Nothing";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "Dim bb As Ice.ObjectPrx = b.ice_newFacet(f)";
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "If bb.ice_isA(\"" << p->scoped() << "\", ctx) Then";
+ _out.inc();
+ _out << nl << "Dim h As " << name << "PrxHelper = new " << name << "PrxHelper()";
+ _out << nl << "h.__copyFrom(bb)";
+ _out << nl << "Return h";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "Catch __ex As Ice.FacetNotExistException";
+ _out << nl << "End Try";
+ _out << nl << "Return Nothing";
+ _out.dec();
+ _out << nl << "End Function";
+
_out << sp << nl << "Public Shared Function uncheckedCast(ByVal b As Ice.ObjectPrx) As " << name << "Prx";
_out.inc();
_out << nl << "If b Is Nothing Then";
diff --git a/cpp/test/Ice/operations/operationsS.dsp b/cpp/test/Ice/operations/operationsS.dsp
index 5bab4e4fadf..75fa103f4ab 100644
--- a/cpp/test/Ice/operations/operationsS.dsp
+++ b/cpp/test/Ice/operations/operationsS.dsp
@@ -68,8 +68,8 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../include" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c
-# SUBTRACT CPP /Fr /YX
+# ADD CPP /nologo /MDd /W3 /WX /Gm /GR /GX /Zi /Od /I "." /I "../../../include" /I "../../include" /D "_DEBUG" /D "_CONSOLE" /Fr /FD /GZ /c
+# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe