summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/slice2cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp81
-rw-r--r--cpp/src/slice2cpp/GenUtil.cpp46
-rw-r--r--cpp/src/slice2cpp/GenUtil.h1
3 files changed, 124 insertions, 4 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 5c34a76005d..c6a14f2f392 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -497,6 +497,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDef_ptr& p)
return;
string name = p -> name();
+ string scoped = p -> scoped();
ClassList bases = p -> bases();
H << sp;
@@ -520,6 +521,13 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDef_ptr& p)
H.dec();
H << nl << "public: ";
H.inc();
+
+ H << sp;
+ H << nl << "virtual void _throw();";
+ C << sp << nl << "void" << nl << "__IceProxy" << scoped << "::_throw()";
+ C << sb;
+ C << nl << "throw " << scoped << "_prxE(this);";
+ C << eb;
}
void
@@ -947,13 +955,16 @@ Slice::Gen::DelegateMVisitor::visitOperation(const Operation_ptr& p)
{
C.dec();
C << nl << "case " << cnt++ << ':';
- C.sb();
+ C << sb;
TypeStringList li;
li.push_back(make_pair(*r, string("__ex")));
writeAllocateCode(C, li, 0);
writeUnmarshalCode(C, li, 0);
- C << nl << "throw __ex;";
- C.eb();
+ if(ClassDecl_ptr::dynamicCast(*r) || Proxy_ptr::dynamicCast(*r))
+ C << nl << "__ex -> _throw();";
+ else
+ C << nl << "throw __ex;";
+ C << eb;
C.inc();
}
C << eb;
@@ -1101,6 +1112,60 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDef_ptr& p)
C << nl << "return dynamic_cast< " << scoped << "*>(ptr_.get());";
C << eb;
+ if(!p -> isLocal())
+ {
+ H << sp;
+ H << nl << "class" << dllExport_ << ' ' << name << "_prxE : ";
+ H.useCurrentPosAsIndent();
+ if(bases.empty())
+ H << "virtual public ::Ice::Object_prxE";
+ else
+ {
+ ClassList::iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public " << (*q) -> scoped()
+ << "_prxE";
+ if(++q != bases.end())
+ H << ',' << nl;
+ }
+ }
+ H.restoreIndent();
+ H << sb;
+ H.dec();
+ H << nl << "public: ";
+ H.inc();
+ H << sp;
+ H << nl << name << "_prxE() { }";
+ H << nl << name << "_prxE(const " << name << "_prxE&);";
+ H << nl << "explicit " << name << "_prxE(const " << name << "_prx&);";
+ H << nl << "operator " << name << "_prx() const;";
+ H << nl << "::__IceProxy" << scoped << "* operator->() const;";
+ H << eb << ';';
+ C << sp << nl << scoped.substr(2) << "_prxE::" << name
+ << "_prxE(const " << name << "_prxE& p)";
+ C << sb;
+ C << nl << "prx_ = p.prx_;";
+ C << eb;
+ C << sp << nl << scoped.substr(2) << "_prxE::" << name
+ << "_prxE(const " << scoped << "_prx& p)";
+ C << sb;
+ C << nl << "prx_ = p;";
+ C << eb;
+ C << sp << nl << scoped.substr(2) << "_prxE::operator " << scoped
+ << "_prx() const";
+ C << sb;
+ C << nl << "return " << scoped << "_prx(dynamic_cast< ::__IceProxy"
+ << scoped << "*>(prx_.get()));";
+ C << eb;
+ C << sp << nl << "::__IceProxy" << scoped << '*' << nl
+ << scoped.substr(2) << "_prxE::operator->() const";
+ C << sb;
+ C << nl << "return dynamic_cast< ::__IceProxy" << scoped
+ << "*>(prx_.get());";
+ C << eb;
+ }
+
H << sp;
H << nl << "class" << dllExport_ << ' ' << name << " : ";
H.useCurrentPosAsIndent();
@@ -1128,6 +1193,14 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDef_ptr& p)
H.dec();
H << nl << "public: ";
H.inc();
+
+ H << sp;
+ H << nl << "virtual void _throw();";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::_throw()";
+ C << sb;
+ C << nl << "throw " << scoped << "_ptrE(this);";
+ C << eb;
+
if(!p -> isLocal())
{
ClassList allBases = p -> allBases();
@@ -1438,7 +1511,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const Operation_ptr& p)
Ice::Int cnt = 0;
for(r = throws.begin(); r != throws.end(); ++r)
{
- C << nl << "catch(" << inputTypeToString(*r) << " __ex)";
+ C << nl << "catch(" << exceptionTypeToString(*r) << " __ex)";
C << sb;
C << nl << "__os -> write(" << cnt++ << ");";
writeMarshalUnmarshalCode(C, *r, "__ex", true);
diff --git a/cpp/src/slice2cpp/GenUtil.cpp b/cpp/src/slice2cpp/GenUtil.cpp
index d6a48b60bfe..42da4f6bbc8 100644
--- a/cpp/src/slice2cpp/GenUtil.cpp
+++ b/cpp/src/slice2cpp/GenUtil.cpp
@@ -148,6 +148,52 @@ Slice::outputTypeToString(const Type_ptr& type)
return "???";
}
+string
+Slice::exceptionTypeToString(const Type_ptr& type)
+{
+ static const char* inputBuiltinTable[] =
+ {
+ "::Ice::Byte",
+ "bool",
+ "::Ice::Short",
+ "::Ice::Int",
+ "::Ice::Long",
+ "::Ice::Float",
+ "::Ice::Double",
+ "const ::std::string&",
+ "const ::std::wstring&",
+ "const ::Ice::Object_ptrE&",
+ "const ::Ice::Object_prx&",
+ "const ::Ice::LocalObject_ptrE&"
+ };
+
+ Builtin_ptr builtin = Builtin_ptr::dynamicCast(type);
+ if(builtin)
+ return inputBuiltinTable[builtin -> kind()];
+
+ ClassDecl_ptr cl = ClassDecl_ptr::dynamicCast(type);
+ if(cl)
+ return "const " + cl -> scoped() + "_ptrE&";
+
+ Proxy_ptr proxy = Proxy_ptr::dynamicCast(type);
+ if(proxy)
+ return "const " + proxy -> _class() -> scoped() + "_prx&";
+
+ Enum_ptr en = Enum_ptr::dynamicCast(type);
+ if(en)
+ return en -> scoped();
+
+ Native_ptr native = Native_ptr::dynamicCast(type);
+ if(native)
+ return native -> scoped();
+
+ Contained_ptr contained = Contained_ptr::dynamicCast(type);
+ if(contained)
+ return "const " + contained -> scoped() + "&";
+
+ return "???";
+}
+
void
Slice::writeMarshalUnmarshalCode(Output& out, const Type_ptr& type,
const string& param, bool marshal)
diff --git a/cpp/src/slice2cpp/GenUtil.h b/cpp/src/slice2cpp/GenUtil.h
index bea707b983d..21f1f83fe85 100644
--- a/cpp/src/slice2cpp/GenUtil.h
+++ b/cpp/src/slice2cpp/GenUtil.h
@@ -21,6 +21,7 @@ std::string typeToString(const Type_ptr&);
std::string returnTypeToString(const Type_ptr&);
std::string inputTypeToString(const Type_ptr&);
std::string outputTypeToString(const Type_ptr&);
+std::string exceptionTypeToString(const Type_ptr&);
void writeMarshalUnmarshalCode(Output&,
const Type_ptr&,